@font-face { font-family: 'VT323'; src: url('vendor/fonts/vt323.woff2') format('woff2'); font-display: block; }
@font-face { font-family: 'PS2P'; src: url('vendor/fonts/pressstart2p.woff2') format('woff2'); font-display: block; }

:root {
  --win-top: #2c3f9e; --win-bot: #0b1242; --win-edge: #d8dcf0; --win-edge2: #6d76a8;
  --ink: #f4f1e6; --dim: #a9b0d4; --gold: #ffd84a; --red: #ff5a4e; --green: #6cf08a; --pink: #ff8fd0;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; color: var(--ink); font-family: 'VT323', monospace; font-size: 22px; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; image-rendering: pixelated; image-rendering: crisp-edges; display: block; cursor: none; }
.hidden { display: none !important; }

/* FF7-style windows */
.win, #objective, #scorebox, #brainpanel, #narrator, #panel, #menu, #loadbox {
  background: linear-gradient(180deg, var(--win-top), var(--win-bot));
  border: 3px solid var(--win-edge); border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--win-edge2), 0 3px 0 rgba(0,0,0,.6);
  text-shadow: 2px 2px 0 #000;
}

#hud { position: fixed; inset: 0; pointer-events: none; }
#objective { position: absolute; left: 14px; top: 14px; max-width: min(430px, 44vw); padding: 8px 12px 10px; }
.obj-kicker { font-family: 'PS2P'; font-size: 10px; color: var(--gold); letter-spacing: 1px; margin-bottom: 4px; }
#obj-title { font-size: 28px; line-height: 1; }
#obj-hint { font-size: 20px; color: var(--dim); margin-top: 4px; line-height: 1.05; }
#scorebox { position: absolute; left: 14px; top: calc(14px + var(--objh, 96px)); padding: 6px 12px; min-width: 200px; }
#scorebox .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 20px; }
#scorebox b { font-family: 'PS2P'; font-size: 12px; font-weight: normal; color: var(--gold); }
.meter { width: 96px; height: 10px; background: #000; border: 2px solid var(--win-edge2); }
.meter i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); background-size: 96px 100%; transition: width .4s; }

