/* =====================================================================
 * Cat Reporter — UI styles
 * Look: chunky glossy royal-blue panels, gold accents, white outlined
 * lettering (matches assets/ui reference sheet). Colours are tokens below.
 * Layout modes set on <body>: layout-wide | layout-compact | layout-portrait
 * ===================================================================== */
:root {
  --blue-1: #2f7cf0; --blue-2: #1a54c8; --blue-edge: #0d2f7a; --blue-hi: #9cc8ff; --navy: #12245a;
  --gold: #ffcf3a; --gold-2: #f2a516; --gold-edge: #a85f00;
  --red: #e5352f; --cream: #fff6df; --ink: #1b2550; --cyan: #5ff3ff; --purple: #7b3fc4; --green: #45c04a;
  --text-scale: 1; --sub-opacity: 0.94; --joy-size: 132px; --joy-opacity: 0.65;
  --font-display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --font-body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d1b3d; color: #fff; font-family: var(--font-body); font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.hidden { display: none !important; }
#app { position: fixed; inset: 0; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* outlined "cartoon" lettering */
.outline, h1, h2, .btn, .pill b, #obj-stage, .scoop .star, kbd {
  text-shadow: 0 2px 0 var(--blue-edge), 2px 0 0 var(--blue-edge), -2px 0 0 var(--blue-edge), 0 -2px 0 var(--blue-edge), 0 4px 0 rgba(0, 0, 0, 0.25);
}
.panel, #objective, .sheet, .tuner-card, .results-card, .gp-card {
  background: linear-gradient(180deg, var(--blue-1), var(--blue-2));
  border: 3px solid var(--blue-hi); border-radius: 22px;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35), 0 6px 0 var(--blue-edge), 0 12px 24px rgba(0, 0, 0, 0.35);
}

