/* Layout: one narrow centered column, a pixel "terminal under the night sky". */
@font-face {
  font-family: "Pixelify Sans";
  src: url("fonts/pixelify-sans.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Silkscreen";
  src: url("fonts/silkscreen.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --sky-top: #070b1f;
  --sky-bot: #1b1342;
  --ink: #ecebf7;
  --dim: #9a98c0;
  --gold: #f5d27a;
  --gold-deep: #b8892e;
  --line: #2e2f5c;
  --card: #12143a;
  --field: #0a0c26;
  --bad: #ff7b8a;
  --good: #8ef0b0;
  --pixel: "Pixelify Sans", "Courier New", ui-monospace, monospace;
  --label: "Silkscreen", "Pixelify Sans", "Courier New", ui-monospace, monospace;
  --px: 3px; /* one "pixel" for borders & shadows */
}

* { box-sizing: border-box; }

html { background-color: var(--sky-bot); }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--sky-bot) linear-gradient(180deg, var(--sky-top), var(--sky-bot)) fixed;
  color: var(--ink);
  font-family: var(--pixel);
  font-size: 17px;
  -webkit-font-smoothing: none;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  image-rendering: pixelated;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding-block: 20px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Header */
.top { text-align: center; margin-bottom: 18px; }
.logo {
  font-family: var(--label);
  font-weight: 400;
  font-size: 2.3rem;
  letter-spacing: 0.04em;
  margin: 6px 0 4px;
  text-shadow: var(--px) var(--px) 0 #2a1f63;
}
.logo span { color: var(--gold); text-shadow: var(--px) var(--px) 0 var(--gold-deep); }
.meta { font-family: var(--label); color: var(--dim); font-size: 0.7rem; margin: 0 0 14px; letter-spacing: 0.1em; text-transform: uppercase; }

.slots { list-style: none; display: flex; justify-content: center; gap: 14px; padding: 0; margin: 0; }
.slots li { width: 14px; height: 14px; border: 2px dashed var(--dim); opacity: 0.6; }
.slots li.current { border: 2px solid var(--gold); opacity: 1; animation: blink 1s steps(2) infinite; }
.slots li.filled { border: none; opacity: 1; }
.slots li.missed { border: 2px solid #44465e; background: #14152b; opacity: 1; }
@keyframes blink { 50% { border-color: transparent; } }

/* Screens */
.screen { animation: fadein 0.3s steps(4); text-align: center; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tag { font-family: var(--label); font-size: 1rem; color: var(--gold); margin: 10px 0 18px; }

.rules {
  text-align: left;
  background: var(--card);
  border: var(--px) solid var(--line);
  box-shadow: var(--px) var(--px) 0 #05061a;
  padding: 14px 16px 14px 32px;
  line-height: 1.5;
  margin: 0 0 18px;
  list-style: square;
}
.rules b { color: var(--gold); font-weight: 600; }

.legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 6px; margin: 0 0 22px; font-size: 0.8rem; color: var(--dim); }
.legend .name { color: var(--ink); }
.legend .cls { font-family: var(--label); font-size: 0.55rem; letter-spacing: 0.06em; text-transform: uppercase; }
.legend .pts { color: var(--gold); }
.legend div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.legend .dot { height: 26px; display: grid; place-items: center; }

/* Pixel star: a plus-shaped sprite */
.pstar {
  display: block;
  clip-path: polygon(33% 0, 67% 0, 67% 33%, 100% 33%, 100% 67%, 67% 67%, 67% 100%, 33% 100%, 33% 67%, 0 67%, 0 33%, 33% 33%);
}
.pstar.sq { clip-path: none; }

/* Buttons */
.btn {
  font-family: var(--label);
  font-size: 0.95rem;
  border: var(--px) solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 12px 24px;
  cursor: pointer;
  box-shadow: var(--px) var(--px) 0 #05061a;
}
.btn:active { transform: translate(var(--px), var(--px)); box-shadow: none; }
.btn:focus-visible, input:focus-visible { outline: var(--px) solid var(--good); outline-offset: 2px; }
.btn.primary { background: var(--gold); color: #1a1530; border-color: var(--gold-deep); box-shadow: var(--px) var(--px) 0 var(--gold-deep); }
.btn.primary:hover { background: #ffe09a; }
.btn.ghost { background: transparent; color: var(--dim); box-shadow: none; }
.btn.ghost:hover { color: var(--gold); border-color: var(--gold-deep); }
.btn.small { padding: 8px 14px; font-size: 0.75rem; margin-top: 10px; }
.btn[disabled] { opacity: 0.4; cursor: default; }

/* Play */
.timer-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.timer { flex: 1; height: 14px; border: 2px solid var(--line); background: var(--field); padding: 2px; }
.timer-bar {
  height: 100%;
  width: 100%;
  background: repeating-linear-gradient(90deg, var(--gold) 0 8px, transparent 8px 10px);
  transform-origin: left;
}
.timer-bar.low { background: repeating-linear-gradient(90deg, var(--bad) 0 8px, transparent 8px 10px); }
.clock {
  font-family: var(--label);
  font-size: 1.25rem;
  color: var(--gold);
  min-width: 4.2ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.clock.low { color: var(--bad); animation: blinktext 0.5s steps(2) infinite; }
@keyframes blinktext { 50% { opacity: 0.35; } }

.set-label { font-family: var(--label); color: var(--dim); letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.72rem; margin: 0 0 12px; }

.clues { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.clues li {
  background: var(--card);
  border: var(--px) solid var(--line);
  box-shadow: var(--px) var(--px) 0 #05061a;
  padding: 12px 14px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  animation: fadein 0.3s steps(3) backwards;
}
.clues li:nth-child(2) { animation-delay: 0.15s; }
.clues li:nth-child(3) { animation-delay: 0.3s; }
.clues li .kind {
  font-family: var(--label);
  font-size: 0.6rem;
  color: var(--sky-top);
  background: var(--gold);
  padding: 4px 6px;
  flex: none;
  min-width: 56px;
  text-align: center;
  text-transform: uppercase;
}
.clues li:nth-child(2) .kind { background: #9fd0ff; }
.clues li:nth-child(3) .kind { background: #ff9be0; }

form { display: flex; gap: 8px; }
input[type="text"] {
  flex: 1;
  min-width: 0;
  font-family: var(--pixel);
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--field);
  border: var(--px) solid var(--line);
  padding: 12px 14px;
  outline: none;
  border-radius: 0;
  caret-color: var(--gold);
}
input[type="text"]:focus { border-color: var(--gold); }
.shake { animation: shake 0.3s steps(4); }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(6px); } 75% { transform: translateX(-3px); } }

.feedback { min-height: 1.4em; color: var(--bad); font-size: 0.95rem; margin: 10px 0 0; }
.feedback.ok { color: var(--gold); }
.feedback.wait { color: var(--dim); animation: blinktext 1s steps(2) infinite; }
#btn-appeal { border-style: dashed; color: var(--good); border-color: var(--good); }

/* Reveal */
.reveal-star { height: 120px; display: grid; place-items: center; }
.reveal-star .pstar { animation: bloom 0.6s steps(6) both; }
@keyframes bloom { from { transform: scale(0); } to { transform: scale(1); } }
.reveal-tier { font-family: var(--label); font-size: 1.6rem; margin: 0; }
.reveal-class { font-family: var(--label); font-size: 0.62rem; color: var(--dim); letter-spacing: 0.06em; text-transform: uppercase; margin: 6px 0 0; }
.reveal-class:empty { display: none; }
.reveal-star.nova .pstar { animation: bloom 0.6s steps(6) both, nova 0.8s steps(2) 0.6s infinite; }
@keyframes nova { 50% { filter: brightness(1.8); transform: scale(1.15); } }
.reveal-answer { font-size: 1.3rem; margin: 8px 0 2px; }
.reveal-fix { color: var(--good); font-size: 0.85rem; margin: 2px 0; }
.reveal-fix:empty { display: none; }
.reveal-pct { color: var(--dim); margin: 0; font-size: 0.95rem; }
.reveal-pts { font-family: var(--label); color: var(--gold); font-size: 1.15rem; margin: 10px 0 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; align-items: center; }
.chip { font-family: var(--label); font-size: 0.62rem; padding: 3px 6px; border: 2px solid currentColor; text-transform: uppercase; }
.chip.spec { color: var(--good); }


/* Sky canvases */
.sky {
  width: 100%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 600 / 360;
  border: var(--px) solid var(--line);
  box-shadow: var(--px) var(--px) 0 #05061a;
  background: var(--field);
  margin-bottom: 14px;
  image-rendering: pixelated;
}

.bonus-prompt { font-size: 1.15rem; margin: 0 0 10px; }
.your-answers { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.your-answers li { border: 2px solid var(--line); padding: 4px 10px; font-size: 0.9rem; background: var(--card); }
.your-answers li.miss { color: var(--dim); }
.hints { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.hints:empty { display: none; }
.hints li { color: var(--gold); font-size: 0.95rem; border: 2px dashed var(--gold-deep); padding: 8px 10px; }
.guesses { color: var(--dim); font-size: 0.85rem; margin: 8px 0 0; }

/* Results */
.total { font-family: var(--label); font-size: 2.6rem; margin: 4px 0 0; color: var(--gold); text-shadow: var(--px) var(--px) 0 var(--gold-deep); }
.bonus-result { color: var(--dim); margin: 4px 0 14px; }

.compare {
  background: var(--card);
  border: var(--px) solid var(--line);
  box-shadow: var(--px) var(--px) 0 #05061a;
  padding: 14px;
  margin: 0 0 16px;
  text-align: left;
}
.compare h4 { font-family: var(--label); margin: 0 0 10px; font-weight: 400; color: var(--dim); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }
.compare .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; text-align: center; }
.compare .stat b { display: block; font-family: var(--label); font-size: 1.15rem; color: var(--ink); font-weight: 400; }
.compare .stat.up b { color: var(--good); }
.compare .stat.down b { color: var(--bad); }
.compare .stat span { font-size: 0.75rem; color: var(--dim); }
.compare .hist { display: flex; align-items: flex-end; gap: 2px; height: 56px; border-bottom: 2px solid var(--line); }
.compare .hist i { flex: 1; background: var(--line); min-height: 2px; }
.compare .hist i.you { background: var(--gold); }
.compare .axis { display: flex; justify-content: space-between; font-size: 0.7rem; color: var(--dim); margin-top: 4px; font-variant-numeric: tabular-nums; }
.compare .note { font-size: 0.72rem; color: var(--dim); margin: 8px 0 0; }

.breakdown { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; background: var(--card); border: var(--px) solid var(--line); box-shadow: var(--px) var(--px) 0 #05061a; }
.breakdown li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; border-bottom: 2px solid var(--line); font-size: 0.95rem; }
.breakdown li:last-child { border-bottom: none; }
.breakdown .l { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.breakdown .l .pstar { flex: none; }
.breakdown .r { color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown .link { color: var(--gold); }

.share-preview {
  font-family: var(--pixel);
  background: var(--field);
  border: 2px dashed var(--line);
  padding: 12px;
  font-size: 1rem;
  white-space: pre-wrap;
  margin: 0 0 14px;
}
.next, .streak { font-family: var(--label); color: var(--dim); font-size: 0.7rem; margin: 12px 0 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  font-family: var(--label);
  font-size: 0.8rem;
  background: var(--gold);
  color: #1a1530;
  padding: 10px 16px;
  border: var(--px) solid var(--gold-deep);
  opacity: 0;
  transition: all 0.2s steps(3);
  z-index: 10;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .clues li { font-size: 1.05rem; }
  .clues li .kind { min-width: 46px; }
}

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