:root {
  --ink: #080a08;
  --panel: #10130f;
  --panel-2: #171b16;
  --paper: #eee8d9;
  --muted: #9da196;
  --line: #41483e;
  --lime: #ccff00;
  --amber: #d5a85e;
}

* { box-sizing: border-box; }
html { color-scheme: dark; background: var(--ink); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--paper);
  background:
    radial-gradient(circle at 52% -15%, rgba(204,255,0,.09), transparent 28rem),
    repeating-linear-gradient(0deg, rgba(255,255,255,.016) 0 1px, transparent 1px 4px),
    #080a08;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.game-header {
  min-height: 72px;
  padding: 0 clamp(16px, 4vw, 58px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid #2c322a;
  background: rgba(8,10,8,.94);
}
.brand { color: var(--paper); text-decoration: none; font-size: 1.04rem; font-weight: 1000; letter-spacing: -.035em; }
.brand span { color: var(--lime); }
.back-link { justify-self: end; color: var(--muted); text-decoration: none; font-size: .65rem; font-weight: 900; letter-spacing: .14em; }
.back-link:hover { color: var(--lime); }
.chapter-mark { display: grid; grid-template-columns: auto auto; gap: 10px; align-items: center; }
.chapter-mark span { color: #6f756b; font-size: .55rem; font-weight: 900; letter-spacing: .18em; }
.chapter-mark strong { color: var(--lime); font-size: .62rem; letter-spacing: .14em; }

main { width: min(1540px, calc(100% - 30px)); margin: 0 auto; padding: clamp(30px, 5vw, 72px) 0 90px; }
.title-block { margin: 0 0 25px; display: flex; justify-content: space-between; align-items: end; gap: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--lime); font-size: .64rem; font-weight: 1000; letter-spacing: .21em; }
.title-block h1 { margin: 0; font-size: clamp(3.25rem, 7vw, 7.1rem); line-height: .8; letter-spacing: -.075em; font-weight: 1000; }
.title-block h1 span, .overlay-panel h2 span { color: var(--lime); }
.title-copy { max-width: 370px; margin: 0 0 4px; color: #afb2a8; font-size: clamp(.86rem, 1.5vw, 1.06rem); font-weight: 650; line-height: 1.55; }

.game-frame { border: 1px solid #566051; background: #0b0e0a; box-shadow: 14px 14px 0 rgba(0,0,0,.36); }
.game-topbar { min-height: 62px; padding: 9px 16px; display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 22px; align-items: center; border-bottom: 1px solid var(--line); background: #11150f; }
.mission-copy, .chapter-time { display: grid; gap: 3px; }
.mission-copy span, .chapter-time span { color: #757b71; font-size: .53rem; font-weight: 900; letter-spacing: .18em; }
.mission-copy strong { overflow: hidden; color: var(--paper); font-size: .72rem; letter-spacing: .11em; text-overflow: ellipsis; white-space: nowrap; }
.chapter-time { min-width: 70px; text-align: right; }
.chapter-time strong { color: var(--lime); font-size: .9rem; letter-spacing: .09em; }
.inventory { display: flex; gap: 7px; }
.inventory-slot { min-width: 112px; padding: 7px 10px; display: grid; grid-template-columns: auto 1fr; gap: 7px; align-items: center; border: 1px solid #343a32; color: #62675f; background: #0b0e0a; transition: border-color .25s, color .25s, background .25s; }
.inventory-slot span { font-size: .53rem; font-weight: 900; }
.inventory-slot strong { font-size: .52rem; letter-spacing: .09em; }
.inventory-slot.found { border-color: rgba(204,255,0,.68); color: var(--lime); background: rgba(204,255,0,.06); }

.canvas-wrap { position: relative; overflow: hidden; background: #060806; isolation: isolate; }
canvas { display: block; width: 100%; aspect-ratio: 16 / 9; background: #0a0c0a; touch-action: none; }
.canvas-wrap::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 110px rgba(0,0,0,.44); }
.interaction-prompt { position: absolute; z-index: 6; left: 50%; bottom: 21%; transform: translateX(-50%); padding: 8px 12px; display: flex; gap: 8px; align-items: center; border: 1px solid rgba(204,255,0,.65); color: var(--paper); background: rgba(8,10,8,.92); box-shadow: 0 8px 30px rgba(0,0,0,.36); font-size: .62rem; font-weight: 900; letter-spacing: .12em; pointer-events: none; }
.interaction-prompt[hidden] { display: none; }
kbd { min-width: 25px; padding: 4px 7px; display: inline-grid; place-items: center; border: 1px solid #68705f; color: var(--lime); background: #161a14; box-shadow: 0 2px 0 #30362d; font: inherit; }

.dialogue { position: absolute; z-index: 8; left: 5%; right: 5%; bottom: 4%; min-height: 112px; padding: 18px 170px 18px 20px; border: 1px solid #68705f; background: rgba(11,14,10,.96); box-shadow: 9px 9px 0 rgba(0,0,0,.5); }
.dialogue[hidden] { display: none; }
.dialogue-speaker { margin-bottom: 8px; color: var(--lime); font-size: .59rem; font-weight: 1000; letter-spacing: .18em; }
.dialogue p { margin: 0; max-width: 880px; color: #ddd8cb; font-size: clamp(.82rem, 1.6vw, 1.04rem); line-height: 1.55; }
.dialogue button { position: absolute; right: 17px; bottom: 16px; border: 0; color: #969b91; background: transparent; font-size: .56rem; font-weight: 900; letter-spacing: .12em; cursor: pointer; }
.dialogue button:hover { color: var(--lime); }

.screen-overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 45%, rgba(12,15,11,.55), rgba(3,4,3,.92)); backdrop-filter: blur(2px); }
.screen-overlay[hidden] { display: none; }
.overlay-panel { width: min(560px, 100%); padding: clamp(24px, 4vw, 46px); border: 1px solid #626b5b; background: rgba(13,16,12,.96); box-shadow: 12px 12px 0 rgba(0,0,0,.52); }
.overlay-panel h2 { margin: 0 0 18px; font-size: clamp(2.3rem, 5vw, 4.7rem); line-height: .83; letter-spacing: -.055em; }
.overlay-panel > p:not(.eyebrow) { margin: 0; max-width: 470px; color: #b8bbae; line-height: 1.55; }
.overlay-controls { margin: 24px 0; padding: 14px 0; display: flex; flex-wrap: wrap; gap: 16px; border-top: 1px solid #30362e; border-bottom: 1px solid #30362e; color: #83897e; font-size: .58rem; font-weight: 900; letter-spacing: .09em; }
.primary-action { width: 100%; min-height: 50px; border: 1px solid var(--lime); color: #080a08; background: var(--lime); font-size: .69rem; font-weight: 1000; letter-spacing: .15em; cursor: pointer; }
.primary-action:hover { filter: brightness(1.08); }
.complete-panel { text-align: center; }
.complete-panel > p:not(.eyebrow) { margin-inline: auto; }
.run-summary { margin: 24px 0; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #3b4238; }
.run-summary div { padding: 12px 8px; border-right: 1px solid #3b4238; }
.run-summary div:last-child { border: 0; }
.run-summary span, .run-summary strong { display: block; }
.run-summary span { color: #70766c; font-size: .51rem; font-weight: 900; letter-spacing: .15em; }
.run-summary strong { margin-top: 4px; color: var(--lime); font-size: .86rem; }

.game-footer { min-height: 48px; padding: 9px 14px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid var(--line); background: #0e120d; }
.desktop-controls { display: flex; flex-wrap: wrap; gap: 18px; color: #7e847a; font-size: .55rem; font-weight: 900; letter-spacing: .09em; }
.status-line { display: flex; align-items: center; gap: 8px; color: #7e847a; font-size: .53rem; font-weight: 900; letter-spacing: .12em; white-space: nowrap; }
.status-light { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 12px rgba(204,255,0,.75); animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.mobile-controls { display: none; grid-template-columns: 1fr 1.35fr 1fr; gap: 10px; margin-top: 14px; }
.mobile-controls button { min-height: 52px; border: 1px solid #566051; color: var(--paper); background: #121610; font-size: 1.15rem; font-weight: 1000; cursor: pointer; touch-action: none; }
.mobile-controls .interact-button { border-color: var(--lime); color: #080a08; background: var(--lime); font-size: .62rem; letter-spacing: .12em; }

.prototype-note { margin-top: clamp(55px, 8vw, 105px); padding: clamp(25px, 4vw, 46px) 0 0; display: grid; grid-template-columns: .5fr 1.2fr 1fr; gap: 30px; border-top: 1px solid #333a31; }
.prototype-note > p { margin: 5px 0 0; color: var(--lime); font-size: .57rem; font-weight: 1000; letter-spacing: .2em; }
.prototype-note h2 { margin: 0; font-size: clamp(1.65rem, 3vw, 3.2rem); line-height: 1; letter-spacing: -.045em; }
.build-features { display: grid; align-content: start; gap: 9px; }
.build-features span { padding: 9px 12px; border: 1px solid #383f36; color: #93988e; font-size: .56rem; font-weight: 900; letter-spacing: .12em; }

@media (max-width: 760px) {
  .game-header { min-height: 58px; grid-template-columns: 1fr auto; padding: 0 12px; }
  .chapter-mark { display: none; }
  .back-link { font-size: .54rem; }
  main { width: min(100% - 16px, 1540px); padding-top: 27px; }
  .title-block { align-items: start; flex-direction: column; gap: 16px; }
  .title-block h1 { font-size: clamp(3.2rem, 17vw, 5rem); }
  .title-copy { max-width: 100%; }
  .game-topbar { min-height: 55px; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 7px 9px; }
  .inventory { position: absolute; z-index: 5; top: 63px; right: 7px; }
  .inventory-slot { min-width: 32px; width: 32px; height: 32px; padding: 0; display: grid; place-items: center; }
  .inventory-slot strong { display: none; }
  .inventory-slot span { font-size: .55rem; }
  .mission-copy strong { font-size: .59rem; }
  .chapter-time { min-width: 58px; }
  canvas { aspect-ratio: 16 / 10; }
  .canvas-wrap::after { box-shadow: inset 0 0 55px rgba(0,0,0,.35); }
  .screen-overlay { padding: 9px; }
  .overlay-panel { padding: 21px; max-height: calc(100% - 10px); overflow: auto; }
  .overlay-panel h2 { font-size: clamp(2.25rem, 12vw, 4rem); }
  .overlay-panel > p:not(.eyebrow) { font-size: .82rem; }
  .overlay-controls { margin: 16px 0; gap: 11px; }
  .dialogue { left: 3%; right: 3%; bottom: 3%; min-height: 105px; padding: 14px 14px 40px; }
  .dialogue p { font-size: .78rem; }
  .dialogue button { right: 11px; bottom: 10px; }
  .interaction-prompt { bottom: 27%; }
  .desktop-controls { display: none; }
  .game-footer { min-height: 38px; justify-content: flex-end; }
  .mobile-controls { display: grid; }
  .prototype-note { grid-template-columns: 1fr; gap: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .status-light { animation: none; }
}
