/* =========================================================================
   MCGuess — Guess the C418 track
   Aesthetic: cave-at-night earthy palette, beveled "block" surfaces,
   pixel display type, friendly rounded body type.
   ========================================================================= */

:root {
  /* palette — dirt, stone, grass, XP gold, parchment */
  --night-0: #0e0d0a;
  --night-1: #161410;
  --night-2: #1e1b14;
  --dirt: #43352629;
  --dirt-panel: #2a2218;
  --dirt-panel-hi: #3a2f21;
  --dirt-edge-light: #5a4730;
  --dirt-edge-dark: #160f08;
  --stone: #6f6a60;
  --stone-light: #8e887b;

  --grass: #6cbb3c;
  --grass-deep: #4c8a2a;
  --grass-glow: #8fe35a;

  --gold: #ffce4f;
  --gold-deep: #d99a23;

  --parchment: #f3ead4;
  --parchment-dim: #c5b896;
  --parchment-faint: #8d8369;

  --danger: #e0653f;

  --radius: 4px;
  --maxw: 720px;

  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-body: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

/* base dark fills any area the gradient doesn't reach (e.g. tall scrolling
   pages on mobile) so the atmosphere never visibly cuts off */
html { background: var(--night-0); }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--parchment);
  background: radial-gradient(120% 90% at 50% -10%, #241f16 0%, var(--night-1) 45%, var(--night-0) 100%);
  background-attachment: fixed; /* keep the gradient covering the viewport while scrolling */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---- atmospheric background layers ---- */
.bg-grid {
  position: fixed;
  inset: -2px;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(120, 95, 60, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 95, 60, 0.045) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: radial-gradient(110% 80% at 50% 0%, #000 35%, transparent 85%);
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 22% 12%, rgba(108, 187, 60, 0.16), transparent 70%),
    radial-gradient(45% 40% at 85% 25%, rgba(255, 206, 79, 0.10), transparent 70%);
}

/* ---- layout shell ---- */
.app {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px) clamp(16px, 4vw, 28px) 48px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* =========================== top bar =========================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: clamp(20px, 4vw, 36px);
}

.brand { display: flex; align-items: center; gap: 14px; }

/* tiny isometric "block" mark made of 4 squares */
.brand__cube {
  display: grid;
  grid-template-columns: repeat(2, 11px);
  grid-template-rows: repeat(2, 11px);
  gap: 2px;
  transform: rotate(45deg);
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.5));
}
.brand__cube span { display: block; image-rendering: pixelated; }
.brand__cube span:nth-child(1) { background: var(--grass-glow); }
.brand__cube span:nth-child(2) { background: var(--grass); }
.brand__cube span:nth-child(3) { background: var(--grass-deep); }
.brand__cube span:nth-child(4) { background: #355f1d; }

.brand__title {
  font-family: var(--font-pixel);
  font-size: clamp(15px, 3.6vw, 22px);
  letter-spacing: 1px;
  margin: 0;
  color: var(--parchment);
  text-shadow: 0 2px 0 #000, 0 0 18px rgba(143, 227, 90, 0.25);
}
.brand__sub {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--parchment-dim);
  letter-spacing: 0.3px;
}

.stats { display: flex; gap: 10px; }

.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 66px;
  padding: 8px 12px;
  background: var(--dirt-panel);
  border-radius: var(--radius);
  box-shadow:
    inset 2px 2px 0 var(--dirt-edge-light),
    inset -2px -2px 0 var(--dirt-edge-dark),
    0 3px 0 rgba(0,0,0,0.4);
}
.chip__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--parchment-faint);
}
.chip__value {
  font-family: var(--font-pixel);
  font-size: 16px;
  margin-top: 5px;
  color: var(--grass-glow);
}
.chip--gold .chip__value { color: var(--gold); }

/* ---- mode toggle (Search / Quiz) ---- */
.topbar__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-toggle {
  display: flex;
  padding: 4px;
  background: var(--dirt-panel);
  border-radius: var(--radius);
  box-shadow:
    inset 2px 2px 0 var(--dirt-edge-dark),
    inset -2px -2px 0 var(--dirt-edge-light);
}
.mode-toggle__btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  color: var(--parchment-dim);
  background: transparent;
  border: none;
  border-radius: 3px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.mode-toggle__btn:hover { color: var(--parchment); }
.mode-toggle__btn.is-active {
  color: #0f2207;
  background: var(--grass);
  box-shadow:
    inset 1px 1px 0 var(--grass-glow),
    inset -1px -1px 0 var(--grass-deep);
}
.mode-toggle__btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* =========================== stage / panels =========================== */
.stage { flex: 1; display: flex; align-items: center; }

