*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

:root {
  --bg-dark: #0a0c10;
  --surface-dark: #121620;
  --surface-card: #181d2a;
  --surface-hover: #22293b;
  --border-muted: #263044;
  --gold-glow: #e09d43;
  --gold-accent: #f5b041;
  --text-main: #f0f4fc;
  --text-muted: #8a96aa;
  --accent-cyan: #00f0ff;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#game-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background: radial-gradient(circle at 30% 50%, #1a1712 0%, var(--bg-dark) 70%);
}

/* Header Bar */
#top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background-color: var(--surface-dark);
  border-bottom: 1px solid var(--border-muted);
  z-index: 10;
}

.stat-group {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--gold-accent);
  font-variant-numeric: tabular-nums;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--surface-card);
  border: 1px solid var(--border-muted);
  color: var(--text-main);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}

.icon-btn:hover {
  background: var(--surface-hover);
  border-color: var(--gold-accent);
}

.icon-btn:active {
  transform: scale(0.92);
}

/* Main Split */
#game-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

@media (max-width: 680px) {
  #game-main {
    flex-direction: column;
  }
}

/* Left Cookie Area */
#cookie-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 20px;
}

#bakery-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

#cookie-glow {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 176, 65, 0.22) 0%, rgba(0,0,0,0) 70%);
  pointer-events: none;
  animation: pulse-glow 3s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
}

#big-cookie {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  width: 220px;
  height: 220px;
  display: grid;
  place-items: center;
  transition: transform 0.08s ease-out;
  touch-action: manipulation;
  z-index: 2;
}

#big-cookie:active {
  transform: scale(0.92);
}

.cookie-svg {
  width: 100%;
  height: 100%;
}

/* Floating Particles */
#click-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.click-float {
  position: absolute;
  font-weight: 800;
  font-size: 20px;
  color: #ffd580;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  animation: float-fade 0.8s ease-out forwards;
}

@keyframes float-fade {
  0% { transform: translateY(0) scale(0.9); opacity: 1; }
  100% { transform: translateY(-50px) scale(1.15); opacity: 0; }
}

/* Right Shop Area */
#shop-section {
  width: 360px;
  background-color: var(--surface-dark);
  border-left: 1px solid var(--border-muted);
  display: flex;
  flex-direction: column;
  z-index: 5;
}

@media (max-width: 680px) {
  #shop-section {
    width: 100%;
    flex: 1.2;
    border-left: none;
    border-top: 1px solid var(--border-muted);
  }
}

.shop-tabs {
  display: flex;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-muted);
}

.shop-tab {
  flex: 1;
  padding: 12px 6px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.shop-tab.active {
  color: var(--gold-accent);
  border-bottom-color: var(--gold-accent);
  background: rgba(245, 176, 65, 0.05);
}

.shop-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  gap: 8px;
}

.shop-content.active {
  display: flex;
  flex-direction: column;
}

/* Building Card */
.building-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-card);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
  min-height: 54px;
}

.building-card:hover:not(.disabled) {
  background: var(--surface-hover);
  border-color: var(--gold-accent);
}

.building-card:active:not(.disabled) {
  transform: scale(0.98);
}

.building-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bldg-info {
  display: flex;
  flex-direction: column;
}

.bldg-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.bldg-cps {
  font-size: 11px;
  color: var(--text-muted);
}

.bldg-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.bldg-cost {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-accent);
}

.bldg-count {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-cyan);
}

/* Upgrades Cards */
.upgrade-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-card);
  border: 1px solid var(--border-muted);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}

.upgrade-card:hover:not(.disabled) {
  background: var(--surface-hover);
  border-color: var(--accent-cyan);
}

.upgrade-card.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Stats Cards */
.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-muted);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sc-label {
  font-size: 12px;
  color: var(--text-muted);
}

.sc-val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.prestige-btn {
  margin-top: 14px;
}

/* Golden Cookie */
.golden-cookie {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff7b2 0%, #ffc83b 50%, #d88900 100%);
  border: 2px solid #fff;
  box-shadow: 0 0 20px #ffd54f, 0 0 40px #ffb300;
  cursor: pointer;
  animation: float-golden 2s infinite ease-in-out;
  z-index: 20;
}

@keyframes float-golden {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.18); }
}

/* Modals */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.88);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 16px;
}

.overlay.hidden {
  display: none !important;
}

.modal-box {
  background: var(--surface-dark);
  border: 1px solid var(--border-muted);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}

.modal-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--gold-accent);
  margin-bottom: 8px;
}

.modal-subtitle {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.pill {
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-card);
  border: 1px solid var(--border-muted);
  border-radius: 20px;
  padding: 4px 10px;
  color: var(--text-main);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f5b041 0%, #d47e0a 100%);
  color: #121008;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(245, 176, 65, 0.35);
  transition: transform 0.1s, box-shadow 0.15s;
}

.btn-primary:hover {
  box-shadow: 0 6px 18px rgba(245, 176, 65, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}
