/* Evil Binary Search: arcade-meets-computer-lab theme */

:root {
  color-scheme: dark;
  --bg: #070d22;
  --bg-2: #0c1533;
  --panel: rgba(16, 26, 60, 0.86);
  --panel-solid: #101a3d;
  --line: #26376e;
  --grid: rgba(62, 230, 255, 0.05);
  --text: #eaf0ff;
  --muted: #a3b3dd;
  --cyan: #3ee6ff;
  --cyan-strong: #12c8ec;
  --cyan-ink: #03202a;
  --coral: #ff6b5e;
  --coral-soft: #ff9d8f;
  --gold: #ffd166;
  --mint: #7dffb2;
  --focus: #ffd166;
  --radius: 18px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1100px 600px at 90% -10%, rgba(255, 107, 94, 0.16), transparent 60%),
    radial-gradient(900px 520px at -10% 5%, rgba(62, 230, 255, 0.13), transparent 60%),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: auto, auto, 32px 32px, 32px 32px;
}

/* faint CRT scanlines */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.018) 0 1px, transparent 1px 3px);
  z-index: 40;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--gold);
  color: var(--bg);
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
}

/* ---------- page frame ---------- */

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px clamp(16px, 4vw, 40px) 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-block: 6px 18px;
}

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

.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--coral), #ff3d7f);
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: 0 0 24px rgba(255, 107, 94, 0.45);
}

h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.35rem, 3.6vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.title-evil {
  color: var(--coral);
  text-shadow: 0 0 18px rgba(255, 107, 94, 0.55);
}

.title-accent {
  color: var(--cyan);
  text-shadow: 0 0 18px rgba(62, 230, 255, 0.5);
}

.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.footer {
  margin-top: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.noscript {
  margin: 20px;
  padding: 16px;
  border: 2px solid var(--coral);
  border-radius: 12px;
  background: var(--bg-2);
  color: var(--text);
}

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  font-weight: 800;
  border: 0;
  border-radius: 14px;
  padding: 12px 20px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, filter 0.2s ease;
}

.btn:disabled {
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #7af2ff, var(--cyan-strong));
  color: var(--cyan-ink);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 0 #0a7d96, 0 12px 30px rgba(62, 230, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.07);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #0a7d96, 0 6px 16px rgba(62, 230, 255, 0.3);
}

.btn-primary:disabled {
  opacity: 0.45;
  box-shadow: none;
}

.btn-big {
  font-size: 1.05rem;
  padding: 14px 26px;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--cyan);
  background: rgba(62, 230, 255, 0.08);
}