.panel {
  width: 100%;
  background:
    linear-gradient(180deg, var(--dirt-panel-hi), var(--dirt-panel));
  border-radius: var(--radius);
  padding: clamp(22px, 5vw, 40px);
  text-align: center;
  /* chunky beveled block edge */
  box-shadow:
    inset 3px 3px 0 var(--dirt-edge-light),
    inset -3px -3px 0 var(--dirt-edge-dark),
    0 14px 0 rgba(0, 0, 0, 0.35),
    0 22px 50px rgba(0, 0, 0, 0.55);
}

.screen { animation: rise 0.45s cubic-bezier(0.2, 0.9, 0.25, 1) both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen__title {
  font-family: var(--font-pixel);
  font-size: clamp(14px, 3.2vw, 19px);
  line-height: 1.5;
  margin: 0 0 22px;
  color: var(--parchment);
  text-shadow: 0 2px 0 #000;
}

.howto {
  margin: 0 0 22px;
  padding: 12px 16px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--parchment-dim);
  background: rgba(0, 0, 0, 0.22);
  border-left: 4px solid var(--grass-deep);
  border-radius: 0 var(--radius) var(--radius) 0;
  text-align: left;
}
.howto strong { color: var(--grass-glow); }

.muted { color: var(--parchment-faint); font-size: 13px; margin: 18px 0 0; }
.hint  { color: var(--parchment-faint); font-size: 13px; margin: 14px 0 0; }

/* =========================== buttons =========================== */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--parchment);
  background: var(--stone);
  border: none;
  border-radius: var(--radius);
  padding: 13px 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  letter-spacing: 0.3px;
  box-shadow:
    inset 2px 2px 0 var(--stone-light),
    inset -2px -2px 0 #3d3933,
    0 5px 0 #2b2823;
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.08s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active {
  transform: translateY(4px);
  box-shadow:
    inset 2px 2px 0 var(--stone-light),
    inset -2px -2px 0 #3d3933,
    0 1px 0 #2b2823;
}
.btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.btn--primary {
  background: var(--grass);
  color: #0f2207;
  box-shadow:
    inset 2px 2px 0 var(--grass-glow),
    inset -2px -2px 0 var(--grass-deep),
    0 5px 0 #2f5a18;
}
.btn--primary:active {
  box-shadow:
    inset 2px 2px 0 var(--grass-glow),
    inset -2px -2px 0 var(--grass-deep),
    0 1px 0 #2f5a18;
}

.btn--xl { font-size: 17px; padding: 17px 30px; }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.4);
  transform: none;
}
.btn:disabled:active { transform: none; }

.btn__icon { font-size: 1.05em; line-height: 1; }

.controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* =========================== player visual =========================== */
.player {
  display: flex;
  justify-content: center;
  margin: 6px 0 26px;
}

.disc {
  position: relative;
  width: 132px;
  height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.disc__face {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #20180f 0 22%, #2c2114 23% 100%);
  box-shadow:
    inset 0 0 0 4px #120c06,
    inset 0 0 0 7px #3a2c1a,
    0 6px 16px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}
.disc__note {
  font-size: 38px;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(255, 206, 79, 0.6);
}
.player[data-playing="true"] .disc__face { animation: spin 4.5s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* equalizer ring of bars */
.disc__bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 1;
}
.disc__bars span {
  width: 5px;
  height: 14px;
  background: var(--grass);
  border-radius: 2px;
  opacity: 0.85;
  transform-origin: center;
}
.player[data-playing="true"] .disc__bars span { animation: eq 0.9s ease-in-out infinite; }
.disc__bars span:nth-child(1) { animation-delay: -0.1s; }
.disc__bars span:nth-child(2) { animation-delay: -0.5s; }
.disc__bars span:nth-child(3) { animation-delay: -0.2s; }
.disc__bars span:nth-child(4) { animation-delay: -0.7s; }
.disc__bars span:nth-child(5) { animation-delay: -0.35s; }
.disc__bars span:nth-child(6) { animation-delay: -0.6s; }
.disc__bars span:nth-child(7) { animation-delay: -0.15s; }
.disc__bars span:nth-child(8) { animation-delay: -0.45s; }
.disc__bars span:nth-child(9) { animation-delay: -0.25s; }
.disc__bars span:nth-child(10){ animation-delay: -0.55s; }
@keyframes eq {
  0%, 100% { transform: scaleY(0.4); opacity: 0.5; }
  50%      { transform: scaleY(2.4); opacity: 1; }
}

/* =========================== volume =========================== */
.volume {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 320px;
  margin: 20px auto 4px;
}
.volume__icon { font-size: 20px; }
.volume__slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 10px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--grass) 0 70%, #1c1710 70% 100%);
  box-shadow: inset 1px 1px 0 #000, inset -1px -1px 0 #4a3a26;
  cursor: pointer;
}
.volume__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 22px;
  border-radius: 3px;
  background: var(--parchment);
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #9b8f72, 0 2px 4px rgba(0,0,0,0.5);
  cursor: pointer;
}
.volume__slider::-moz-range-thumb {
  width: 18px;
  height: 22px;
  border: none;
  border-radius: 3px;
  background: var(--parchment);
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 #9b8f72;
  cursor: pointer;
}

