/* Pixel Peek — single dark look (arcade screen), painted explicitly on both host themes. */
:root {
  color-scheme: dark;
  --night: #181425;
  --ink: #262b44;
  --slate: #3a4466;
  --steel: #5a6988;
  --fog: #8b9bb4;
  --mist: #c0cbdc;
  --cream: #ead4aa;
  --sand: #e4a672;
  --clay: #b86f50;
  --rust: #733e39;
  --gold: #feae34;
  --yellow: #fee761;
  --red: #e43b44;
  --wine: #a22633;
  --cyan: #2ce8f5;
  --green: #63c74d;
  --plum: #68386c;
  --accent: var(--gold);
  --display: 'Silkscreen', 'Courier New', ui-monospace, monospace;
  --body: 'VT323', 'Courier New', ui-monospace, monospace;
  --px: 4px;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--cream);
}

body {
  font-family: var(--body);
  font-size: 22px;
  line-height: 1.15;
  -webkit-font-smoothing: none;
}

#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 40%, #262b44 0%, #181425 70%);
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: relative;
  max-width: 100%;
  max-height: 100%;
}

#stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#fx {
  pointer-events: none;
  image-rendering: auto;
}

#scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0 2px, rgba(24, 20, 37, 0.16) 2px 3px);
  box-shadow: inset 0 0 140px rgba(24, 20, 37, 0.55);
}

.no-scan #scan {
  background: none;
  box-shadow: inset 0 0 120px rgba(24, 20, 37, 0.35);
}

#app.playing,
#app.playing * {
  cursor: none;
}

/* ---------- UI layer ---------- */

#ui {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: none;
  padding-inline: 16px;
}

#ui.open {
  pointer-events: auto;
}

.screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-block: 28px;
  box-sizing: border-box;
  animation: screen-in 0.22s steps(4) both;
}

#scr-hub,
#scr-levels,
#scr-brief,
#scr-pause,
#scr-results,
#scr-settings {
  background: rgba(24, 20, 37, 0.72);
  margin-inline: -16px;
  padding-inline: 16px;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.wrap {
  width: min(100%, 1180px);
  align-self: flex-start;
  display: grid;
  gap: 24px;
}

.narrow-wrap {
  width: min(100%, 940px);
}

/* ---------- Pixel frame helpers ---------- */

.panel {
  background: var(--ink);
  color: var(--cream);
  padding: 24px;
  box-shadow:
    inset 0 4px 0 0 var(--slate),
    inset 0 -4px 0 0 #1f2238,
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night),
    0 12px 0 0 rgba(24, 20, 37, 0.5);
}

/* ---------- Buttons ---------- */

.btn {
  --bg: var(--gold);
  --hi: var(--yellow);
  --lo: var(--clay);
  --fg: var(--night);
  font-family: var(--display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg);
  background: var(--bg);
  border: 0;
  margin: 4px;
  padding: 12px 22px 14px;
  cursor: pointer;
  box-shadow:
    inset 0 4px 0 0 var(--hi),
    inset 0 -4px 0 0 var(--lo),
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night);
  transition: transform 0.08s steps(2);
}

.btn:hover {
  transform: translateY(-3px);
  --bg: var(--hi);
}

.btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 4px 0 0 var(--lo),
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night);
}

.btn:focus-visible,
.card:focus-visible,
.lv:focus-visible,
.swatch:focus-visible {
  outline: 3px dashed var(--cyan);
  outline-offset: 7px;
}

.btn.ghost {
  --bg: var(--slate);
  --hi: var(--steel);
  --lo: var(--ink);
  --fg: var(--cream);
}

.btn.ghost:hover {
  --bg: var(--steel);
  --hi: var(--fog);
}

.btn.danger {
  --bg: var(--red);
  --hi: #f6757a;
  --lo: var(--wine);
  --fg: var(--night);
}

.btn.big {
  font-size: 26px;
  padding: 16px 42px 18px;
}

.btn.small {
  font-size: 14px;
  padding: 9px 14px 11px;
}

/* ---------- Language switch ---------- */

.lang-switch {
  display: inline-flex;
  margin: 4px;
  box-shadow:
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night);
}

.lang-btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--fog);
  background: var(--ink);
  border: 0;
  padding: 9px 12px 11px;
  cursor: pointer;
}

.lang-btn + .lang-btn {
  box-shadow: inset 4px 0 0 0 var(--night);
}