#brainpanel { position: absolute; right: 14px; top: 14px; width: 272px; padding: 8px 10px; }
.bp-title { font-family: 'PS2P'; font-size: 10px; color: var(--gold); display: flex; justify-content: space-between; margin-bottom: 6px; }
.live { color: var(--red); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .2; } }
#braincam { width: 252px; height: 252px; image-rendering: pixelated; background: #000; border: 2px solid var(--win-edge2); display: block; }
#bars { margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 86px 1fr 40px; align-items: center; gap: 6px; font-size: 18px; line-height: 18px; }
.bar-row .nm { color: var(--dim); white-space: nowrap; }
.bar-row .track { height: 8px; background: #000; border: 1px solid var(--win-edge2); }
.bar-row .fill { height: 100%; width: 0; }
.bar-row .hz { text-align: right; font-size: 16px; color: var(--ink); }
.bar-row.hot .nm { color: var(--gold); }
#doing { margin-top: 6px; font-family: 'PS2P'; font-size: 10px; color: var(--green); min-height: 12px; }
#thoughts { margin-top: 5px; font-size: 17px; line-height: 17px; color: var(--pink); min-height: 34px; }
#brainstats { margin-top: 4px; font-size: 15px; line-height: 15px; color: var(--dim); }

#remote { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px 12px 10px;
  background: linear-gradient(180deg, #5b5d66, #2a2b31); border: 3px solid #17181c; border-radius: 22px;
  box-shadow: inset 0 2px 0 #8a8d99, 0 4px 0 #000; pointer-events: auto; }
.tool { width: 74px; height: 74px; border-radius: 12px; border: 3px solid #111; background: linear-gradient(180deg, #3b3d45, #1c1d22);
  box-shadow: inset 0 2px 0 #6c6f7c; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; cursor: pointer; position: relative; padding-bottom: 4px; }
.tool canvas { width: 40px; height: 40px; image-rendering: pixelated; position: absolute; top: 7px; left: 50%; transform: translateX(-50%); }
.tool .lbl { font-family: 'PS2P'; font-size: 7px; color: #cfd2e0; text-shadow: 1px 1px 0 #000; }
.tool .key { position: absolute; top: 3px; left: 6px; font-family: 'PS2P'; font-size: 8px; color: #8d90a0; }
.tool.sel { border-color: var(--gold); background: linear-gradient(180deg, #6a5a1c, #2d260b); box-shadow: inset 0 2px 0 #d9b94a, 0 0 12px rgba(255,216,74,.5); }
.tool .cd { position: absolute; inset: 0; border-radius: 9px; background: rgba(0,0,0,.6); transform-origin: bottom; }
.tool.locked { opacity: .35; }

#padhint { position: absolute; left: 50%; bottom: 2px; transform: translateX(-50%); font-family: 'PS2P'; font-size: 8px; color: #cfd2e0; text-shadow: 1px 1px 0 #000; width: max-content; max-width: 96vw; text-align: center; }
body.padmode #remote { bottom: 16px; }
body.padmode .tool .key { display: none; }
#narrator { position: absolute; left: 50%; bottom: 112px; transform: translateX(-50%); width: min(720px, 92vw); padding: 10px 16px 14px; font-size: 26px; line-height: 1.1; min-height: 70px; }
#narrator .more { position: absolute; right: 10px; bottom: 2px; font-size: 16px; color: var(--gold); animation: blink .8s steps(2) infinite; }
#toast { position: absolute; left: 50%; top: 28%; transform: translate(-50%, -50%); font-family: 'PS2P'; font-size: 22px; color: var(--gold);
  text-shadow: 3px 3px 0 #000, -2px -2px 0 #000; text-align: center; opacity: 0; transition: opacity .3s; white-space: pre; }
#toast.show { opacity: 1; }
#bubbles { position: absolute; inset: 0; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; color: #111; border: 3px solid #111; border-radius: 4px; padding: 2px 8px 3px;
  font-size: 20px; line-height: 1; white-space: nowrap; text-shadow: none; box-shadow: 3px 3px 0 rgba(0,0,0,.5); }
.bubble:after { content: ''; position: absolute; left: 50%; bottom: -9px; margin-left: -6px; border: 6px solid transparent; border-top-color: #111; }
.bubble.gary { background: #fffbe0; }
.bubble.fx { background: none; border: none; box-shadow: none; color: var(--gold); font-family: 'PS2P'; font-size: 11px; text-shadow: 2px 2px 0 #000; }
.bubble.fx:after { display: none; }
#reticle { position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 2px solid var(--gold); border-radius: 50%; box-shadow: 0 0 0 2px #000; }
#reticle:after { content: ''; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: var(--gold); }

/* title / loading / menus */
#screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: rgba(0,0,0,.35); }
#screen.clear { background: none; }
#title-logo { text-align: center; line-height: .9; font-family: 'PS2P'; text-shadow: 4px 4px 0 #000; transform: rotate(-4deg); }
#title-logo .l1 { font-size: clamp(26px, 6vw, 60px); color: #ffe36e; -webkit-text-stroke: 2px #6b2b00; letter-spacing: 2px; }
#title-logo .l2 { font-size: clamp(46px, 11vw, 116px); color: #ff6f3d; -webkit-text-stroke: 3px #5a0f00; }
#title-logo .l3 { font-size: clamp(18px, 4vw, 40px); color: #9ff0ff; -webkit-text-stroke: 2px #003b55; letter-spacing: 6px; }
#title-sub { font-size: 26px; color: #fff; text-shadow: 2px 2px 0 #000; background: rgba(0,0,0,.5); padding: 2px 10px; }
#loadbox { width: min(520px, 90vw); padding: 10px 14px 12px; }
#loadlabel { font-family: 'PS2P'; font-size: 11px; color: var(--gold); margin-bottom: 8px; }
#loadbox .bar { height: 16px; background: #000; border: 2px solid var(--win-edge2); }
#loadbar { display: block; height: 100%; width: 0; background: repeating-linear-gradient(90deg, #6cf08a 0 10px, #3cb65a 10px 20px); }
#loaddetail { margin-top: 6px; font-size: 20px; color: var(--dim); min-height: 22px; }
#menu { padding: 10px 26px; display: flex; flex-direction: column; gap: 4px; min-width: 300px; pointer-events: auto; }
#menu button { all: unset; font-family: 'PS2P'; font-size: 14px; padding: 8px 4px 8px 26px; cursor: pointer; position: relative; color: var(--ink); text-shadow: 2px 2px 0 #000; }
#menu button.sel:before, #menu button:hover:before { content: '\25B6'; position: absolute; left: 0; color: var(--gold); }
#panel { width: min(780px, 94vw); max-height: 78vh; overflow-y: auto; padding: 14px 20px; font-size: 22px; line-height: 1.15; pointer-events: auto; }
#panel h2 { font-family: 'PS2P'; font-size: 14px; color: var(--gold); margin: 6px 0 10px; }
#panel p { margin: 0 0 10px; }
#panel .k { color: var(--gold); }
#panel table { border-collapse: collapse; width: 100%; font-size: 20px; }
#panel td { padding: 2px 8px 2px 0; vertical-align: top; }
#panel a { color: #9ff0ff; }
#panel .back { margin-top: 10px; font-family: 'PS2P'; font-size: 12px; color: var(--gold); cursor: pointer; }
#legal { position: absolute; bottom: 10px; font-size: 16px; color: #888; }
#back-link { position: absolute; left: 14px; bottom: 10px; font-family: 'PS2P'; font-size: 10px; color: #cfd2e0; text-decoration: none; text-shadow: 2px 2px 0 #000; pointer-events: auto; }
#back-link:hover { color: var(--gold); }
#screen.play #back-link { display: none; }
#screen.play #legal, #screen.play #title-sub { display: none; }

@media (max-width: 900px) {
  html, body { font-size: 18px; }
  #brainpanel { width: 170px; padding: 6px; }
  #braincam { width: 150px; height: 150px; }
  .bar-row { grid-template-columns: 60px 1fr 30px; font-size: 14px; }
  #thoughts, #brainstats { display: none; }
  .tool { width: 56px; height: 60px; }
  .tool canvas { width: 30px; height: 30px; top: 6px; }
  #narrator { bottom: 90px; font-size: 21px; }
  #objective { max-width: 52vw; }
  #obj-title { font-size: 22px; }
}

/* smaller windows: shrink the whole HUD and the menus rather than let them cover the game */
/* (not the bubbles or the reticle: they are placed in screen pixels) */
@media (max-height: 820px) { #objective, #scorebox, #brainpanel, #remote, #padhint, #narrator, #toast, #screen > * { zoom: 0.85; } }
@media (max-height: 680px) { #objective, #scorebox, #brainpanel, #remote, #padhint, #narrator, #toast, #screen > * { zoom: 0.7; } }
@media (max-height: 520px) { #objective, #scorebox, #brainpanel, #remote, #padhint, #narrator, #toast, #screen > * { zoom: 0.55; } }
