/* [hidden] is only a UA rule, so any author display rule beats it. */
[hidden] { display: none !important; }

:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f8;
  --border: #d9dfec;
  --text: #17203a;
  --text-dim: #5c6785;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --hot: #e8590c;
  --cold: #1c7ed6;
  --good: #2b8a3e;
  --bad: #c92a2a;
  --ruled-out: rgba(23, 32, 58, .42);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 28, 60, .06), 0 8px 24px rgba(18, 28, 60, .07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11131c;
    --surface: #1a1d2a;
    --surface-2: #232736;
    --border: #2f3547;
    --text: #e8ebf5;
    --text-dim: #9aa3bd;
    --accent: #5c7cfa;
    --accent-text: #0d1020;
    --hot: #ff922b;
    --cold: #4dabf7;
    --good: #51cf66;
    --bad: #ff6b6b;
    --ruled-out: rgba(8, 9, 14, .62);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.head { text-align: center; }

h1 {
  margin: 0 0 6px;
  font-size: clamp(1.9rem, 6vw, 2.4rem);
  letter-spacing: -.02em;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: .95rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-title {
  margin: 0 0 10px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.levels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.level {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.level:hover { border-color: var(--accent); }

.level[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.level-name { font-weight: 600; font-size: .95rem; }
.level-meta { font-size: .72rem; opacity: .8; }

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

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  text-align: center;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 4px;
  background: var(--surface-2);
  border-radius: 10px;
}

.stat-label {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

.stat-value.pulse { animation: pulse .4s ease; }

@keyframes pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.guess-form { display: flex; gap: 8px; }

.guess-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.guess-input:focus-visible,
.btn:focus-visible,
.level:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hide the spinners: the game is keyboard/tap driven. */
.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.guess-input { -moz-appearance: textfield; appearance: textfield; }

.btn {
  padding: 12px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}

.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.feedback {
  margin: 0;
  min-height: 1.5em;
  font-size: 1rem;
  font-weight: 500;
}

.feedback.is-hot  { color: var(--hot); }
.feedback.is-cold { color: var(--cold); }
.feedback.is-win  { color: var(--good); }
.feedback.is-lose { color: var(--bad); }

.thermo { display: flex; flex-direction: column; gap: 6px; }

.thermo-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cold), var(--surface-2) 50%, var(--hot));
  overflow: hidden;
}

/* The eliminated ends are drawn as a mask over the gradient rather than as a
   flat fill, so they stay legible against every part of it. */
.thermo-lo, .thermo-hi {
  position: absolute;
  top: 0;
  height: 100%;
  width: 0;
  background: var(--ruled-out);
  transition: width .25s ease;
}

.thermo-lo { left: 0; }
.thermo-hi { right: 0; }

.thermo-marker {
  position: absolute;
  top: -3px;
  width: 4px;
  height: 18px;
  margin-left: -2px;
  border-radius: 2px;
  background: var(--text);
  transition: left .25s ease;
}

.thermo-scale {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: .72rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.history {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 34px;
}

.history li {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}

.history .arrow { font-weight: 700; }
.history .up   { color: var(--hot); }
.history .down { color: var(--cold); }
.history .hit  { color: var(--good); }

.actions { display: flex; }
.actions .btn { flex: 1; }

.foot {
  text-align: center;
  font-size: .8rem;
  color: var(--text-dim);
}

.foot p { margin: 0; }

kbd {
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--surface);
  font: inherit;
  font-size: .78rem;
}

@media (max-width: 420px) {
  .guess-form { flex-direction: column; }
  .level-meta { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