.btn-ghost[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-ghost:disabled {
  opacity: 0.5;
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.btn-icon {
  width: 1.15em;
  height: 1.15em;
}

/* ---------- mode selector ---------- */

.mode-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 20px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  min-width: 0;
}

.segmented-label {
  padding: 0 8px 0 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.segmented label {
  position: relative;
  display: inline-flex;
}

.segmented input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segmented label span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.segmented label span::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.segmented input:checked + span {
  background: var(--cyan);
  color: var(--cyan-ink);
}

.segmented input:checked + span::before {
  background: currentColor;
}

.segmented input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.segmented input:not(:checked):not(:disabled):hover + span {
  color: var(--text);
}

.segmented:disabled label span {
  opacity: 0.55;
}

.segmented:disabled input {
  cursor: not-allowed;
}

.segmented:disabled input:checked + span {
  opacity: 0.8;
}

.mode-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.mode-note.is-locked::before {
  content: "⏸ ";
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "opp"
    "play"
    "hist";
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
    grid-template-areas:
      "opp play"
      "hist play";
    grid-template-rows: auto 1fr;
    align-items: start;
  }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(16px, 2.6vw, 28px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  min-width: 0;
}

/* ---------- opponent ---------- */

.opponent-card {
  grid-area: opp;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-color: rgba(255, 107, 94, 0.4);
  background:
    radial-gradient(260px 200px at 50% 20%, rgba(255, 107, 94, 0.14), transparent 70%),
    var(--panel);
}

.bot {
  width: min(220px, 72%);
}

.bot svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.bot-float {
  animation: bot-float 4.5s ease-in-out infinite;
}

.bot-tilt {
  transform-box: view-box;
  transform-origin: 100px 170px;
  transition: transform 0.4s ease;
}

.bot-rig {
  transform-box: view-box;
  transform-origin: 100px 170px;
}

.bot.bot-react .bot-rig {
  animation: bot-hop 0.45s ease;
}

.bot[data-mood="gloat"].bot-react .bot-rig {
  animation: bot-laugh 0.16s ease-in-out 6;
}

.bot[data-mood="defeated"] .bot-tilt {
  transform: rotate(-6deg);
}

.face {
  filter: drop-shadow(0 0 4px rgba(255, 107, 94, 0.85));
}

.eyes,
.mouth,
.sweat {
  opacity: 0;
  transition: opacity 0.18s ease;
}

.e-open {
  opacity: 1;
  transform-box: fill-box;
  transform-origin: center;
  animation: bot-blink 5.5s infinite;
}

.bot[data-mood="annoyed"] .e-open {
  animation: none;
  transform: scaleY(0.55);
}

.bot[data-mood="gloat"] .e-open,
.bot[data-mood="defeated"] .e-open {
  opacity: 0;
}

.bot[data-mood="gloat"] .e-squint,
.bot[data-mood="defeated"] .e-x {
  opacity: 1;
}

.bot[data-mood="idle"] .m-smirk,
.bot[data-mood="smug"] .m-grin,
.bot[data-mood="gloat"] .m-grin,
.bot[data-mood="annoyed"] .m-flat,
.bot[data-mood="defeated"] .m-o {
  opacity: 1;
}

.brow {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.25s ease;
}

.bot[data-mood="smug"] .brow-l {
  transform: translateY(-4px) rotate(-8deg);
}

.bot[data-mood="annoyed"] .brow-l {
  transform: translateY(2px) rotate(12deg);
}

.bot[data-mood="annoyed"] .brow-r {
  transform: translateY(2px) rotate(-12deg);
}

.bot[data-mood="gloat"] .brow {
  transform: translateY(-5px);
}

.bot[data-mood="defeated"] .brow-l {
  transform: translateY(-3px) rotate(-30deg);
}

.bot[data-mood="defeated"] .brow-r {
  transform: translateY(-3px) rotate(30deg);
}

.bot[data-mood="defeated"] .sweat {
  opacity: 1;
  animation: bot-sweat 1.6s ease-in infinite;
}

.led {
  animation: bot-led 2.4s steps(1) infinite;
}

.tail {
  transform-box: fill-box;
  transform-origin: 0% 0%;
  animation: bot-wag 3.2s ease-in-out infinite;
}

.speech {
  position: relative;
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 107, 94, 0.5);
  border-radius: 14px;
  background: var(--bg-2);
}

.speech::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  width: 14px;
  height: 14px;
  background: var(--bg-2);
  border-left: 1px solid rgba(255, 107, 94, 0.5);
  border-top: 1px solid rgba(255, 107, 94, 0.5);
  transform: translateX(-50%) rotate(45deg);
}

.speech-name {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--coral-soft);
}

.speech-text {
  margin: 0;
  font-weight: 650;
  font-size: 1.02rem;
}

.speech.speech-pop {
  animation: speech-pop 0.3s ease;
}

@media (max-width: 899px) {
  .opponent-card {
    flex-direction: row;
    align-items: center;
    gap: 14px;
  }

  .bot {
    width: 104px;
    flex: none;
  }

  .speech::before {
    left: -8px;
    top: 50%;
    border-top: 0;
    border-left: 1px solid rgba(255, 107, 94, 0.5);
    border-bottom: 1px solid rgba(255, 107, 94, 0.5);
    transform: translateY(-50%) rotate(45deg);
  }
}

/* ---------- play area ---------- */

.play-card {
  grid-area: play;
  border-color: rgba(62, 230, 255, 0.32);
}

.intro h2 {
  margin: 0 0 6px;
  font-size: clamp(1.25rem, 2.7vw, 1.75rem);
}

.intro p {
  margin: 8px 0 0;
  color: var(--muted);
}

.attempts {
  margin: 20px 0;
}

.attempts-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

#attempts-text {
  color: var(--text);
}

.attempts-low #attempts-text {
  color: var(--coral-soft);
}

.pips {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(4px, 1vw, 8px);
}