.lang-btn:hover {
  color: var(--cream);
  background: var(--slate);
}

.lang-btn[aria-pressed='true'] {
  color: var(--night);
  background: var(--gold);
}

.lang-btn:focus-visible {
  outline: 3px dashed var(--cyan);
  outline-offset: 4px;
}

/* ---------- Boot screen ---------- */

#scr-title {
  cursor: pointer;
}

.boot {
  display: grid;
  justify-items: center;
  gap: 22px;
  margin-top: 16vh;
  text-align: center;
}

.boot-btn {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cream);
  background: none;
  border: 0;
  padding: 8px 16px;
  cursor: pointer;
  text-shadow: 3px 3px 0 var(--night);
  animation: blink 1.1s steps(1) infinite;
}

.boot-btn:hover {
  color: var(--gold);
}

.boot-btn:focus-visible {
  outline: 3px dashed var(--cyan);
  outline-offset: 6px;
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

/* ---------- Mobile notice ---------- */

#scr-mobile {
  background: rgba(24, 20, 37, 0.6);
  margin-inline: -16px;
  padding-inline: 16px;
}

.mobile-card {
  width: min(100%, 460px);
  display: grid;
  justify-items: center;
  gap: 16px;
  text-align: center;
}

.mobile-logo {
  font-size: clamp(52px, 16vw, 96px);
}

.mobile-card .tagline {
  margin: 0;
}

.mobile-panel {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: 4px;
  box-sizing: border-box;
  width: 100%;
}

.mobile-panel p {
  margin: 0;
}

.mobile-title {
  font-size: clamp(24px, 7vw, 34px);
  color: var(--gold);
}

.mobile-url {
  font-size: 22px;
  color: var(--cyan);
  background: var(--night);
  padding: 6px 12px;
  word-break: break-all;
  user-select: text;
  -webkit-user-select: text;
}

/* ---------- Credit ---------- */

.credit {
  margin: 8px 0 0;
  text-align: center;
  font-size: 20px;
  color: var(--fog);
  text-shadow: 2px 2px 0 var(--night);
}

.credit a {
  color: var(--gold);
  text-decoration: none;
  box-shadow: inset 0 -3px 0 0 var(--wine);
}

.credit a:hover {
  color: var(--yellow);
  box-shadow: inset 0 -3px 0 0 var(--gold);
}

.credit a:focus-visible {
  outline: 3px dashed var(--cyan);
  outline-offset: 4px;
}

/* ---------- Main menu hero ---------- */

.hub-bar {
  justify-content: flex-end;
}

.hub-hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  margin-top: -8px;
}

.hub-logo {
  font-size: clamp(60px, 10vw, 136px);
}

.hub-hero .tagline {
  margin: 0;
}

.section-label {
  margin: 8px 0 -6px;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fog);
  text-align: center;
}

.logo {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(64px, 12vw, 168px);
  line-height: 0.82;
  text-transform: uppercase;
  display: grid;
  justify-items: center;
}

.logo .l1 {
  color: var(--cream);
  text-shadow: 6px 6px 0 var(--rust), 12px 12px 0 var(--night);
}

.logo .l2 {
  color: var(--gold);
  text-shadow: 6px 6px 0 var(--wine), 12px 12px 0 var(--night);
  animation: peek 3.2s steps(1) infinite;
}

@keyframes peek {
  0%,
  88% {
    transform: none;
  }
  90% {
    transform: translateX(10px);
  }
  94% {
    transform: translateX(-4px);
  }
}

.tagline {
  margin: 4px 0 10px;
  font-size: clamp(22px, 2.6vw, 32px);
  color: var(--cream);
  text-shadow: 3px 3px 0 var(--night);
  text-wrap: balance;
}

.hint {
  margin: 0;
  font-size: 20px;
  color: var(--fog);
  text-shadow: 2px 2px 0 var(--night);
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px 24px;
  flex-wrap: wrap;
}

.topbar-sub {
  margin: 0;
  color: var(--fog);
  flex: 1;
  min-width: 180px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.screen-title {
  margin: 0;
  font-family: var(--display);
  font-size: 32px;
  color: var(--accent);
  text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--night);
}