/* ---------------- Buttons ---------------- */
.btn { border: 0; border-radius: 18px; padding: 0.7em 1.4em; color: #fff; font-family: var(--font-display); font-size: calc(1.15rem * var(--text-scale)); letter-spacing: 0.02em;
  background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 5px 0 var(--blue-edge); transition: transform 0.08s; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.btn small { font-family: var(--font-body); font-size: 0.65em; opacity: 0.9; text-shadow: none; }
.btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 1px 0 var(--blue-edge); }
.btn:disabled { filter: grayscale(0.7); opacity: 0.6; cursor: default; }
.btn.gold { background: linear-gradient(180deg, #ffe066, var(--gold-2)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 5px 0 var(--gold-edge); text-shadow: 0 2px 0 var(--gold-edge), 2px 0 0 var(--gold-edge), -2px 0 0 var(--gold-edge), 0 -2px 0 var(--gold-edge); }
.btn.green { background: linear-gradient(180deg, #7be05a, #2f9a2a); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 5px 0 #1d5e1a; text-shadow: 0 2px 0 #1d5e1a, 2px 0 0 #1d5e1a, -2px 0 0 #1d5e1a, 0 -2px 0 #1d5e1a; }
.btn.ghost { background: rgba(13, 47, 122, 0.55); box-shadow: inset 0 0 0 2px var(--blue-hi); }
.btn.danger { background: linear-gradient(180deg, #ff6a5a, #c42a22); box-shadow: 0 5px 0 #7a1410; margin-top: 1rem; }
.btn.big { font-size: calc(1.45rem * var(--text-scale)); padding: 0.6em 1.6em; }
kbd { display: inline-grid; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 0.35em; border-radius: 8px; background: #fff; color: var(--blue-2); font-family: var(--font-display); font-size: 0.85em; text-shadow: none; box-shadow: 0 3px 0 #9cb4dd; }
body.touch #prompt kbd, body.touch .gchip kbd, body.touch .title-hint { display: none; }

/* ---------------- Overlays: spy vignette, letterbox, flash ---------------- */
#spy-overlay { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(60, 220, 255, 0.28) 100%), repeating-linear-gradient(0deg, rgba(120, 240, 255, 0.05) 0 2px, transparent 2px 5px); }
#spy-overlay.on { opacity: 1; }
#letterbox i { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 0.5s; z-index: 5; }
#letterbox .top { top: 0; } #letterbox .bottom { bottom: 0; }
#letterbox.on i { height: 9vh; }
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 40; }
#flash.on { animation: flash 0.35s ease-out; }
@keyframes flash { 0% { opacity: 0.85; } 100% { opacity: 0; } }
#fade { position: absolute; inset: 0; background: #0d1b3d; opacity: 0; pointer-events: none; transition: opacity 0.35s; z-index: 39; }
#fade.on { opacity: 1; }
#fps { position: absolute; left: 50%; bottom: calc(4px + var(--safe-b)); transform: translateX(-50%); font-size: 12px; background: rgba(0, 0, 0, 0.5); padding: 2px 8px; border-radius: 8px; z-index: 50; }

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; font-size: calc(16px * var(--text-scale)); }
#hud button, #hud #minimap { pointer-events: auto; }
#hud-player { position: absolute; top: calc(12px + var(--safe-t)); left: calc(12px + var(--safe-l)); display: flex; align-items: center; gap: 8px; }
.portrait-ring { width: 74px; height: 74px; border-radius: 50%; padding: 4px; background: radial-gradient(circle at 30% 30%, #ff7a6a, var(--red)); box-shadow: 0 4px 0 #7a1410, 0 6px 14px rgba(0, 0, 0, 0.35); }
.portrait-ring img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 3px solid #fff; background: #bfe0ff; }
#hearts { display: flex; gap: 3px; }
.heart { width: 26px; height: 24px; display: inline-block; background: #3b2a5a; clip-path: path('M13 23 L2 11 C-2 6 2 0 7 1 C10 1.5 12 4 13 5 C14 4 16 1.5 19 1 C24 0 28 6 24 11 Z'); }
.heart.full { background: linear-gradient(180deg, #ff6a7a, #e5253f); }
.scoop { display: flex; align-items: center; margin-top: 4px; }
.scoop .star { width: 30px; height: 30px; display: grid; place-items: center; font-family: var(--font-display); font-size: 15px; z-index: 1;
  background: var(--gold); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.scoop .bar { width: 110px; height: 14px; margin-left: -6px; border-radius: 10px; background: var(--navy); border: 2px solid #fff; overflow: hidden; }
.scoop .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4fd6ff, var(--blue-1)); transition: width 0.6s; }
#hud-counters { position: absolute; top: calc(14px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; }
.pill { display: flex; align-items: center; gap: 4px; padding: 3px 14px 3px 4px; border-radius: 30px; background: linear-gradient(180deg, #1e4fae, var(--navy)); border: 2px solid var(--blue-hi); box-shadow: 0 4px 0 #081a47; }
.pill img { width: 34px; height: 34px; }
.pill b { font-family: var(--font-display); font-size: 1.25em; min-width: 2.2em; text-align: center; }
.pill.bump { animation: bump 0.45s; }
@keyframes bump { 40% { transform: scale(1.25); } }
#hud-buttons { position: absolute; top: calc(10px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; gap: 8px; }
.icon-btn { width: 54px; height: 54px; padding: 0; border: 0; background: none; border-radius: 14px; filter: drop-shadow(0 4px 0 rgba(8, 26, 71, 0.8)); cursor: pointer; touch-action: manipulation; }
.icon-btn img { pointer-events: none; }
.icon-btn img { width: 100%; height: 100%; }
.icon-btn:active { transform: translateY(3px); }
#objective { position: absolute; top: calc(100px + var(--safe-t)); left: calc(12px + var(--safe-l)); width: min(330px, 40vw); padding: 10px 14px 12px; transition: transform 0.3s, opacity 0.3s; }
#objective.flash { animation: objpop 0.6s; }
@keyframes objpop { 30% { transform: scale(1.06); box-shadow: 0 0 0 6px rgba(255, 207, 58, 0.7), 0 6px 0 var(--blue-edge); } }
#objective.collapsed #obj-side { display: none; }
.obj-head { display: flex; align-items: center; gap: 6px; font-size: 0.78em; opacity: 0.95; }
#obj-stage { font-family: var(--font-display); color: var(--gold); letter-spacing: 0.02em; }
#obj-text { margin-top: 4px; padding: 7px 10px; border-radius: 12px; background: var(--cream); color: var(--ink); font-weight: 800; font-size: 1em; line-height: 1.3; }
#obj-side .side { margin-top: 6px; font-size: 0.85em; display: flex; gap: 6px; align-items: center; }
#obj-side .side .box { width: 18px; height: 18px; border-radius: 5px; background: #fff; color: var(--green); display: grid; place-items: center; font-size: 13px; flex: none; }
#obj-side .side.done { opacity: 0.7; text-decoration: line-through; }
#minimap { position: absolute; top: calc(76px + var(--safe-t)); right: calc(14px + var(--safe-r)); width: 168px; height: 168px; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 4px 0 var(--blue-edge), 0 8px 18px rgba(0, 0, 0, 0.35); background: #1a2f55; cursor: pointer; transition: width 0.25s, height 0.25s; }
#minimap.big { width: 260px; height: 260px; }
#timer { position: absolute; top: calc(70px + var(--safe-t)); left: 50%; transform: translateX(-50%); padding: 6px 18px; border-radius: 20px; background: var(--red); box-shadow: 0 4px 0 #7a1410; font-family: var(--font-display); font-size: 1.2em; display: flex; gap: 10px; align-items: center; }
#timer.urgent { animation: pulse 0.8s infinite; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.08); } }
#prompt { position: absolute; left: 50%; bottom: calc(120px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 18px 8px 10px; border-radius: 30px; background: rgba(13, 36, 90, 0.88); border: 2px solid var(--gold); font-weight: 800; font-size: 1.05em; white-space: nowrap; }
#gadget-bar { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(16px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.gchip { display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; border-radius: 30px; background: rgba(13, 36, 90, 0.82); border: 2px solid var(--blue-hi); font-size: 0.9em; }
.gchip img { width: 34px; height: 34px; border-radius: 8px; }
.gchip.active { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(95, 243, 255, 0.4); }
#relay-panel { position: absolute; right: calc(16px + var(--safe-r)); top: calc(260px + var(--safe-t)); padding: 10px 14px; border-radius: 16px; background: rgba(13, 36, 90, 0.9); border: 2px solid var(--cyan); display: flex; flex-wrap: wrap; gap: 8px; max-width: 240px; }
#relay-panel b { width: 100%; font-family: var(--font-display); color: var(--cyan); }
#relay-panel .lever { display: flex; flex-direction: column; align-items: center; padding: 4px 8px; border-radius: 10px; background: var(--navy); font-family: var(--font-display); }
#relay-panel .lever i { font-style: normal; font-size: 0.75em; color: var(--gold); }
#relay-panel small { width: 100%; font-size: 0.75em; opacity: 0.85; }
#marker { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; margin: -36px 0 0 -18px; width: 36px; }
#marker .arrow { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: #7a3a00; font-size: 18px; box-shadow: 0 3px 0 var(--gold-edge); animation: bob 1s infinite; }
#marker.edge .arrow { animation: none; }
#marker .dist { margin-top: 3px; font-size: 12px; font-weight: 900; background: rgba(13, 36, 90, 0.8); padding: 1px 6px; border-radius: 8px; white-space: nowrap; }
@keyframes bob { 50% { transform: translateY(-5px); } }
#float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.float { position: absolute; left: 0; top: 0; font-family: var(--font-display); font-size: 1.15em; white-space: nowrap; color: #fff; text-shadow: 0 2px 0 var(--blue-edge), 2px 0 0 var(--blue-edge), -2px 0 0 var(--blue-edge), 0 -2px 0 var(--blue-edge); }
.float.gold { color: var(--gold); } .float.cyan { color: var(--cyan); } .float.red { color: #ff8a9a; }
.float.pip { color: #fff; background: #8f93d6; padding: 3px 10px; border-radius: 12px; text-shadow: none; border: 2px solid #fff; }
.float.robot { color: #9ff3ff; background: #0d1b3d; padding: 3px 10px; border-radius: 10px; text-shadow: none; font-family: monospace; font-weight: 900; }
#toasts { position: absolute; top: calc(120px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(520px, 90vw); }
.toast { padding: 8px 16px; border-radius: 14px; background: rgba(13, 36, 90, 0.92); border-left: 6px solid var(--blue-hi); font-weight: 800; font-size: 0.95em; animation: toastIn 0.3s; transition: opacity 0.4s, transform 0.4s; text-align: center; }
.toast.ok { border-color: var(--green); } .toast.warn { border-color: var(--red); } .toast.hint { border-color: var(--gold); } .toast.evidence { border-color: var(--cyan); }
.toast.out { opacity: 0; transform: translateY(-8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } }

/* ---------------- Dialogue (bottom-centre subtitle panel) ---------------- */
#dialogue { position: absolute; z-index: 20; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); width: min(820px, 94vw); display: flex; align-items: flex-end; gap: 0; font-size: calc(17px * var(--text-scale)); --speaker: var(--blue-1); }
.dlg-portrait { flex: none; width: 126px; height: 126px; margin-right: -24px; z-index: 1; border-radius: 50%; border: 5px solid #fff; background: radial-gradient(circle at 35% 30%, #fff, var(--speaker)); overflow: hidden; box-shadow: 0 5px 0 rgba(8, 26, 71, 0.7); display: grid; place-items: center; }
.dlg-portrait img { width: 100%; height: 100%; object-fit: cover; }
#dlg-emoji { font-size: 64px; }
.dlg-body { position: relative; flex: 1; min-height: 120px; padding: 14px 22px 18px 42px; border-radius: 24px; background: rgba(255, 252, 240, var(--sub-opacity)); color: var(--ink); border: 4px solid var(--speaker); box-shadow: 0 6px 0 rgba(8, 26, 71, 0.6), 0 14px 26px rgba(0, 0, 0, 0.3); }
#dlg-name { position: absolute; top: -18px; left: 34px; padding: 3px 16px; border-radius: 12px; background: var(--speaker); color: #fff; font-family: var(--font-display); font-size: 1.05em; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); }
#dlg-text { font-weight: 800; line-height: 1.42; min-height: 2.9em; max-width: 64ch; }
#dialogue.narration .dlg-portrait { display: none; }
#dialogue.narration #dlg-text { font-style: italic; }
.dlg-next { position: absolute; right: 16px; bottom: 6px; color: var(--speaker); animation: bob 0.8s infinite; }
#dlg-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
#dlg-choices:not(:empty) ~ .dlg-next { display: none; }
.choice { text-align: left; display: flex; gap: 10px; align-items: center; padding: 9px 14px; border-radius: 14px; border: 0; background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); color: #fff; font-weight: 800; font-size: 0.95em; box-shadow: 0 4px 0 var(--blue-edge); }
.choice:hover, .choice:focus-visible { background: linear-gradient(180deg, #ffe066, var(--gold-2)); color: var(--ink); }
#dlg-skip { position: absolute; right: 0; top: -40px; border: 0; padding: 5px 12px; border-radius: 12px; background: rgba(13, 36, 90, 0.85); color: #fff; font-weight: 800; font-size: 0.8em; }

#polaroid { position: absolute; z-index: 25; right: calc(24px + var(--safe-r)); top: 22%; width: min(300px, 46vw); padding: 12px 12px 6px; background: #fff; color: var(--ink); border-radius: 6px; transform: rotate(4deg); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45); animation: polaroid 0.5s cubic-bezier(.2, 1.4, .4, 1); transition: opacity 0.4s, transform 0.4s; }
#polaroid img { width: 100%; display: block; aspect-ratio: 16 / 10; object-fit: cover; background: #ddd; }
#polaroid p { margin: 8px 0 4px; font-family: var(--font-display); text-align: center; font-size: 1.1em; }
#polaroid.out { opacity: 0; transform: rotate(10deg) translateY(-30px); }
@keyframes polaroid { from { transform: rotate(-12deg) scale(0.4); opacity: 0; } }

#gadget-popup { position: absolute; inset: 0; z-index: 45; display: grid; place-items: center; background: rgba(8, 20, 50, 0.55); }
.gp-card { width: min(380px, 88vw); padding: 22px; text-align: center; animation: polaroid 0.45s cubic-bezier(.2, 1.4, .4, 1); }
.gp-card small { font-family: var(--font-display); color: var(--gold); font-size: 1.2em; }
.gp-card img { width: 110px; height: 110px; display: block; margin: 8px auto; border-radius: 20px; box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25); }
.gp-card h2 { margin: 6px 0; font-family: var(--font-display); font-size: 2em; }
.gp-card p { line-height: 1.4; }
#gp-key { display: block; margin: 6px 0 14px; color: var(--cyan); }

/* ---------------- Touch controls ---------------- */
/* Below the HUD (z 10): the HUD only catches clicks on its buttons, everything else falls through to the touch zones */
#touch { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
#look-zone { position: absolute; top: 0; right: 0; width: 60%; height: 100%; pointer-events: auto; }
#joy-zone { position: absolute; left: 0; bottom: 0; width: 42%; height: 55%; pointer-events: auto; }
#joy-base { position: absolute; left: calc(70px + var(--safe-l)); top: 62%; width: var(--joy-size); height: var(--joy-size); margin: calc(var(--joy-size) / -2) 0 0 calc(var(--joy-size) / -2); border-radius: 50%; background: rgba(13, 36, 90, 0.45); border: 3px solid rgba(255, 255, 255, 0.7); opacity: var(--joy-opacity); display: grid; place-items: center; }
#joy-base.active { opacity: 1; }
#joy-knob { width: 46%; height: 46%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, var(--blue-hi)); box-shadow: 0 4px 0 var(--blue-edge); }
.joy-hint { position: absolute; left: calc(28px + var(--safe-l)); bottom: calc(16px + var(--safe-b)); font-size: 12px; opacity: 0.7; }
#touch-buttons { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); width: 250px; height: 250px; pointer-events: none; }
.tbtn { position: absolute; pointer-events: auto; border: 0; border-radius: 50%; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 13px; background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 5px 0 var(--blue-edge); }
.tbtn.down { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 1px 0 var(--blue-edge); }
.tbtn.big { right: 0; bottom: 0; width: 96px; height: 96px; background: linear-gradient(180deg, #ffe066, var(--gold-2)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 5px 0 var(--gold-edge); color: #7a3a00; }
.tbtn.big b { font-size: 34px; line-height: 0.9; }
.tbtn.act { right: 112px; bottom: 6px; width: 84px; height: 84px; background: linear-gradient(180deg, #b47bff, var(--purple)); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 5px 0 #3b1a7a; }
.tbtn.act img { width: 44px; height: 44px; border-radius: 50%; }
.tbtn.img { right: 4px; bottom: 112px; width: 82px; height: 82px; padding: 0; background: none; box-shadow: none; }
.tbtn.img img { width: 100%; height: 100%; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)); }
.tbtn.img.active img { filter: drop-shadow(0 0 10px var(--cyan)); }
#tb-gadget { right: 96px; bottom: 112px; width: 70px; height: 70px; }
#tb-gadget img { width: 36px; height: 36px; border-radius: 8px; }
.tbtn.small { right: 200px; bottom: 0; width: 58px; height: 58px; font-size: 12px; background: rgba(13, 36, 90, 0.75); }
.tbtn.small.down { background: var(--cyan); color: var(--ink); }
body.touch #gadget-bar { display: none; }
body.touch #prompt { bottom: calc(220px + var(--safe-b)); }

/* ---------------- Screens ---------------- */
.screen { position: absolute; inset: 0; z-index: 30; display: none; }
.screen.show { display: flex; }
#screen-loading, #screen-error { align-items: center; justify-content: center; background: radial-gradient(circle at 50% 40%, var(--blue-1), #0d1b3d); }
.load-card { text-align: center; width: min(460px, 88vw); }
.load-card h1 { font-family: var(--font-display); font-size: 3rem; margin: 10px 0 18px; color: var(--gold); }
.load-card p { line-height: 1.5; }
.load-card code { background: rgba(0, 0, 0, 0.35); padding: 2px 6px; border-radius: 6px; font-size: 0.95em; user-select: text; }
.paw-spin { font-size: 54px; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-bar { height: 22px; border-radius: 14px; background: var(--navy); border: 3px solid #fff; overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #ff9a3c); transition: width 0.2s; }

/* Title: full-screen splash art, logo in the middle, buttons along the bottom.
   Art files: assets/ui/art/title_splash.jpg (full-bleed, keep the subject centred) and title_logo.png (transparent). */
#screen-title { flex-direction: column; align-items: center; justify-content: flex-end; overflow: hidden; background: #12245a; }
.title-splash { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; animation: splashIn 1.6s ease-out both; }
@keyframes splashIn { from { transform: scale(1.08); filter: brightness(0.6); } }
.title-shade { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, rgba(10, 20, 60, 0) 40%, rgba(10, 20, 60, 0.35) 100%),
              linear-gradient(to bottom, rgba(10, 20, 60, 0.15) 0%, rgba(10, 20, 60, 0) 30%, rgba(10, 20, 60, 0) 58%, rgba(8, 18, 52, 0.82) 100%); }
.title-logo { position: absolute; left: 50%; top: 42%; width: min(760px, 70vw); max-height: 46vh; object-fit: contain; transform: translate(-50%, -50%);
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.4)); animation: logoIn 0.9s 0.2s cubic-bezier(.2, 1.4, .4, 1) both, logoFloat 4.5s 1.2s ease-in-out infinite; }
@keyframes logoIn { from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } }
@keyframes logoFloat { 50% { transform: translate(-50%, calc(-50% - 10px)); } }
.title-bottom { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 0 16px calc(18px + var(--safe-b)); animation: slideUp 0.7s 0.5s ease-out both; }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } }
@keyframes blink { 50% { opacity: 0.55; } }
@keyframes titleIn { from { transform: rotate(-8deg) scale(0.8); opacity: 0; } }
.title-menu { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 14px; }
.title-menu .btn { min-width: 170px; }
.title-menu .btn.ghost { min-width: 120px; }
.title-hint { margin: 0; font-size: 0.8rem; opacity: 0.85; text-align: center; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7); }

#screen-chapters { flex-direction: column; background: linear-gradient(180deg, var(--blue-2), #0d1b3d); padding: calc(14px + var(--safe-t)) 16px calc(14px + var(--safe-b)); }
.screen-head { display: flex; align-items: center; gap: 16px; }
.screen-head h2 { font-family: var(--font-display); font-size: 2.2rem; margin: 0; }
#chapter-list { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 16px 4px; overflow-y: auto; align-content: start; }
.chapter { position: relative; border: 0; padding: 0 0 12px; border-radius: 20px; overflow: hidden; color: #fff; background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); box-shadow: 0 6px 0 var(--blue-edge); text-align: left; display: flex; flex-direction: column; }
.chapter img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.chapter .ch-num { position: absolute; left: 10px; top: 10px; width: 42px; height: 42px; border-radius: 50%; background: var(--gold); color: #7a3a00; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.4rem; box-shadow: 0 3px 0 var(--gold-edge); }
.chapter b { font-family: var(--font-display); font-size: 1.15rem; padding: 8px 12px 0; }
.chapter small { padding: 2px 12px; opacity: 0.9; }
.chapter .ch-meta { padding: 4px 12px 0; font-size: 0.85rem; color: var(--gold); }
.chapter.locked img { filter: grayscale(1) brightness(0.5); }

/* Intro card styled as a TV news lower-third */
#screen-intro { flex-direction: column; align-items: center; justify-content: center; gap: 2vh; background: rgba(8, 20, 50, 0.55); padding: 16px; }
.intro-feed { position: relative; width: min(620px, 86vw); border: 6px solid #fff; border-radius: 14px; overflow: hidden; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); transform: rotate(1deg); }
.intro-feed img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.live { position: absolute; left: 10px; top: 10px; background: var(--red); padding: 3px 10px; border-radius: 8px; font-family: var(--font-display); animation: blink 1.6s infinite; }
.chyron { display: flex; width: min(760px, 94vw); border-radius: 12px; overflow: hidden; box-shadow: 0 8px 0 rgba(8, 26, 71, 0.8); animation: slideIn 0.6s cubic-bezier(.2, 1.2, .4, 1); }
@keyframes slideIn { from { transform: translateX(-60px); opacity: 0; } }
.breaking { flex: none; display: grid; place-items: center; padding: 0 18px; background: var(--red); font-family: var(--font-display); font-size: 1.4rem; writing-mode: horizontal-tb; }
.chyron-body { flex: 1; padding: 10px 18px; background: #fff; color: var(--ink); }
.chyron-body small { font-family: var(--font-display); color: var(--blue-2); font-size: 1rem; }
.chyron-body h2 { margin: 2px 0; font-family: var(--font-display); font-size: calc(2rem * var(--text-scale)); color: var(--ink); text-shadow: none; line-height: 1.05; }
.chyron-body p { margin: 0; font-weight: 800; color: #5a6380; }
.intro-q { width: min(700px, 92vw); text-align: center; font-size: calc(1.1rem * var(--text-scale)); font-style: italic; margin: 0; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }

#screen-results { align-items: center; justify-content: center; background: rgba(8, 20, 50, 0.75); padding: 16px; overflow-y: auto; }
.results-card { width: min(720px, 96vw); padding: 20px 24px; text-align: center; }
.results-card h2 { font-family: var(--font-display); font-size: 2.3rem; margin: 0; color: var(--gold); }
.results-card h3 { margin: 2px 0 6px; }
.stars { font-size: 2.6rem; letter-spacing: 6px; }
.stars i { font-style: normal; color: rgba(255, 255, 255, 0.25); }
.stars i.on { color: var(--gold); text-shadow: 0 3px 0 var(--gold-edge); }
.res-grid { display: grid; grid-template-columns: 200px 1fr; gap: 18px; align-items: center; margin: 8px 0; }
.chest-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#res-chest { width: 170px; border-radius: 22px; transition: transform 0.4s; }
#res-chest.open { transform: scale(1.12) rotate(-4deg); filter: drop-shadow(0 0 22px var(--gold)); }
#res-stats { list-style: none; margin: 0; padding: 0; text-align: left; display: grid; gap: 6px; }
#res-stats li { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: 12px; background: rgba(13, 36, 90, 0.55); }
#res-stats li b { margin-left: auto; font-family: var(--font-display); color: var(--gold); }
#res-stats li.unlock { background: rgba(255, 207, 58, 0.25); }
.reveal { margin: 10px auto; max-width: 60ch; padding: 10px 14px; border-radius: 14px; background: var(--cream); color: var(--ink); font-weight: 800; line-height: 1.4; }
.reward { color: var(--cyan); margin: 4px; }
#res-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 8px; }

/* Ending: the in-game newspaper front page */
#screen-ending { align-items: center; justify-content: center; padding: 16px; background: radial-gradient(circle, #ffd59a, #e5884a); overflow-y: auto; }
.newspaper { width: min(760px, 96vw); background: #fbf5e6; color: #222; padding: 22px 28px; border-radius: 4px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4); transform: rotate(-1deg); animation: titleIn 0.9s; font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.newspaper header { text-align: center; border-bottom: 3px double #222; padding-bottom: 8px; }
.newspaper header h1 { font-family: Georgia, serif; font-size: clamp(1.8rem, 6vw, 3rem); margin: 4px 0; color: #222; text-shadow: none; }
.newspaper header small { font-size: 0.8rem; }
#end-headline { font-family: var(--font-display); font-size: clamp(1.6rem, 5vw, 2.6rem); line-height: 1.05; margin: 14px 0 8px; color: #222; text-shadow: none; }
.lede { font-size: 1.1rem; line-height: 1.5; }
.newspaper blockquote { margin: 12px 0; padding-left: 14px; border-left: 4px solid var(--red); font-style: italic; font-size: 1.1rem; }
.newspaper .stats { font-family: var(--font-body); font-weight: 800; color: var(--blue-2); }
.credits { margin: 14px 0; padding-top: 10px; border-top: 1px solid #bbb; }
.credits h3 { font-family: var(--font-display); margin: 0 0 6px; }
.newspaper .btn { margin-top: 6px; }

/* ---------------- Overlay sheets ---------------- */
#overlay { position: absolute; inset: 0; z-index: 35; display: flex; align-items: center; justify-content: center; background: rgba(8, 20, 50, 0.6); padding: calc(12px + var(--safe-t)) 12px calc(12px + var(--safe-b)); font-size: calc(16px * var(--text-scale)); }
.sheet { display: none; width: min(640px, 96vw); max-height: 100%; padding: 16px 20px 20px; flex-direction: column; overflow: hidden; }
.sheet.wide { width: min(1100px, 98vw); }
.sheet.show { display: flex; }
.sheet h2 { font-family: var(--font-display); margin: 0 0 10px; font-size: 2rem; text-align: center; }
.sheet header { display: flex; align-items: center; gap: 12px; }
.sheet header h2 { flex: 1; margin: 0; }
.sheet .close { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--gold); color: #7a3a00; font-size: 1.2rem; box-shadow: 0 4px 0 var(--gold-edge); }
.sheet-note { font-size: 0.85em; opacity: 0.9; margin: 8px 0; }
.scroll { overflow-y: auto; }
.menu-tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.menu-tiles button { border: 0; padding: 0; background: none; border-radius: 18px; filter: drop-shadow(0 4px 0 rgba(8, 26, 71, 0.8)); }
.menu-tiles img { width: 100%; display: block; }
.menu-tiles button:active { transform: translateY(3px); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 18px; }
#ev-count { font-family: var(--font-display); color: var(--gold); }
#evidence-board { position: relative; flex: 1; overflow: auto; display: flex; gap: 16px; padding: 10px 4px 14px; border-radius: 16px; background: linear-gradient(135deg, #d8b07a, #c08e55); box-shadow: inset 0 0 0 6px #8a5a2a; min-height: 300px; }
#evidence-board .empty { color: var(--ink); margin: auto; max-width: 40ch; text-align: center; font-weight: 800; }
.ev-links { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; overflow: visible; }
.ev-links .link { fill: none; stroke-width: 4; stroke-linecap: round; }
.ev-links .link.supports { stroke: #1f8a3a; }
.ev-links .link.contradicts { stroke: #d42a2a; stroke-dasharray: 10 8; }
.ev-links .link-label { font: 900 13px var(--font-body); paint-order: stroke; stroke: #fff; stroke-width: 4px; text-anchor: middle; }
.ev-links .link-label.supports { fill: #1f8a3a; } .ev-links .link-label.contradicts { fill: #d42a2a; }
.ev-col { flex: 0 0 250px; display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.ev-col h3 { margin: 0; font-family: var(--font-display); color: #fff; font-size: 1.05rem; text-shadow: 0 2px 0 #5a3410; }
.ev-card { position: relative; display: flex; gap: 10px; padding: 10px; background: #fffaf0; color: var(--ink); border-radius: 6px; box-shadow: 0 6px 12px rgba(60, 30, 0, 0.35); transform: rotate(-0.8deg); }
.ev-card:nth-child(odd) { transform: rotate(0.9deg); }
.ev-card::before { content: ''; position: absolute; top: -7px; left: 50%; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--red)); box-shadow: 0 2px 2px rgba(0, 0, 0, 0.3); }
.ev-photo { flex: none; width: 70px; height: 70px; border-radius: 4px; background: #e8eef8; display: grid; place-items: center; overflow: hidden; }
.ev-photo img { width: 100%; height: 100%; object-fit: cover; }
.type-icon { font-size: 34px; }
.ev-body { min-width: 0; }
.ev-type { font-size: 0.72em; text-transform: none; color: var(--blue-2); font-weight: 900; }
.ev-card h4 { margin: 1px 0 3px; font-family: var(--font-display); font-weight: 400; font-size: 1.05em; }
.ev-card p { margin: 0 0 4px; font-size: 0.82em; line-height: 1.35; font-weight: 700; }
.ev-card small { display: block; font-size: 0.72em; color: #5a6380; }
.ev-status { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 10px; font-size: 0.75em; font-weight: 900; }
.status-confirmed .ev-status { background: #d6f5d6; color: #1f6a2a; border: 2px solid #1f8a3a; }
.status-suspicious .ev-status { background: #fff1c8; color: #7a5200; border: 2px dashed #c98a10; }
.status-unresolved .ev-status { background: #e6e9f5; color: #3a4466; border: 2px dotted #5a6380; }
#journal-body .question { font-style: italic; background: var(--cream); color: var(--ink); padding: 10px 14px; border-radius: 14px; }
.obj-list { list-style: none; padding: 0; display: grid; gap: 6px; }
.obj-list li { display: flex; gap: 10px; padding: 7px 12px; border-radius: 12px; background: rgba(13, 36, 90, 0.5); }
.obj-list li.current { background: var(--gold); color: var(--ink); }
.obj-list li.done { opacity: 0.75; }
.obj-list li.todo { opacity: 0.6; font-style: italic; }
.tally { margin-top: 12px; font-weight: 900; }
.cast, .gadget { display: flex; gap: 12px; align-items: center; padding: 10px; margin-bottom: 10px; border-radius: 16px; background: rgba(13, 36, 90, 0.5); }
.cast-pic { flex: none; width: 76px; height: 76px; border-radius: 50%; overflow: hidden; border: 4px solid #fff; background: var(--c); display: grid; place-items: center; font-size: 38px; }
.cast-pic img { width: 100%; height: 100%; object-fit: cover; }
.cast h4, .gadget h4 { margin: 0; font-family: var(--font-display); font-weight: 400; font-size: 1.2em; }
.cast b { color: var(--gold); font-size: 0.85em; }
.cast p, .gadget p { margin: 3px 0 0; font-size: 0.85em; line-height: 1.35; }
.gadget img { width: 64px; height: 64px; border-radius: 14px; }
.gadget.locked { opacity: 0.55; } .gadget.locked img { filter: grayscale(1); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 9px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.15); }
.set-row input[type=range] { width: 46%; accent-color: var(--gold); }
.set-row select { padding: 6px 10px; border-radius: 10px; border: 0; font: inherit; color: var(--ink); }
.switch { appearance: none; width: 54px; height: 30px; border-radius: 20px; background: var(--navy); position: relative; transition: background 0.2s; flex: none; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left 0.2s; }
.switch:checked { background: var(--green); } .switch:checked::after { left: 27px; }
.map-wrap { display: grid; place-items: center; }
#bigmap { max-width: 100%; max-height: 62vh; border-radius: 16px; border: 4px solid #fff; }

/* Tuner */
#tuner { position: absolute; inset: 0; z-index: 42; display: grid; place-items: center; background: rgba(8, 20, 50, 0.7); padding: 12px; }
.tuner-card { width: min(700px, 96vw); padding: 16px 20px; text-align: center; }
.tuner-card h2 { font-family: var(--font-display); margin: 0; font-size: 2rem; }
#tuner-canvas { width: 100%; border-radius: 14px; border: 4px solid #fff; background: #0d1b3d; }
#tuner-slider { width: 100%; margin: 12px 0 8px; accent-color: var(--cyan); height: 30px; }
.tuner-meter { height: 16px; border-radius: 10px; background: var(--navy); overflow: hidden; border: 2px solid #fff; }
.tuner-meter i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), #5aff8a); }
.tuner-state { font-family: var(--font-display); font-size: 1.2rem; margin: 8px 0 0; }

/* ---------------- Responsive: compact landscape ---------------- */
body.layout-compact #objective { width: min(290px, 42vw); }
body.layout-compact #minimap { width: 128px; height: 128px; }
body.layout-compact #hud-counters { left: auto; right: calc(250px + var(--safe-r)); transform: none; }
body.layout-compact .menu-tiles { grid-template-columns: repeat(3, 1fr); }

/* small landscape phones */
body.small.layout-wide .portrait-ring, body.small.layout-compact .portrait-ring { width: 56px; height: 56px; }
body.small.layout-wide #objective, body.small.layout-compact #objective { top: calc(78px + var(--safe-t)); font-size: 0.85em; width: min(260px, 36vw); }
body.small.layout-wide #minimap, body.small.layout-compact #minimap { width: 104px; height: 104px; top: calc(66px + var(--safe-t)); }
body.small .icon-btn { width: 44px; height: 44px; }
body.small #dialogue { font-size: calc(14px * var(--text-scale)); }
body.small .dlg-portrait { width: 84px; height: 84px; }
body.small .dlg-body { min-height: 86px; }
body.small.layout-wide .title-logo, body.small.layout-compact .title-logo { top: 36%; max-height: 40vh; }
body.small.layout-wide .title-menu .btn, body.small.layout-compact .title-menu .btn { font-size: 1.1rem; min-width: 130px; padding: 0.45em 1em; }
body.small .title-hint { display: none; }

/* ---------------- Responsive: portrait phones (reflowed, not shrunk) ---------------- */
body.layout-portrait #hud-player { top: calc(10px + var(--safe-t)); }
body.layout-portrait .portrait-ring { width: 54px; height: 54px; }
body.layout-portrait .scoop .bar { width: 80px; }
body.layout-portrait #hud-counters { top: calc(72px + var(--safe-t)); left: calc(10px + var(--safe-l)); transform: none; gap: 6px; }
body.layout-portrait .pill img { width: 26px; height: 26px; }
body.layout-portrait .pill b { font-size: 1em; }
body.layout-portrait #hud-buttons { gap: 4px; }
body.layout-portrait .icon-btn { width: 40px; height: 40px; }
body.layout-portrait #hearts { transform: scale(0.78); transform-origin: left center; }
body.layout-portrait #objective { top: calc(108px + var(--safe-t)); left: calc(10px + var(--safe-l)); right: calc(120px + var(--safe-r)); width: auto; padding: 5px 9px 7px; font-size: 0.82em; }
body.layout-portrait #objective.collapsed .obj-head { display: none; }
body.layout-portrait #minimap { top: calc(60px + var(--safe-t)); width: 96px; height: 96px; }
body.layout-portrait #toasts { top: calc(120px + var(--safe-t)); }
body.layout-portrait #prompt { bottom: calc(260px + var(--safe-b)); }
body.layout-portrait #joy-zone { width: 50%; height: 45%; }
body.layout-portrait #relay-panel { top: auto; bottom: calc(360px + var(--safe-b)); right: 50%; transform: translateX(50%); }
body.layout-portrait #dialogue { flex-direction: column; align-items: flex-start; bottom: calc(12px + var(--safe-b)); }
body.layout-portrait .dlg-portrait { width: 76px; height: 76px; margin: 0 0 -26px 14px; }
body.layout-portrait .dlg-body { width: 100%; padding: 26px 16px 18px; }
body.layout-portrait #dlg-name { left: 100px; }
body.layout-portrait .title-logo { top: 30%; width: 90vw; max-height: 34vh; }
body.layout-portrait .title-menu { display: grid; grid-template-columns: 1fr 1fr; width: min(420px, 94vw); gap: 10px; }
body.layout-portrait .title-menu .btn { min-width: 0; width: 100%; }
body.layout-portrait .title-menu #btn-new, body.layout-portrait .title-menu #btn-title-settings { grid-column: 1 / -1; }
body.layout-portrait #chapter-list { grid-template-columns: 1fr; }
body.layout-portrait .res-grid { grid-template-columns: 1fr; }
body.layout-portrait .menu-tiles { grid-template-columns: repeat(3, 1fr); }
body.layout-portrait #evidence-board { flex-direction: column; }
body.layout-portrait .ev-col { flex: none; }
body.layout-portrait .sheet { height: 100%; }
body.layout-portrait .chyron { flex-direction: column; }
body.layout-portrait .breaking { padding: 4px; }
body.layout-portrait #polaroid { top: 14%; right: 50%; transform: translateX(50%) rotate(3deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
body.reduce-motion *, body.reduce-motion *::before { animation: none !important; }