.pip {
  height: clamp(28px, 6vw, 42px);
  display: grid;
  place-items: center;
  border: 2px solid var(--cyan);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(62, 230, 255, 0.4), rgba(62, 230, 255, 0.12));
  box-shadow: 0 0 12px rgba(62, 230, 255, 0.25), inset 0 0 10px rgba(62, 230, 255, 0.3);
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: clamp(0.85rem, 2.4vw, 1.1rem);
  color: var(--muted);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.attempts-low .pip:not(.pip-used) {
  border-color: var(--coral);
  background: linear-gradient(180deg, rgba(255, 107, 94, 0.45), rgba(255, 107, 94, 0.14));
  box-shadow: 0 0 12px rgba(255, 107, 94, 0.3);
}

.pip-used {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.02);
  box-shadow: none;
}

.pip-correct {
  border-color: var(--mint);
  color: var(--mint);
}

.pip-next {
  animation: pip-pulse 1.6s ease-in-out infinite;
}

.pip-pop {
  animation: pip-pop 0.45s ease;
}

.guess-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.input-row {
  display: flex;
  gap: 12px;
}

#guess-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: 10px 18px;
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text);
  background: #050a1a;
  border: 2px solid var(--line);
  border-radius: 14px;
  caret-color: var(--cyan);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#guess-input::placeholder {
  color: #5a6a99;
}

#guess-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 4px rgba(62, 230, 255, 0.16), 0 0 28px rgba(62, 230, 255, 0.18);
}

#guess-input[aria-invalid="true"] {
  border-color: var(--coral);
}

#guess-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#guess-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 clamp(16px, 3vw, 28px);
  font-size: 1.1rem;
}

.help {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  margin: 6px 0 0;
  min-height: 1.5em;
  color: var(--coral-soft);
  font-weight: 700;
}

.error:not(:empty)::before {
  content: "✕ ";
}

.guess-form.shake {
  animation: shake 0.35s ease;
}

/* ---------- higher / lower feedback ---------- */