/* ---------- Game cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}

.card {
  --accent: var(--gold);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 18px 18px 16px;
  margin: 4px;
  text-align: left;
  font: inherit;
  color: var(--cream);
  background: var(--ink);
  border: 0;
  cursor: pointer;
  box-shadow:
    inset 0 6px 0 0 var(--accent),
    inset 0 -4px 0 0 #1f2238,
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night),
    0 12px 0 0 rgba(24, 20, 37, 0.5);
  transition: transform 0.1s steps(2);
}

button.card:hover {
  transform: translateY(-6px);
  background: var(--slate);
}

.icon {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  margin-bottom: 4px;
}

.c-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  text-transform: uppercase;
  color: var(--accent);
}

.c-eyebrow {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog);
}

.c-skill {
  color: var(--mist);
  font-size: 22px;
}

.pips {
  display: flex;
  gap: 3px;
  margin-top: 8px;
}

.pips i {
  width: 12px;
  height: 8px;
  background: var(--night);
}

.pips i.on {
  background: var(--accent);
}

.pips i.cur {
  background: var(--steel);
}

.c-foot {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--fog);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.c-stars {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--yellow);
}

.star {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

.rank-card {
  cursor: default;
  background: #1f2238;
}

.rank-card .c-name {
  font-size: 18px;
  min-height: 2.3em;
}

.rank-bar {
  width: 100%;
  height: 8px;
  background: var(--night);
  margin-top: 4px;
}

.rank-bar i {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* ---------- Levels ---------- */

.lv-body {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 32px;
  align-items: start;
}

.lv-info {
  display: grid;
  gap: 10px;
  margin: 4px;
}

.eyebrow {
  margin: 0;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lv-blurb {
  margin: 0;
  font-size: 24px;
}

.tipbox {
  background: var(--night);
  padding: 14px 16px;
  box-shadow: inset 4px 0 0 0 var(--accent);
}

.tipbox p {
  margin: 0;
  color: var(--mist);
}

.tip-label {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog) !important;
  margin-bottom: 6px !important;
}

.lv-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 20px;
}

.lv {
  aspect-ratio: 1;
  max-width: 100%;
  margin: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  color: var(--cream);
  background: var(--slate);
  border: 0;
  cursor: pointer;
  box-shadow:
    inset 0 4px 0 0 var(--steel),
    inset 0 -4px 0 0 var(--ink),
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night);
  transition: transform 0.08s steps(2);
}

.lv:not([disabled]):hover {
  transform: translateY(-4px);
  background: var(--steel);
}

.lv-n {
  font-family: var(--display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
}

.lv-stars,
.res-stars,
.g-stars {
  display: flex;
  gap: 3px;
  color: var(--night);
}

.lv-stars .on,
.g-stars .on,
.res-stars .on {
  color: var(--yellow);
}

.lv-stars .star {
  width: 14px;
  height: 14px;
}

.lv-best {
  font-size: 18px;
  color: var(--mist);
  font-variant-numeric: tabular-nums;
}

.lv[disabled] {
  background: var(--ink);
  color: var(--slate);
  cursor: not-allowed;
  box-shadow:
    0 -4px 0 0 var(--night),
    0 4px 0 0 var(--night),
    -4px 0 0 0 var(--night),
    4px 0 0 0 var(--night);
}

.lock {
  width: 16px;
  height: 18px;
  background:
    linear-gradient(var(--slate), var(--slate)) 0 8px / 16px 10px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 3px 0 / 2px 8px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 11px 0 / 2px 8px no-repeat,
    linear-gradient(var(--slate), var(--slate)) 3px 0 / 10px 2px no-repeat;
}

.lv.next {
  background: var(--accent);
  color: var(--night);
  animation: nudge 1.4s steps(2) infinite;
}

.lv.next .lv-best {
  color: var(--night);
}

.lv.next .lv-stars {
  color: rgba(24, 20, 37, 0.35);
}

@keyframes nudge {
  50% {
    transform: translateY(-3px);
  }
}

/* ---------- Brief / results ---------- */

.card-center {
  width: min(100%, 720px);
  box-sizing: border-box;
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  margin: 4px;
}

.card-center.narrow {
  width: min(100%, 380px);
}

.big-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(34px, 5vw, 52px);
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 4px 4px 0 var(--night);
  text-wrap: balance;
}

.warn {
  margin: 0;
  padding: 6px 14px;
  background: var(--night);
  color: var(--cyan);
}

.brief-cols {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  text-align: left;
}

.col-label {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fog);
}

.obj,
.goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.obj li {
  padding-left: 20px;
  position: relative;
}

.obj li::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 8px;
  width: 8px;
  height: 8px;
  background: var(--accent);
}

