:root {
  --bg: #0d0d0d;
  --panel: rgba(16, 16, 16, 0.92);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f4f1ea;
  --muted: #a9a49a;
  --green: #1faa59;
  --green-dark: #127a3e;
  --yellow: #f5c518;
  --red: #e5484d;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.active { display: flex; }
.screen.scroll { overflow-y: auto; justify-content: center; align-items: flex-start; padding: 32px 16px; background: rgba(8, 8, 8, 0.82); backdrop-filter: blur(6px); }
.overlay-center { align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.55); z-index: 30; }
.overlay-bottom { align-items: flex-end; justify-content: center; padding: 16px; z-index: 30; }

/* Title */
#screen-title { align-items: center; justify-content: center; text-align: center; background:
  radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0.55), rgba(0,0,0,0.15) 70%),
  linear-gradient(180deg, rgba(10,6,20,0.35) 0%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.85) 100%),
  url('/img/title.jpg') 62% center / cover no-repeat, #1a1020; }
.title-wrap h1 { text-shadow: none; filter: drop-shadow(0 6px 24px rgba(0,0,0,0.6)); }
.tagline, .controls-hint { text-shadow: 0 1px 6px rgba(0,0,0,0.9); color: #e9e2d6 !important; }
.title-wrap { max-width: 560px; padding: 16px; }
.title-wrap h1 { font-size: clamp(64px, 16vw, 128px); line-height: 0.88; font-weight: 900; letter-spacing: -0.03em; margin: 12px 0 16px;
  background: linear-gradient(180deg, #fff 40%, var(--green)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { color: var(--muted); margin-bottom: 28px; font-size: 17px; }
.controls-hint { margin-top: 28px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.18em; font-size: 12px; color: var(--green); font-weight: 700; }

.btn { display: block; width: 100%; max-width: 320px; margin: 10px auto; padding: 14px 20px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.06); color: var(--text); font-weight: 700; cursor: pointer; font-size: 16px; transition: transform .1s, background .2s; }
.btn:hover { background: rgba(255,255,255,0.12); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-dark); }
.btn.ghost { background: transparent; }
.btn.small { width: auto; display: inline-block; padding: 8px 14px; margin: 0; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: wait; }
.link { background: none; border: 0; color: var(--yellow); cursor: pointer; text-decoration: underline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.row .btn { flex: 1; min-width: 160px; margin: 0; max-width: none; }

/* Loading */
#screen-loading { flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; background: rgba(8,8,8,0.92); gap: 18px; }
.loader { width: 54px; height: 54px; border: 4px solid rgba(255,255,255,0.15); border-top-color: var(--green); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tip { color: var(--muted); max-width: 440px; min-height: 3em; }

/* Panels & cards */
.panel { width: 100%; max-width: 720px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.panel.wide { max-width: 960px; }
.panel.narrow { max-width: 360px; text-align: center; }
.panel h1 { font-size: clamp(28px, 6vw, 44px); line-height: 1.05; margin: 8px 0 12px; }
.panel h2 { font-size: 22px; margin: 8px 0 18px; }
.lead { color: #d9d4c9; font-size: 17px; line-height: 1.55; }
.meta { color: var(--yellow); font-weight: 600; margin-bottom: 12px; }
.label { text-transform: uppercase; letter-spacing: 0.14em; font-size: 11px; color: var(--muted); margin: 18px 0 8px; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin: 22px 0; }
.card { background: rgba(255,255,255,0.04); border: 1px solid var(--line); border-radius: 14px; padding: 16px; line-height: 1.5; font-size: 14.5px; color: #d9d4c9; }
.card .label { margin-top: 0; }
.card h3 { color: var(--text); margin-bottom: 6px; font-size: 18px; }
.card .stake { margin-top: 8px; color: var(--yellow); }
.villain-card { border-color: rgba(229,72,77,0.4); }
.villain-card h3 { color: var(--red); }
.hostage-card { border-color: rgba(245,197,24,0.4); margin: 18px 0; }
.team-member { margin-bottom: 10px; }
.team-member b { color: var(--text); }
ol#brief-objectives { padding-left: 22px; line-height: 1.8; color: #d9d4c9; }

.act { margin-top: 22px; }
.act h3 { font-size: 18px; margin-bottom: 4px; }
.act > p { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.mission-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 8px; background: rgba(255,255,255,0.03); }
.mission-row .num { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: rgba(255,255,255,0.1); }
.mission-row.done .num { background: var(--green); }
.mission-row.failed .num { background: var(--red); }
.mission-row.current { border-color: var(--green); }
.mission-row.locked { opacity: 0.45; }
.mission-row h4 { font-size: 15px; }
.mission-row p { font-size: 13.5px; color: var(--muted); line-height: 1.45; }

/* Dialogue */
.dialogue-box { width: 100%; max-width: 820px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 14px; padding: 18px 22px; cursor: pointer; margin-bottom: max(16px, env(safe-area-inset-bottom)); }
.speaker { color: var(--yellow); font-weight: 800; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.08em; font-size: 13px; }
#dlg-line { font-size: 18px; line-height: 1.5; }
.hint { color: var(--muted); font-size: 12px; margin-top: 10px; text-align: right; }

/* HUD */
#hud { pointer-events: none; z-index: 20; }
#hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); text-align: center; width: min(92vw, 560px); pointer-events: none !important; }
#hud-timer { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; text-shadow: 0 2px 8px #000; }
#hud-timer.urgent { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
#hud-objective { margin-top: 4px; background: rgba(0,0,0,0.6); padding: 7px 14px; border-radius: 10px; font-weight: 600; font-size: 15px; display: inline-block; }
#hud-gps { margin-top: 6px; font-weight: 800; color: var(--yellow); text-shadow: 0 2px 6px #000; }
#gps-arrow { display: inline-block; transition: transform 0.1s; }
#minimap { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 150px; height: 150px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.7); background: #1a1d1a; pointer-events: none !important; }
.hud-left { position: absolute; top: max(14px, env(safe-area-inset-top)); left: 12px; width: 150px; pointer-events: none !important; }
.bar { height: 12px; background: rgba(0,0,0,0.6); border-radius: 6px; overflow: hidden; margin-bottom: 6px; border: 1px solid rgba(255,255,255,0.3); }
#hp-fill { height: 100%; width: 100%; background: var(--green); transition: width 0.2s; }
#veh-fill { height: 100%; width: 100%; background: var(--yellow); }
#hud-prompt { position: absolute; bottom: 34%; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.7); padding: 8px 16px; border-radius: 10px; font-weight: 700; display: none; pointer-events: none !important; white-space: nowrap; }
#hud-toast { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); font-size: 22px; font-weight: 900; text-align: center; text-shadow: 0 2px 10px #000; opacity: 0; transition: opacity 0.3s; pointer-events: none !important; width: 90vw; }
#hud-toast.show { opacity: 1; }
#phone-call { position: absolute; left: 12px; top: 90px; width: min(340px, 70vw); background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: 12px; padding: 12px 14px; pointer-events: none !important; }
#phone-call .caller { font-weight: 800; color: var(--yellow); margin-bottom: 4px; font-size: 13px; text-transform: uppercase; }
#call-line { font-size: 14.5px; line-height: 1.45; }
.ring { display: inline-block; animation: ring 0.4s infinite alternate; }
@keyframes ring { from { transform: rotate(-15deg); } to { transform: rotate(15deg); } }
#crosshair { position: absolute; top: 50%; left: 50%; width: 28px; height: 28px; transform: translate(-50%, -50%); pointer-events: none !important; transition: width .12s, height .12s; }
#crosshair span { position: absolute; background: rgba(255,255,255,0.9); box-shadow: 0 0 3px #000; border-radius: 1px; transition: background .12s; }
#crosshair span:nth-child(1) { left: 50%; top: 0; width: 2px; height: 8px; margin-left: -1px; }
#crosshair span:nth-child(2) { left: 50%; bottom: 0; width: 2px; height: 8px; margin-left: -1px; }
#crosshair span:nth-child(3) { top: 50%; left: 0; height: 2px; width: 8px; margin-top: -1px; }
#crosshair span:nth-child(4) { top: 50%; right: 0; height: 2px; width: 8px; margin-top: -1px; }
#crosshair.locked span { background: var(--red); }
#crosshair.aiming { width: 18px; height: 18px; }
#reticle { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border: 2px solid var(--red); border-radius: 50%; display: none; pointer-events: none !important; box-shadow: 0 0 8px rgba(229,72,77,0.7); animation: reticle-in .15s ease-out; }
#reticle::before, #reticle::after { content: ''; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; background: var(--red); border-radius: 50%; }
#reticle::after { display: none; }
@keyframes reticle-in { from { transform: scale(1.6); opacity: 0; } }
.ret-bar { position: absolute; top: 50px; left: -6px; width: 52px; height: 5px; background: rgba(0,0,0,0.6); border-radius: 3px; overflow: hidden; }
#ret-hp { height: 100%; width: 100%; background: var(--red); }
#hitmarker { position: absolute; top: 50%; left: 50%; width: 26px; height: 26px; transform: translate(-50%, -50%) rotate(45deg); opacity: 0; pointer-events: none !important; }
#hitmarker::before, #hitmarker::after { content: ''; position: absolute; background: #fff; box-shadow: 0 0 4px #000; }
#hitmarker::before { left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; }
#hitmarker::after { top: 50%; left: 0; right: 0; height: 3px; margin-top: -1.5px; }
#hitmarker.show { animation: hit .22s ease-out; }
#hitmarker.kill::before, #hitmarker.kill::after { background: var(--red); }
@keyframes hit { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(45deg) scale(1.4); } 100% { opacity: 0; transform: translate(-50%, -50%) rotate(45deg) scale(0.9); } }
#controls-legend { position: absolute; left: 12px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: 420px; font-size: 12px; color: rgba(255,255,255,0.85); background: rgba(0,0,0,0.45); padding: 8px 10px; border-radius: 10px; pointer-events: none !important; }
#controls-legend kbd { font: inherit; font-weight: 800; font-size: 11px; border: 1px solid rgba(255,255,255,0.5); border-radius: 4px; padding: 0 4px; margin-right: 3px; }
body.touch #controls-legend { display: none; }
.tbtn.shoot.locked { background: rgba(229,72,77,0.95); box-shadow: 0 0 18px rgba(229,72,77,0.9); animation: pulse-fire 0.8s infinite; }
@keyframes pulse-fire { 50% { transform: scale(1.06); } }
#damage-flash { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(229,72,77,0.9); opacity: 0; transition: opacity 0.25s; pointer-events: none !important; }
#btn-pause { position: absolute; top: 172px; right: 14px; }
#btn-assist { position: absolute; top: max(48px, calc(env(safe-area-inset-top) + 40px)); left: 12px; background: rgba(0,0,0,0.6); border-color: rgba(245,197,24,0.6); color: var(--yellow); }
#btn-assist kbd { font: inherit; font-size: 11px; opacity: 0.7; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
body.touch #btn-assist kbd { display: none; }
#phone-call { top: 100px !important; }
.assist-box { border-color: rgba(245,197,24,0.4); }
.assist-box .chat-head p { color: var(--muted); font-size: 12.5px; }
#assist-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
#assist-quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; }
#assist-quick .btn { flex: none; white-space: nowrap; font-size: 13px; padding: 7px 12px; }
#assist-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
#assist-input { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--text); font-size: 16px; outline: none; }
#assist-input:focus { border-color: var(--yellow); }
.msg.helper { align-self: flex-start; background: rgba(245,197,24,0.12); border: 1px solid rgba(245,197,24,0.25); }

/* Touch */
#touch-ui { display: none; }
body.touch #touch-ui { display: block; }
body.touch #crosshair { display: none; }
#stick-zone { position: absolute; left: 0; bottom: 0; width: 45%; height: 45%; }
#stick-base { position: absolute; left: 28px; bottom: max(28px, env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,0.1); border: 2px solid rgba(255,255,255,0.3); }
#stick-knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,0.55); }
.touch-buttons { position: absolute; right: 16px; bottom: max(20px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, 68px); gap: 12px; }
.tbtn { width: 68px; height: 68px; transition: transform .1s; border-radius: 50%; border: 2px solid rgba(255,255,255,0.4); background: rgba(0,0,0,0.45); color: #fff; font-weight: 800; font-size: 13px; touch-action: none; user-select: none; -webkit-user-select: none; }
.tbtn.shoot { background: rgba(229,72,77,0.6); width: 84px; height: 84px; font-size: 15px; grid-row: span 1; }
.tbtn.held { background: rgba(31,170,89,0.7); }

/* Chat */
.chat-box { width: 100%; max-width: 520px; height: min(560px, 82vh); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.chat-head div { flex: 1; }
#chat-role { color: var(--muted); font-size: 13px; }
.mood { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,0.1); text-transform: capitalize; }
#chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 85%; padding: 10px 13px; border-radius: 14px; line-height: 1.45; font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--green-dark); }
.msg.npc { align-self: flex-start; background: rgba(255,255,255,0.08); }
.msg.system { align-self: center; background: rgba(245,197,24,0.15); color: var(--yellow); font-size: 13px; text-align: center; }
.msg.typing { opacity: 0.6; font-style: italic; }
#chat-goal { padding: 10px 16px; background: rgba(245,197,24,0.1); border-bottom: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; color: #e9dfbf; }
#chat-goal b { color: var(--yellow); }
#chat-quick { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; }
#chat-quick .btn { flex: none; white-space: nowrap; font-size: 13px; padding: 7px 12px; }
#chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
#chat-input { flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255,255,255,0.06); color: var(--text); font-size: 16px; outline: none; }
#chat-input:focus { border-color: var(--green); }

#choice-options .btn { max-width: none; text-align: left; }
#choice-options .btn small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }

#result-lines p { margin-bottom: 10px; line-height: 1.5; }
#result-lines b { color: var(--yellow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 20px; }
.stat { background: rgba(255,255,255,0.05); border-radius: 12px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 12px; }

#error-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--red); padding: 12px 18px; border-radius: 12px; z-index: 100; max-width: 90vw; font-weight: 600; }

@media (max-width: 600px) {
  .panel { padding: 20px; }
  #minimap { width: 110px; height: 110px; }
  #btn-pause { top: 128px; }
  #hud-timer { font-size: 26px; }
  #hud-objective { font-size: 13px; }
  .hud-left { width: 110px; }
  #phone-call { top: 70px; }
}

/* phones in landscape: keep the HUD out of the way */
@media (max-height: 500px) {
  .hud-top { width: min(52vw, 480px); }
  #hud-timer { font-size: 24px; }
  #hud-objective { font-size: 12px; padding: 5px 10px; }
  #minimap { width: 110px; height: 110px; }
  #btn-pause { top: 128px; }
  .hud-left { width: 110px; }
  #phone-call { top: 84px !important; width: min(280px, 36vw); padding: 8px 10px; }
  #call-line { font-size: 12.5px; }
  .tbtn { width: 60px; height: 60px; }
  .touch-buttons { grid-template-columns: repeat(2, 60px); }
}

/* simple story page */
.cast { margin-top: 10px; color: var(--muted); font-size: 15px; }
.cast b { color: var(--text); }
.cast .enemy { color: var(--red); font-weight: 700; }
.next-card { margin: 22px 0 8px; padding: 20px; border-radius: 16px; border: 1px solid var(--green); background: rgba(31,170,89,0.1); }
.next-card .label { margin-top: 0; color: var(--green); }
.next-card h2 { font-size: 24px; margin: 4px 0 8px; }
.next-card p { font-size: 16.5px; line-height: 1.5; color: #e4dfd4; }
.next-card .btn { max-width: none; margin: 16px 0 0; }
.progress-list { display: flex; flex-direction: column; gap: 6px; }
.progress-list .item { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--muted); }
.progress-list .item .num { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: rgba(255,255,255,0.1); color: var(--text); }
.progress-list .item.done .num { background: var(--green); }
.progress-list .item.failed .num { background: var(--red); }
.progress-list .item.current { color: var(--text); font-weight: 700; }
.progress-list .item.current .num { background: var(--yellow); color: #000; }
.progress-list .item.locked { opacity: 0.5; }

/* bigger FIRE button on phones */
.touch-buttons { grid-template-columns: repeat(2, auto) !important; align-items: center; justify-items: center; }
@media (max-height: 500px) { .tbtn.shoot { width: 76px; height: 76px; } }