/* =========================== guess + combobox =========================== */
.guess {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-top: 26px;
}

.combo {
  position: relative;
  width: 100%;
  max-width: 440px;
  text-align: left;
}

.guess .btn { min-width: 200px; }

/* ---- quiz mode: multiple choice ---- */
.quiz-prompt {
  margin: 26px 0 16px;
  font-family: var(--font-pixel);
  font-size: clamp(11px, 2.4vw, 13px);
  letter-spacing: 0.5px;
  color: var(--parchment-dim);
}
.quiz-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
}
.quiz-option {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  color: var(--parchment);
  background: #14100a;
  border: none;
  border-radius: var(--radius);
  padding: 16px 14px;
  min-height: 60px;
  cursor: pointer;
  text-align: center;
  box-shadow:
    inset 2px 2px 0 #2e251a,
    inset -2px -2px 0 #000,
    0 4px 0 #0c0905;
  transition: transform 0.08s ease, filter 0.15s ease, box-shadow 0.08s ease;
}
.quiz-option:hover { filter: brightness(1.25); }
.quiz-option:active {
  transform: translateY(3px);
  box-shadow: inset 2px 2px 0 #2e251a, inset -2px -2px 0 #000, 0 1px 0 #0c0905;
}
.quiz-option:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

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

.combo__input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--parchment);
  background: #14100a;
  border: none;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: inset 2px 2px 0 #000, inset -2px -2px 0 #4a3a26;
}
.combo__input::placeholder { color: var(--parchment-faint); }
.combo__input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.combo__list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 5px;
  list-style: none;
  max-height: 256px;
  overflow-y: auto;
  background: var(--dirt-panel);
  border-radius: var(--radius);
  box-shadow:
    inset 2px 2px 0 var(--dirt-edge-light),
    inset -2px -2px 0 var(--dirt-edge-dark),
    0 12px 28px rgba(0,0,0,0.6);
}
.combo__option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border-radius: var(--radius);
  font-size: 15px;
  color: var(--parchment-dim);
  cursor: pointer;
}
.combo__cover {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 3px;
  object-fit: cover;
  background: #14100a;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.4);
  image-rendering: auto;
}
.combo__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.combo__option[aria-selected="true"],
.combo__option:hover {
  background: var(--grass-deep);
  color: #f4ffe9;
}
.combo__option mark {
  background: transparent;
  color: var(--gold);
  font-weight: 700;
}
.combo__empty {
  padding: 11px 13px;
  font-size: 14px;
  color: var(--parchment-faint);
}

/* =========================== result =========================== */
.result__badge {
  width: 76px;
  height: 76px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  border-radius: 50%;
  background: var(--grass-deep);
  color: #f4ffe9;
  box-shadow: inset 0 0 0 4px var(--grass-glow), 0 6px 0 #2f5a18;
  animation: pop 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.result--wrong .result__badge {
  background: #7a2f1c;
  color: #ffe5dc;
  box-shadow: inset 0 0 0 4px var(--danger), 0 6px 0 #4a1c10;
}
@keyframes pop {
  from { transform: scale(0); }
  to   { transform: scale(1); }
}
.result__answer {
  font-size: 17px;
  color: var(--parchment-dim);
  margin: 0 0 26px;
}
.result__answer strong { color: var(--gold); }
.result--wrong .screen__title { color: var(--danger); }

/* =========================== notice (empty state) =========================== */
.notice {
  margin-top: 26px;
  padding: 18px;
  text-align: left;
  background: rgba(0,0,0,0.28);
  border-radius: var(--radius);
  border-left: 4px solid var(--gold-deep);
}
.notice h3 { margin: 0 0 8px; font-size: 16px; color: var(--gold); }
.notice p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--parchment-dim); }
code {
  font-family: "Courier New", monospace;
  font-size: 0.92em;
  background: rgba(0,0,0,0.4);
  padding: 1px 6px;
  border-radius: 3px;
  color: var(--grass-glow);
}

/* =========================== footer =========================== */
.footer {
  margin-top: 28px;
  text-align: center;
}
.footer p {
  font-size: 12px;
  color: var(--parchment-faint);
  line-height: 1.5;
  margin: 0;
  max-width: 520px;
  margin-inline: auto;
}
.footer a {
  color: var(--grass-glow);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid rgba(143, 227, 90, 0.4);
  transition: color 0.15s ease, border-color 0.15s ease;
}
.footer a:hover {
  color: var(--gold);
  border-color: var(--gold);
}
.footer a:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* =========================== responsive =========================== */
@media (max-width: 540px) {
  /* center the whole header stack on phones */
  .topbar {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
  }
  .brand { justify-content: center; }
  .topbar__controls {
    width: 100%;
    justify-content: center;
  }
  .stats { justify-content: center; }

  .guess .btn { width: 100%; max-width: 440px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