.goals li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.goals .g-stars .star {
  width: 14px;
  height: 14px;
}

.goals .g-stars {
  min-width: 52px;
}

#res-goals li {
  color: var(--fog);
}

#res-goals li.met {
  color: var(--cream);
}

.muted {
  margin: 0;
  color: var(--fog);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

.stack {
  display: grid;
  gap: 12px;
  width: 100%;
}

.res-stars .star {
  width: 56px;
  height: 56px;
}

.res-stars span {
  display: block;
}

.res-stars .pop {
  animation: star-pop 0.35s steps(4) both;
}

@keyframes star-pop {
  0% {
    transform: scale(2.2) rotate(-12deg);
  }
  60% {
    transform: scale(0.85);
  }
  100% {
    transform: none;
  }
}

.headline {
  display: grid;
  justify-items: center;
  gap: 2px;
}

#res-big {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(44px, 7vw, 72px);
  color: var(--accent);
  text-shadow: 5px 5px 0 var(--night);
  font-variant-numeric: tabular-nums;
}

#res-big .unit {
  font-family: var(--body);
  font-weight: 400;
  font-size: 0.55em;
  margin-left: 0.2em;
  color: var(--mist);
  text-shadow: 3px 3px 0 var(--night);
}

#res-big .unit.pct {
  font-size: 0.95em;
  margin-left: 0.08em;
  color: inherit;
  text-shadow: 5px 5px 0 var(--night);
}

.headline-label {
  color: var(--mist);
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  font-family: var(--display);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--yellow);
  color: var(--night);
  padding: 4px 10px;
  margin-top: 6px;
}

.badge.alt {
  background: var(--green);
}

#scr-results.failed .big-title {
  color: var(--fog);
}

.stats {
  margin: 0;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 8px;
}

.stats div {
  background: var(--night);
  padding: 8px 12px;
  display: grid;
  gap: 2px;
  text-align: left;
}

.stats dt {
  color: var(--fog);
  font-size: 18px;
}

.stats dd {
  margin: 0;
  font-size: 26px;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}

/* ---------- Settings ---------- */

.settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  align-items: start;
}

.settings .panel {
  display: grid;
  gap: 12px;
  margin: 4px;
}

.settings .col-label:not(:first-child) {
  margin-top: 10px;
}

.row {
  display: grid;
  grid-template-columns: 110px 1fr 36px;
  align-items: center;
  gap: 12px;
}

.row output {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.row.check {
  grid-template-columns: auto 1fr;
  cursor: pointer;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 22px;
  width: 100%;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 8px;
  background: var(--night);
}

input[type='range']::-moz-range-track {
  height: 8px;
  background: var(--night);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 22px;
  margin-top: -7px;
  background: var(--gold);
  border: 0;
  box-shadow: inset 0 -4px 0 var(--clay);
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 22px;
  background: var(--gold);
  border: 0;
  border-radius: 0;
}

input[type='range']:focus-visible {
  outline: 2px dashed var(--cyan);
  outline-offset: 4px;
}

input[type='checkbox'] {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin: 0;
  background: var(--night);
  box-shadow: inset 0 0 0 3px var(--slate);
  cursor: pointer;
}

input[type='checkbox']:checked {
  background: var(--gold);
  box-shadow: inset 0 0 0 3px var(--night), inset 0 0 0 6px var(--gold);
}

input[type='checkbox']:focus-visible {
  outline: 2px dashed var(--cyan);
  outline-offset: 3px;
}

.xh-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 12 / 7;
  box-shadow: 0 0 0 4px var(--night);
  overflow: hidden;
}

.xh-preview canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.swatch {
  width: 34px;
  height: 34px;
  border: 0;
  cursor: pointer;
  background: var(--sw);
  box-shadow: inset 0 0 0 3px var(--night);
}

.swatch.sel {
  box-shadow: inset 0 0 0 3px var(--night), 0 0 0 3px var(--cream);
}

.confirm {
  display: grid;
  gap: 8px;
  justify-items: start;
  background: var(--night);
  padding: 12px;
}

.confirm p {
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lv-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .settings,
  .brief-cols {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lv-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
  }
}

@media (max-width: 480px) {
  .grid {
    grid-template-columns: 1fr;
  }
  body {
    font-size: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .boot-btn,
  .logo .l2,
  .lv.next,
  .res-stars .pop {
    animation: none;
  }
  .btn,
  .card,
  .lv {
    transition: none;
  }
}