.feedback {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 84px;
  margin-top: 10px;
  padding: 14px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.fb-icon {
  display: none;
  flex: none;
  width: 52px;
  height: 52px;
}

.fb-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.feedback[data-kind="higher"] .fb-arrow,
.feedback[data-kind="lower"] .fb-arrow,
.feedback[data-kind="correct"] .fb-check {
  display: block;
}

.feedback[data-kind="lower"] .fb-arrow svg {
  transform: rotate(180deg);
}

.fb-text {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.fb-word {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 5vw, 2.3rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.fb-detail {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--muted);
}

.feedback[data-kind="higher"],
.feedback[data-kind="lower"] {
  border-style: solid;
  border-color: rgba(255, 107, 94, 0.55);
  background: rgba(255, 107, 94, 0.08);
  color: var(--coral);
}

.feedback[data-kind="correct"] {
  border-style: solid;
  border-color: rgba(125, 255, 178, 0.6);
  background: rgba(125, 255, 178, 0.08);
  color: var(--mint);
}

.feedback.fb-animate .fb-word {
  animation: fb-slam 0.35s ease;
}

.feedback.fb-animate[data-kind="higher"] .fb-arrow {
  animation: fb-up 0.6s ease 2;
}

.feedback.fb-animate[data-kind="lower"] .fb-arrow {
  animation: fb-down 0.6s ease 2;
}

.feedback.fb-animate[data-kind="correct"] .fb-check {
  animation: fb-slam 0.45s ease;
}

/* ---------- learning mode ---------- */

.learning {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.learning-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.learning h3,
.panel-inner h3 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}

.count-badge {
  padding: 3px 12px;
  border: 1px solid rgba(62, 230, 255, 0.45);
  border-radius: 999px;
  background: rgba(62, 230, 255, 0.1);
  font-family: var(--font-mono);
  font-weight: 800;
}

.interval-text {
  margin: 8px 0 4px;
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 800;
}

.numberline {
  position: relative;
  padding: 30px 0 52px;
}

.nl-track {
  position: relative;
  height: 34px;
  overflow: hidden;
  border: 1px solid rgba(255, 107, 94, 0.4);
  border-radius: 8px;
  background: repeating-linear-gradient(135deg, rgba(255, 107, 94, 0.24) 0 6px, rgba(255, 107, 94, 0.05) 6px 12px);
  cursor: crosshair;
  touch-action: manipulation;
}

.nl-alive {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  min-width: 4px;
  border-radius: 6px;
  background: linear-gradient(180deg, #7af2ff, var(--cyan-strong));
  box-shadow: 0 0 18px rgba(62, 230, 255, 0.6);
  transition: left 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), width 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.nl-alive.alive-found {
  background: linear-gradient(180deg, #b6ffd3, var(--mint));
}

.nl-cut {
  position: absolute;
  top: 0;
  bottom: 0;
  background: var(--coral);
  pointer-events: none;
  animation: nl-cut 1.3s ease forwards;
}

.nl-marker {
  position: absolute;
  width: 0;
  pointer-events: none;
}

.nl-label {
  position: absolute;
  left: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 800;
}

.edge-left .nl-label {
  transform: translateX(-6px);
}

.edge-right .nl-label {
  transform: translateX(calc(-100% + 6px));
}

.nl-guess {
  top: 22px;
  height: 50px;
  border-left: 2px solid var(--text);
}

.nl-guess .nl-label {
  bottom: 100%;
  margin-bottom: 2px;
}

.nl-mid {
  top: 26px;
  height: 46px;
  border-left: 2px dashed var(--gold);
}

.nl-mid .nl-label {
  top: 100%;
  margin-top: 2px;
  border-color: var(--gold);
  color: var(--gold);
}

.nl-hover {
  top: 30px;
  height: 34px;
  border-left: 1px solid rgba(255, 255, 255, 0.8);
  z-index: 2;
}

.nl-hover .nl-label {
  bottom: 100%;
  margin-bottom: 10px;
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

.nl-ticks {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 18px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.nl-ticks span {
  position: absolute;
  transform: translateX(-50%);
}

.nl-ticks span:first-child {
  transform: none;
}

.nl-ticks span:last-child {
  transform: translateX(-100%);
}

.nl-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.split-note {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--coral);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.zoom {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(62, 230, 255, 0.4);
  border-radius: 12px;
  background: rgba(62, 230, 255, 0.04);
}

.zoom h4 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.zoom-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.zoom-cells {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(3.2rem, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.zoom-cell {
  position: relative;
  padding: 8px 0;
  font: inherit;
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text);
  border: 1px solid rgba(62, 230, 255, 0.5);
  border-radius: 8px;
  background: rgba(62, 230, 255, 0.12);
  cursor: pointer;
  animation: cell-in 0.35s ease both;
}

.zoom-cell:hover:not(:disabled) {
  background: rgba(62, 230, 255, 0.26);
}

.zoom-cell:disabled {
  cursor: default;
  opacity: 0.7;
}

.zoom-cell.is-mid {
  border: 2px dashed var(--gold);
  color: var(--gold);
}

.zoom-cell.is-mid::after {
  content: "mid";
  display: block;
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.zoom-cell.is-found {
  border-color: var(--mint);
  background: rgba(125, 255, 178, 0.18);
  color: var(--mint);
  opacity: 1;
}

.learning-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 16px;
}

.midpoint-text {
  margin: 0;
  color: var(--gold);
  font-weight: 650;
}

/* ---------- history ---------- */

.history-card {
  grid-area: hist;
}

.history-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-empty {
  margin: 0;
  color: var(--muted);
}

.history-scroll {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
}

.history-table th {
  position: sticky;
  top: 0;
  padding: 8px 10px;
  background: var(--panel-solid);
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.history-table td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}

.col-num {
  color: var(--muted);
}

.col-guess {
  font-size: 1.05rem;
  font-weight: 800;
}

.col-left {
  color: var(--muted);
  font-size: 0.85rem;
}

.reply {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
}

.reply-higher,
.reply-lower {
  color: var(--coral-soft);
  background: rgba(255, 107, 94, 0.13);
}

.reply-correct {
  color: var(--mint);
  background: rgba(125, 255, 178, 0.13);
}

.row-new {
  animation: row-in 0.4s ease;
}

/* ---------- result ---------- */

.result {
  margin-bottom: 20px;
  scroll-margin-top: 16px;
}

.result[data-outcome="won"] {
  border-color: rgba(125, 255, 178, 0.6);
  box-shadow: 0 0 60px rgba(125, 255, 178, 0.12), 0 24px 60px rgba(0, 0, 0, 0.35);
}

.result[data-outcome="lost"] {
  border-color: rgba(255, 107, 94, 0.65);
  box-shadow: 0 0 60px rgba(255, 107, 94, 0.12), 0 24px 60px rgba(0, 0, 0, 0.35);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.result-kicker {
  margin: 0;
  font-family: var(--font-mono);
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.result[data-outcome="won"] .result-kicker {
  color: var(--mint);
}

.result[data-outcome="lost"] .result-kicker {
  color: var(--coral);
}

#result-title {
  margin: 4px 0;
  font-size: clamp(1.6rem, 4.2vw, 2.5rem);
}

.result-summary {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
}

.result-grid {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

@media (min-width: 900px) {
  .result-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  }
}

.panel-inner {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-2);
}

.trick h3 {
  color: var(--coral-soft);
}

.trick p {
  margin: 10px 0 0;
}

.insight {
  color: var(--gold);
  font-weight: 650;
}

.insight:empty {
  display: none;
}

.explain-list {
  margin: 10px 0 0;
  padding-left: 1.2em;
}

.explain-list li + li {
  margin-top: 8px;
}

.chart-scroll {
  margin-top: 16px;
  overflow-x: auto;
}

.chart {
  width: 100%;
  min-width: 320px;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.chart caption {
  margin-bottom: 8px;
  text-align: left;
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--muted);
}

.chart th,
.chart td {
  padding: 4px 6px;
  text-align: left;
}

.chart thead th {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.chart tbody th {
  width: 3.2em;
  color: var(--muted);
  font-weight: 700;
}

.key {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 3px;
  vertical-align: middle;
}

.key-ideal,
.bar-ideal {
  background: var(--cyan);
}

.key-yours,
.bar-yours {
  background: repeating-linear-gradient(135deg, var(--coral) 0 4px, var(--coral-soft) 4px 8px);
}

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

.bar-track {
  flex: 1;
  min-width: 40px;
}

.bar {
  display: block;
  height: 12px;
  border-radius: 6px;
  transform-origin: left center;
  animation: bar-grow 0.6s ease both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

.bar-label {
  flex: none;
  min-width: 4.2em;
  font-weight: 800;
}

.bar-none {
  color: var(--muted);
}

.chart-foot {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.result.result-glitch {
  animation: glitch 0.5s steps(2) 1;
}

/* ---------- confetti ---------- */

.confetti {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 60;
}

.confetti-piece {
  position: absolute;
  top: -16px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

/* ---------- keyframes ---------- */

@keyframes bot-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes bot-hop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-8px) scale(1.03); }
  70% { transform: translateY(1px) scale(0.99); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes bot-laugh {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-3px) rotate(2deg); }
}

@keyframes bot-blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

@keyframes bot-sweat {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(14px); opacity: 0; }
}

@keyframes bot-led {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0.25; }
}

@keyframes bot-wag {
  0%, 100% { transform: rotate(0); }
  50% { transform: rotate(8deg); }
}

@keyframes speech-pop {
  0% { transform: scale(0.97); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pip-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(62, 230, 255, 0.25); }
  50% { box-shadow: 0 0 22px rgba(62, 230, 255, 0.7); }
}

@keyframes pip-pop {
  0% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@keyframes fb-slam {
  0% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes fb-up {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(-10px); }
}

@keyframes fb-down {
  0%, 100% { transform: translateY(0); }
  45% { transform: translateY(10px); }
}

@keyframes nl-cut {
  0% { opacity: 0.95; }
  45% { opacity: 0.85; }
  100% { opacity: 0; transform: scaleY(0.15); }
}

@keyframes cell-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes row-in {
  from { transform: translateY(-6px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes bar-grow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes glitch {
  0% { transform: translate(0); }
  25% { transform: translate(-4px, 1px); }
  50% { transform: translate(4px, -1px); }
  75% { transform: translate(-2px, 0); }
  100% { transform: translate(0); }
}

@keyframes confetti-fall {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--drift, 0), 105vh) rotate(var(--spin, 360deg)); opacity: 0.85; }
}

/* ---------- reduced motion ---------- */

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

  .nl-cut {
    animation: none !important;
    opacity: 0.7;
  }

  .confetti {
    display: none;
  }
}

/* ---------- small screens ---------- */

@media (max-width: 480px) {
  .brand-mark {
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }

  .topbar .btn-ghost {
    padding: 8px 14px;
  }

  .feedback {
    gap: 12px;
    padding: 12px 14px;
  }

  .fb-icon {
    width: 40px;
    height: 40px;
  }

  .history-table th,
  .history-table td {
    padding: 7px 8px;
  }
}
