:root {
  color-scheme: dark;
  --navy: #061a31;
  --navy-2: #0b2d4d;
  --ink: #f8fbff;
  --cyan: #30e5e1;
  --cyan-dark: #087d8d;
  --orange: #ff8b22;
  --orange-dark: #a43f0a;
  --yellow: #ffe45e;
  --lime: #b9f34b;
  --red: #ff5a58;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; min-width: 1100px; min-height: 700px; overflow: hidden; }
body { margin: 0; color: var(--ink); background: #041225; }
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 4px solid white; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.game { width: 100%; height: 100%; padding: 14px; }
.world { position: relative; width: 100%; height: 100%; min-height: 670px; overflow: hidden; border: 3px solid #123b61; border-radius: 30px; background: #071b33 url("./assets/world-01.webp") center/cover no-repeat; box-shadow: inset 0 0 0 2px #020b17, 0 18px 55px #020812; isolation: isolate; }
.world::after { position: absolute; inset: 0; z-index: -1; content: ""; background: linear-gradient(180deg, rgba(2,12,26,.22), rgba(2,12,26,.05) 40%, rgba(2,12,26,.5)); pointer-events: none; }

.hud { position: absolute; z-index: 20; left: 24px; right: 24px; top: 20px; height: 68px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 26px; padding: 0 14px 0 18px; border: 2px solid #1a5078; border-radius: 19px; background: rgba(4,20,39,.92); box-shadow: 0 8px 0 rgba(1,8,18,.72), inset 0 1px #2d6b91; backdrop-filter: blur(7px); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot { width: 16px; height: 16px; border: 4px solid #123146; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); }
.brand small, .mission-chip small, .scoreboard small, .console small, .target-panel small, .readout small { display: block; color: #83b3cc; font-size: 9px; font-weight: 950; letter-spacing: .13em; text-transform: uppercase; }
.brand strong { display: block; margin-top: 1px; font-size: 19px; line-height: 1; letter-spacing: -.02em; }
.mission-chip { min-width: 210px; padding: 8px 24px; border: 1px solid #28678c; border-radius: 999px; background: #092a48; text-align: center; }
.mission-chip small { color: var(--cyan); }
.mission-chip strong { display: block; margin-top: 2px; font-size: 13px; }
.scoreboard { display: flex; justify-content: flex-end; gap: 8px; }
.scoreboard > div { min-width: 74px; padding: 6px 12px; border-left: 1px solid #275777; text-align: center; }
.scoreboard strong { display: block; margin-top: 2px; color: white; font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
.scoreboard span { color: var(--yellow); }

.console { position: absolute; z-index: 5; left: 18%; right: 18%; top: 112px; bottom: 28px; padding: 22px 26px 20px; border: 4px solid #06111f; border-radius: 32px; background: linear-gradient(180deg, rgba(14,58,88,.97), rgba(5,28,51,.98)); box-shadow: 0 0 0 3px #267b95, 0 13px 0 #020a14, 0 28px 40px rgba(0,0,0,.46), inset 0 2px #3ab0bd; }
.console::before { position: absolute; inset: 10px; content: ""; border: 2px solid rgba(74,184,194,.22); border-radius: 22px; pointer-events: none; }
.console-top { position: relative; z-index: 2; height: 44px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.console-top h1 { margin: 2px 0 0; font-size: 24px; line-height: 1.1; letter-spacing: -.035em; }
.console-top small { color: var(--orange); }
.difficulty { width: 180px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }
.difficulty span { color: #a9cadd; font-size: 10px; font-weight: 850; }
.difficulty strong { grid-row: 1 / 3; grid-column: 2; color: var(--lime); font-size: 23px; }
.difficulty i { height: 7px; overflow: hidden; border-radius: 8px; background: #031424; }
.difficulty i b { display: block; width: 18%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--cyan),var(--lime)); transition: width 280ms ease-out; }

.target-panel { position: absolute; z-index: 2; left: 26px; top: 80px; width: 108px; height: 122px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 10px; border: 2px solid #235d7a; border-radius: 18px; background: #051c31; box-shadow: inset 0 0 18px rgba(0,0,0,.45), 0 6px 0 #020d19; text-align: center; }
.target-panel strong { margin: 5px 0 2px; color: var(--yellow); font-family: "SFMono-Regular", Consolas, monospace; font-size: 46px; line-height: 1; text-shadow: 0 0 20px rgba(255,228,94,.4); }
.target-panel span { color: #8db3c6; font-size: 9px; font-weight: 750; line-height: 1.25; }

.lamp-board { position: absolute; z-index: 3; left: 150px; right: 26px; top: 78px; height: 184px; display: grid; grid-template-columns: repeat(var(--bit-count, 5), minmax(72px, 1fr)); gap: 10px; }
.lamp { position: relative; min-width: 0; display: grid; grid-template-rows: 1fr auto auto; place-items: center; gap: 2px; padding: 9px 7px 8px; border: 3px solid #0a1725; border-radius: 19px; color: #a9c5d3; background: #0d3150; box-shadow: 0 0 0 2px #25617b, 0 7px 0 #020d18, inset 0 1px #3a7894; transition: transform 150ms ease-out, filter 150ms ease-out, background 150ms ease-out; }
.lamp:not(:disabled):hover { transform: translateY(-4px); filter: brightness(1.12); }
.lamp:not(:disabled):active { transform: translateY(3px) scale(.98); }
.bulb { position: relative; width: 62px; height: 76px; border: 4px solid #071421; border-radius: 35px 35px 20px 20px; background: #153b58; box-shadow: inset 8px 8px 12px rgba(255,255,255,.06), inset -9px -10px 15px rgba(0,0,0,.34), 0 0 0 2px #45687c; transition: all 150ms ease-out; }
.bulb::before { position: absolute; left: 50%; bottom: -10px; width: 35px; height: 18px; content: ""; transform: translateX(-50%); border: 3px solid #071421; border-radius: 4px 4px 8px 8px; background: repeating-linear-gradient(0deg,#708b99 0 3px,#2f5267 3px 6px); }
.bulb::after { position: absolute; left: 14px; top: 12px; width: 14px; height: 25px; content: ""; transform: rotate(24deg); border-radius: 50%; background: rgba(255,255,255,.13); }
.place { margin-top: 5px; color: white; font-size: 24px; font-weight: 1000; line-height: 1; }
.bit { min-width: 42px; padding: 3px 8px; border-radius: 999px; color: #87aabe; background: #061b2e; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; font-weight: 950; }
.lamp[aria-pressed="true"] { background: #3b480e; box-shadow: 0 0 0 2px #b09014, 0 7px 0 #1a2107, inset 0 1px #e3cd4e; }
.lamp[aria-pressed="true"] .bulb { background: var(--yellow); box-shadow: 0 0 0 6px rgba(255,228,94,.14), 0 0 30px rgba(255,212,43,.84), inset 10px 10px 15px #fff9b6; }
.lamp[aria-pressed="true"] .bit { color: #1f310b; background: var(--lime); }
.lamp.is-covered .place { color: transparent; }
.lamp.is-covered::after { position: absolute; left: 50%; top: 94px; content: "?"; transform: translateX(-50%); color: var(--orange); font-size: 32px; font-weight: 1000; }
.lamp.is-pulse { animation: lamp-pulse 520ms ease-out 2; }
.lamp.is-carry .bulb { animation: carry-pop 480ms ease-out; }

.readout { position: absolute; z-index: 2; left: 26px; right: 26px; top: 280px; height: 70px; display: grid; grid-template-columns: 1fr 1.2fr .5fr; align-items: center; gap: 16px; padding: 10px 18px; border: 2px solid #173f59; border-radius: 15px; background: #031629; box-shadow: inset 0 0 24px rgba(0,0,0,.4); }
.readout > div + div { padding-left: 18px; border-left: 1px solid #25516b; }
.readout output { color: var(--lime); font-family: "SFMono-Regular", Consolas, monospace; font-size: 25px; font-weight: 950; letter-spacing: .16em; }
.readout strong { display: block; margin-top: 3px; overflow: hidden; color: white; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.readout .total strong { color: var(--yellow); font-size: 31px; line-height: .9; }

.action-zone { position: absolute; z-index: 4; left: 26px; right: 26px; bottom: 20px; min-height: 92px; display: flex; align-items: center; justify-content: center; gap: 12px; }
.choices { width: 100%; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; }
.choice, .primary { min-height: 58px; padding: 10px 15px; border: 3px solid #071724; border-radius: 14px; background: #0a4663; box-shadow: 0 5px 0 #031521, 0 0 0 2px #2b86a0; font-weight: 950; transition: transform 140ms ease-out, filter 140ms ease-out; }
.choice:hover, .primary:hover { transform: translateY(-3px); filter: brightness(1.15); }
.choice:active, .primary:active { transform: translateY(3px); box-shadow: 0 2px 0 #031521, 0 0 0 2px #2b86a0; }
.choice strong { display: block; font-size: 19px; }
.choice small { display: block; margin-top: 2px; color: #a9d1df; font-size: 10px; }
.primary { min-width: 220px; min-height: 62px; border-color: #3c2107; color: #201000; background: var(--orange); box-shadow: 0 6px 0 var(--orange-dark), 0 0 0 2px #ffbc4b; font-size: 17px; }
.primary:disabled { opacity: .42; filter: saturate(.3); }
.primary:disabled:hover { transform: none; }
.evidence { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 16px; border: 2px solid #246b76; border-radius: 15px; background: rgba(12,70,76,.68); }
.evidence strong { display: block; color: var(--lime); font-size: 18px; }
.evidence p { margin: 3px 0 0; color: #bfdae5; font-size: 12px; }

.bix { position: absolute; z-index: 8; left: 1.5%; bottom: 24px; width: 17%; max-width: 220px; min-width: 160px; pointer-events: none; }
.bix img { display: block; width: 100%; mix-blend-mode: multiply; filter: drop-shadow(0 14px 8px rgba(0,0,0,.5)); transform-origin: 50% 90%; }
.bix.happy img { animation: robot-happy 650ms cubic-bezier(.2,.9,.3,1.3); }
.bix.sad img { animation: robot-sad 420ms ease-out; }
.speech { position: relative; width: 100%; margin-bottom: -8px; padding: 11px 13px; border: 3px solid #061421; border-radius: 16px 16px 16px 4px; color: #092036; background: white; box-shadow: 0 6px 0 #071321; font-size: 12px; font-weight: 900; line-height: 1.25; }
.core { position: absolute; z-index: 6; right: 1.4%; bottom: 34px; width: 16%; max-width: 205px; min-width: 150px; text-align: center; }
.core img { display: block; width: 100%; mix-blend-mode: multiply; filter: drop-shadow(0 12px 8px rgba(0,0,0,.58)) saturate(.88); transition: filter 180ms ease-out, transform 180ms ease-out; }
.core.is-powered img { filter: drop-shadow(0 0 25px rgba(48,229,225,.85)) saturate(1.18); transform: scale(1.035); }
.core-meter { height: 10px; margin: -4px 14% 7px; overflow: hidden; border: 2px solid #07121e; border-radius: 999px; background: #08192a; }
.core-meter i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--orange),var(--yellow),var(--lime)); transition: width 220ms ease-out; }
.core span { padding: 4px 9px; border-radius: 999px; color: #b5d6e2; background: rgba(3,17,31,.8); font-size: 10px; font-weight: 900; }
.victory { position: absolute; z-index: 30; left: 50%; top: 50%; width: 560px; max-height: 76%; opacity: 0; transform: translate(-50%,-50%) scale(.5); mix-blend-mode: screen; pointer-events: none; }
.victory.show { animation: victory-burst 900ms ease-out both; }
.toast { position: absolute; z-index: 40; left: 50%; top: 102px; max-width: 520px; padding: 11px 20px; opacity: 0; transform: translate(-50%,-12px); border: 3px solid #211204; border-radius: 999px; color: #1b1205; background: var(--yellow); box-shadow: 0 6px 0 #a65a06; pointer-events: none; font-size: 13px; font-weight: 950; transition: opacity 150ms ease-out, transform 150ms ease-out; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.console.miss { animation: miss-shake 330ms ease-out; }
.carry-beam { position: absolute; z-index: 10; left: 34%; right: 14%; top: 132px; display: flex; align-items: center; justify-content: flex-end; gap: 15px; pointer-events: none; }
.carry-beam i { width: 26px; height: 26px; border: 4px solid white; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); animation: beam-step 520ms ease-out both; }
.carry-beam i:nth-child(2) { animation-delay: .16s; }.carry-beam i:nth-child(3) { animation-delay: .32s; }
.carry-beam b { color: var(--yellow); font-size: 24px; }

@keyframes lamp-pulse { 50% { transform: translateY(-8px) scale(1.04); filter: brightness(1.35); } }
@keyframes carry-pop { 40% { transform: scale(.62); } 75% { transform: scale(1.2); } }
@keyframes robot-happy { 35% { transform: translateY(-14px) rotate(4deg); } 65% { transform: translateY(-5px) rotate(-3deg); } }
@keyframes robot-sad { 30% { transform: translateX(-7px) rotate(-2deg); } 65% { transform: translateX(7px) rotate(2deg); } }
@keyframes miss-shake { 25% { transform: translateX(-7px); } 55% { transform: translateX(6px); } 80% { transform: translateX(-3px); } }
@keyframes victory-burst { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.45) rotate(-8deg); } 38% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); } 100% { opacity: 0; transform: translate(-50%,-50%) scale(1.22) rotate(4deg); } }
@keyframes beam-step { from { opacity: 0; transform: translateX(40px) scale(.3); } to { opacity: 1; transform: none; } }

@media (max-height: 790px) {
  .game { padding: 8px; }
  .hud { top: 12px; }
  .console { top: 94px; bottom: 18px; }
  .bix, .core { bottom: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
