:root {
  --bg: #f2efe9;
  --surface: #ffffff;
  --ink: #1e1b16;
  --muted: #6c5e4d;
  --accent: #f0672a;
  --accent-dark: #c94b15;
  --mint: #17a398;
  --shadow: 0 18px 45px rgba(30, 27, 22, 0.12);
  --radius: 18px;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: radial-gradient(circle at top, #ffe7d4 0%, #f2efe9 45%, #e8efe8 100%);
  color: var(--ink);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
}

.hero__text h1 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 12px;
}

.subtitle {
  color: var(--muted);
  max-width: 520px;
  font-size: 1rem;
}

.hero__score {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 12px;
}

.score-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 10px 24px rgba(30, 27, 22, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.high-score-card {
  background: linear-gradient(135deg, #ffecd1 0%, #ffe2f1 100%);
  border: 2px solid rgba(240, 103, 42, 0.25);
}

.score-spark {
  font-size: 0.85rem;
  color: #6a3b2e;
  letter-spacing: 0.04em;
}

.score-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.score-value {
  font-size: 2rem;
  font-weight: 700;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
}

.card__header h2 {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.card__header p {
  color: var(--muted);
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.tile {
  border: none;
  border-radius: 16px;
  padding: 18px;
  text-align: left;
  background: #fff7ef;
  border: 1px solid #eadfce;
  cursor: pointer;
  display: grid;
  gap: 8px;
  min-height: 120px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.tile h3 {
  font-size: 1.1rem;
}

.tile p {
  color: var(--muted);
  font-size: 0.95rem;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(30, 27, 22, 0.12);
}

.gate {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}

.question {
  font-size: clamp(1.9rem, 3.2vw, 2.8rem);
  font-weight: 700;
  background: #fff4e9;
  padding: 18px 22px;
  border-radius: 16px;
  border: 1px solid #f6c7a8;
  text-align: center;
  letter-spacing: 0.01em;
  width: min(520px, 100%);
}

.gate__meta {
  width: min(520px, 100%);
  display: flex;
  justify-content: center;
  margin-top: -4px;
}

.gate__progress {
  font-size: 0.9rem;
  color: var(--muted);
  background: #f7f0e8;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #eadfce;
}

.gate__inputs {
  display: grid;
  grid-template-columns: minmax(180px, 260px);
  gap: 10px;
  align-items: center;
  justify-items: center;
  width: min(320px, 100%);
  margin-top: 2px;
}

.answer-label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

input[type="number"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #e5d7c5;
  font-size: 1.15rem;
  background: #fffdf9;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.answer-input {
  width: 100%;
}

input[type="number"]:focus {
  outline: none;
  border-color: #1f5fff;
  box-shadow: 0 0 0 3px rgba(31, 95, 255, 0.15);
}

.gate .btn {
  padding: 14px 24px;
  font-size: 1.05rem;
  white-space: nowrap;
}

.gate__submit {
  justify-self: center;
  min-width: 190px;
  background: linear-gradient(135deg, #f0672a 0%, #ff8a4c 100%);
  box-shadow: 0 10px 22px rgba(240, 103, 42, 0.35);
}

.gate__controls {
  justify-content: center;
}

.feedback {
  min-height: 24px;
  font-weight: 600;
  color: var(--mint);
  text-align: center;
  font-size: 1.05rem;
}

.feedback.unlock {
  font-size: 1.35rem;
  color: #f0672a;
  text-shadow: 0 6px 18px rgba(240, 103, 42, 0.35);
  animation: unlock-pop 0.6s ease;
}

@keyframes unlock-pop {
  0% { transform: scale(0.98); opacity: 0.6; }
  60% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.answer-input {
  flex: 0 0 180px;
  max-width: 200px;
}

.btn {
  border: none;
  background: var(--accent);
  color: white;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(240, 103, 42, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(240, 103, 42, 0.35);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.ghost {
  background: #f4efe8;
  color: var(--ink);
  box-shadow: none;
  border: 1px solid #e1d6c7;
}

.feedback {
  min-height: 24px;
  font-weight: 600;
  color: var(--mint);
}

.gate__controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hidden {
  display: none;
}

.game {
  display: grid;
  grid-template-columns: minmax(280px, 480px) 1fr;
  gap: 24px;
  align-items: start;
}

.game--stack {
  grid-template-columns: 1fr;
}

#game-canvas {
  width: 100%;
  max-width: 100%;
  border-radius: 16px;
  background: #0f1d1b;
  border: 4px solid #1f302f;
}

.game__panel--wide {
  width: 100%;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.game__panel--wide .panel__row,
.game__panel--wide .dial,
.game__panel--wide .btn,
.game__panel--wide .hint {
  width: 100%;
}

.dial {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f7f0e8;
}

.dial label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.dial input[type="range"] {
  width: 100%;
  accent-color: #1f5fff;
}


.game__panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel__row {
  display: flex;
  justify-content: space-between;
  font-size: 1rem;
  padding: 10px 12px;
  background: #f7f0e8;
  border-radius: 12px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.game-status {
  min-height: 24px;
  font-weight: 600;
  color: var(--accent-dark);
}

.oreo {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'><circle cx='16' cy='16' r='12' fill='%233b2f2f'/><circle cx='16' cy='16' r='9' fill='%231c1515'/><circle cx='12' cy='12' r='2' fill='%23f8f3f0'/><circle cx='20' cy='18' r='2' fill='%23f8f3f0'/></svg>") 16 16, pointer;
}

.oreo__restart {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at top, #3b2f2f 0%, #1c1515 100%);
  color: #f8f3f0;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 16px 30px rgba(15, 12, 12, 0.3);
}

.oreo__restart::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px dashed rgba(248, 243, 240, 0.2);
}

.oreo__restart:hover {
  transform: translateY(-1px);
}

.oreo__core {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.oreo__owned {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff7ef;
  border: 1px solid #eadfce;
}

.oreo__owned-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.75rem;
  color: var(--muted);
}

.oreo__owned-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.oreo__badge {
  padding: 6px 10px;
  border-radius: 999px;
  background: #f4ede4;
  border: 1px solid #e1d6c7;
  font-size: 0.85rem;
  color: var(--ink);
}

.oreo__stats {
  display: grid;
  gap: 10px;
}

.oreo__mini-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.oreo__count {
  padding: 16px 18px;
  border-radius: 18px;
  background: #fff2e6;
  border: 2px solid #f3d4b9;
  display: grid;
  gap: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.oreo__count--wide {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  overflow-x: auto;
}

.oreo__count--wide .oreo__count-label {
  flex: 0 0 auto;
}

.oreo__count--wide .oreo__count-value {
  flex: 1 1 auto;
  text-align: right;
  white-space: nowrap;
}

.oreo__count.mini {
  padding: 12px 14px;
}

.oreo__count.mini .oreo__count-value {
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  color: #1f5fff;
  text-shadow: 0 6px 18px rgba(31, 95, 255, 0.2);
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oreo__count-label {
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.75rem;
  color: var(--muted);
}

.oreo__count-value {
  font-size: clamp(2.6rem, 5vw, 3.6rem);
  font-weight: 800;
  color: #1f5fff;
  text-shadow: 0 6px 18px rgba(31, 95, 255, 0.25);
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oreo__count-value.bump {
  animation: oreo-bump 0.16s ease;
}

@keyframes oreo-bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.oreo__button {
  width: 100%;
  padding: 26px;
  font-size: 1.8rem;
  font-weight: 700;
  border-radius: 24px;
  border: none;
  background: radial-gradient(circle at top, #3b2f2f 0%, #1c1515 100%);
  color: #f8f3f0;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(15, 12, 12, 0.25);
  transition: transform 0.1s ease;
}

.oreo__button::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 20px;
  border: 2px dashed rgba(248, 243, 240, 0.15);
}

.oreo__button {
  position: relative;
  overflow: hidden;
}

.oreo__button:active {
  transform: scale(0.98);
}

.oreo__event {
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff3b0;
  color: #6b4c00;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.oreo__boost {
  padding: 10px 14px;
  border-radius: 12px;
  background: #e8f7f4;
  color: #0c524b;
  font-weight: 600;
  text-align: center;
}

.oreo__side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.oreo__controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.oreo__list,
.oreo__upgrades {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.oreo__item {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #d6e3ff;
  background: #f3f7ff;
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.oreo__core {
  position: relative;
}

.oreo__rain {
  position: absolute;
  inset: -20px -10px auto -10px;
  height: 280px;
  pointer-events: none;
  overflow: hidden;
}

.oreo__drop {
  position: absolute;
  top: -40px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #4a3a3a 0%, #1c1515 70%);
  box-shadow: inset 0 0 0 3px #2c2222, 0 8px 18px rgba(0, 0, 0, 0.2);
  animation: oreo-fall linear infinite;
}

@keyframes oreo-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translateY(260px) rotate(220deg);
    opacity: 0;
  }
}

.oreo__item button {
  width: 100%;
}

.oreo__upgrades .oreo__item {
  padding: 10px 12px;
  border-radius: 12px;
}

.oreo__upgrades .btn {
  background: #1f5fff;
  box-shadow: 0 8px 18px rgba(31, 95, 255, 0.25);
}

.oreo__upgrades .btn:hover {
  box-shadow: 0 12px 22px rgba(31, 95, 255, 0.35);
}


.clicker {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: 24px;
  align-items: center;
}

.clicker__stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clicker__pad {
  min-height: 180px;
  border-radius: 18px;
  border: 2px dashed #e1bfa7;
  background: #fff4ea;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  font-weight: 600;
  text-align: center;
  padding: 18px;
}

.clicker__pad.active {
  border-color: var(--mint);
  background: #e7f7f5;
  color: #0c524b;
}

.clicker__controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .game {
    grid-template-columns: 1fr;
  }

  .clicker {
    grid-template-columns: 1fr;
  }

  .oreo {
    grid-template-columns: 1fr;
  }

  .hero__score {
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}
