/* BLACK RAIN — pixel noir. Teal night, sodium orange, hologram pink.
   The HUD is sized in container units of the 16:9 stage box, so it scales
   with the canvas on every screen. */
:root {
  --ink: #05070c;
  --text: #e8e4dc;
  --muted: #8f9aaa;
  --orange: #ff9a3a;
  --pink: #ff3f8e;
  --cyan: #3fe8ff;
  --teal: #2ee6c8;
  --gold: #ffd23f;
  --panel: rgba(6, 9, 15, .82);
  --line: rgba(120, 200, 230, .18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --px: Tiny5, Silkscreen, "Courier New", monospace;
  --sk: Silkscreen, "Courier New", monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--px); overscroll-behavior: none; font-synthesis: none; }
.comic-on .hud, .comic-on .touch { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }
kbd { font-family: var(--sk); font-size: .8em; padding: 0 .35em; border: 1px solid rgba(255, 255, 255, .3); border-bottom-width: 2px; border-radius: 3px; background: rgba(255, 255, 255, .06); }

.game-shell { width: 100%; height: 100%; display: flex; flex-direction: column; background: var(--ink); }
.game-bar { height: 48px; flex-shrink: 0; display: flex; align-items: center; gap: .6rem; padding: max(6px, var(--safe-top)) max(12px, var(--safe-right)) 6px max(12px, var(--safe-left));
  background: linear-gradient(180deg, rgba(8, 12, 20, .95), rgba(8, 12, 20, .75)); border-bottom: 1px solid var(--line); z-index: 30; }
.back-link { display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; color: var(--muted); font: 700 .82rem/1 system-ui, sans-serif; }
.back-link:hover { color: var(--text); }
.game-bar-title { flex: 1; font: 700 1rem/1 var(--px); letter-spacing: .2em; text-transform: uppercase; color: var(--pink); text-shadow: 0 0 12px rgba(255, 63, 142, .5); }
.player-pill { font: 700 .72rem/1 system-ui, sans-serif; color: var(--muted); background: rgba(255, 255, 255, .05); border: 1px solid var(--line); padding: .3rem .6rem; border-radius: 999px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .04); font-size: 1rem; display: grid; place-items: center; }
.icon-btn:active { transform: scale(.94); }

.game-wrap { flex: 1; position: relative; overflow: hidden; background: #000; touch-action: none; display: grid; place-items: center; container-type: size; }
.stage-box { position: relative; width: min(100cqw, 100cqh * 16 / 9); aspect-ratio: 16 / 9; container-type: size; overflow: hidden; background: #000; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }
.crt { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .12) 0 1px, transparent 1px 3px); mix-blend-mode: multiply; opacity: .55; z-index: 4; }

/* ── HUD ─────────────────────────────────────────────────────────────── */
.hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; font-size: 2.1cqh; }
.hud-tl { position: absolute; left: 1.6cqw; top: 2.4cqh; display: flex; gap: 1cqw; align-items: flex-start; }
.hud-face { width: 9.4cqh; height: 9.4cqh; border: .35cqh solid #0a0a0e; outline: .25cqh solid rgba(255, 210, 120, .6); background: #10141c; image-rendering: pixelated; }
.hud-face canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.hud-bars { display: flex; flex-direction: column; gap: .5cqh; min-width: 24cqw; }
.hud-name { font: 700 2.2cqh/1 var(--px); letter-spacing: .08em; color: #f2e6c4; text-shadow: .2cqh .2cqh 0 #000; }
.hud-name em { font-style: normal; color: var(--orange); }
.bar { position: relative; height: 1.6cqh; background: rgba(0, 0, 0, .6); border: .25cqh solid #0a0a0e; outline: 1px solid rgba(255, 255, 255, .12); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; transition: width .18s steps(6); }
.hud-life { display: flex; align-items: center; gap: .6cqw; }
.hud-life .bar { flex: 1; }
.hud-life .bar i { background: repeating-linear-gradient(90deg, #ffb45a 0 8%, #ff8a2a 8% 9.5%, transparent 9.5% 10%); }
.hud-life b { font: 700 1.9cqh/1 var(--sk); color: #ffd9a0; min-width: 4ch; }
.hud-life.low .bar i { background: repeating-linear-gradient(90deg, #ff4a4a 0 8%, #c81a2a 8% 9.5%, transparent 9.5% 10%); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }
.hud-ammo { display: flex; align-items: center; gap: .6cqw; pointer-events: auto; cursor: pointer; }
.lbl { font: 1.5cqh/1 var(--sk); color: var(--muted); letter-spacing: .06em; min-width: 7.5cqw; }
.pips { display: flex; gap: .3cqw; }
.pips i { width: .9cqw; height: 1.8cqh; background: #2a2a30; border: 1px solid #000; }
.pips i.on { background: linear-gradient(180deg, #ffe08a, #c8961a); }
.res { font: 1.5cqh/1 var(--sk); color: #cfc6a8; }
.hud-taali { display: flex; align-items: center; gap: .6cqw; }
.hud-taali .bar { flex: 1; max-width: 16cqw; }
.hud-taali .bar i { background: linear-gradient(90deg, #a01a5a, var(--pink), #ffd0e6); }
.hud-taali .ready { display: none; font: 1.5cqh/1 var(--sk); color: var(--gold); text-shadow: 0 0 1cqh rgba(255, 210, 63, .8); }
.hud-taali.full .ready { display: inline; animation: blink .6s steps(2) infinite; }
.hud-taali.full .bar { outline-color: var(--gold); box-shadow: 0 0 1.2cqh rgba(255, 63, 142, .8); }
body.calm .hud-ammo, body.calm .hud-taali { opacity: .55; }

.hud-tr { position: absolute; right: 1.6cqw; top: 2.4cqh; text-align: right; max-width: 38cqw; }
.obj-label { font: 1.5cqh/1 var(--sk); color: var(--orange); letter-spacing: .14em; }
.obj-text { margin-top: .5cqh; font: 500 2.1cqh/1.25 var(--px); color: #f2f2ea; text-shadow: .2cqh .2cqh 0 #000; padding-right: .8cqw; border-right: .35cqh solid var(--orange); }
.hud-btn { pointer-events: auto; margin-top: 1cqh; width: 5.6cqh; height: 5.6cqh; border: .3cqh solid rgba(255, 255, 255, .2); background: rgba(5, 8, 14, .6); font: 700 2.2cqh/1 var(--sk); color: var(--text); }

.hud-br { position: absolute; right: 1.6cqw; bottom: 2.6cqh; display: flex; flex-direction: column; align-items: flex-end; gap: .4cqh; padding: .9cqh 1cqw; background: rgba(4, 12, 14, .72); border: .25cqh solid rgba(46, 230, 200, .55); box-shadow: inset 0 0 1.4cqh rgba(46, 230, 200, .18); font-family: var(--sk); }
.hud-br b { font: 700 1.8cqh/1 var(--px); color: var(--teal); letter-spacing: .1em; }
.hud-br span { font-size: 1.3cqh; color: #8fc8c0; }
.hud-br .tide { color: #9fd0ff; }
.hud-br .tide.rising { color: var(--cyan); animation: blink 1s steps(2) infinite; }

.boss-bar { position: absolute; left: 50%; bottom: 3cqh; transform: translateX(-50%); width: 46cqw; text-align: center; }
.boss-name { font: 700 2cqh/1 var(--px); color: #ff6a7a; letter-spacing: .12em; text-shadow: .2cqh .2cqh 0 #000; margin-bottom: .6cqh; }
.boss-name em { font-style: normal; color: var(--muted); font-size: .8em; }
.boss-bar .bar { height: 1.4cqh; }
.boss-bar .bar i { background: linear-gradient(90deg, #7a1f2c, #ff3a5a); }

.toast { position: absolute; left: 50%; top: 20cqh; transform: translateX(-50%); font: 700 3.4cqh/1 var(--px); color: var(--gold); letter-spacing: .14em; text-shadow: .3cqh .3cqh 0 #000, 0 0 2cqh rgba(255, 160, 40, .6); opacity: 0; white-space: nowrap; }
.toast.show { animation: toast 1.6s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 1cqh) scale(1.3); } 12% { opacity: 1; transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -1.5cqh); } }

/* ── dialogue ────────────────────────────────────────────────────────── */
.dialog { position: absolute; left: 50%; bottom: 3cqh; transform: translateX(-50%); width: min(86cqw, 80cqh * 1.7); display: flex; gap: 1.4cqw; align-items: flex-start; padding: 1.6cqh 1.6cqw; background: linear-gradient(180deg, rgba(8, 10, 18, .94), rgba(4, 6, 12, .96)); border: .4cqh solid #0a0a0e; outline: .3cqh solid rgba(255, 210, 120, .45); box-shadow: 0 0 0 .3cqh #000, 0 1.6cqh 3cqh rgba(0, 0, 0, .6); z-index: 14; cursor: pointer; touch-action: manipulation; }
.dialog canvas { width: 12cqh; height: 12cqh; flex-shrink: 0; image-rendering: pixelated; border: .3cqh solid #000; outline: .2cqh solid rgba(255, 255, 255, .15); }
.dlg-body { flex: 1; min-width: 0; }
.dlg-name { font: 700 2.2cqh/1 var(--px); letter-spacing: .12em; margin-bottom: .8cqh; }
.dlg-text { font: 500 2.9cqh/1.35 var(--px); color: #f2efe6; min-height: 8cqh; }
.dlg-next { position: absolute; right: 1.4cqw; bottom: 1cqh; color: var(--gold); font-size: 2cqh; animation: blink .7s steps(2) infinite; }

.comic-ui { position: absolute; inset: 0; z-index: 14; pointer-events: none; }
.comic-ui .skip { pointer-events: auto; position: absolute; right: 1.6cqw; bottom: 2cqh; font: 700 2cqh/1 var(--sk); padding: 1cqh 1.4cqw; background: rgba(0, 0, 0, .7); border: .3cqh solid rgba(255, 255, 255, .3); color: #fff; }
.comic-hint { position: absolute; left: 1.6cqw; bottom: 2.4cqh; font: 1.6cqh/1 var(--sk); color: rgba(255, 255, 255, .55); animation: blink 1.2s steps(2) infinite; }

/* ── screens ─────────────────────────────────────────────────────────── */
.screen { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 3cqh 3cqw; }
.screen-active { display: flex; }
#screen-menu, #screen-loading { justify-content: flex-start; padding-left: 6cqw; background: linear-gradient(90deg, rgba(3, 5, 10, .88) 0%, rgba(3, 5, 10, .55) 46%, rgba(3, 5, 10, 0) 72%); }
#screen-loading { background: #05070c; justify-content: center; padding-left: 3cqw; }
#screen-pause, #screen-over, #screen-how, #screen-leaderboard, #screen-clear { background: rgba(3, 5, 10, .72); backdrop-filter: blur(2px); }
.title-block { max-width: 52cqw; }
.eyebrow { font: 1.7cqh/1 var(--sk); letter-spacing: .22em; color: var(--orange); }
.logo { margin-top: 1.4cqh; font: 700 13cqh/.9 var(--px); letter-spacing: .04em; color: #f4f1ea; text-shadow: .6cqh .6cqh 0 #000, 0 0 4cqh rgba(63, 232, 255, .35); }
.logo span { color: var(--pink); text-shadow: .6cqh .6cqh 0 #000, 0 0 3cqh rgba(255, 63, 142, .8), 0 0 8cqh rgba(255, 63, 142, .4); }
.hindi { margin-top: .6cqh; font: 5cqh/1.2 "Tiro Devanagari Hindi", serif; color: var(--orange); text-shadow: 0 0 2cqh rgba(255, 154, 58, .55); }
.tagline { margin-top: 1.6cqh; font: 500 2.5cqh/1.4 var(--px); color: #c9d2de; max-width: 44cqw; }
.menu-actions { margin-top: 2.8cqh; display: flex; flex-direction: column; gap: 1.2cqh; align-items: flex-start; }
.menu-actions button { font: 700 2.6cqh/1 var(--px); letter-spacing: .08em; padding: 1.4cqh 2cqw; min-width: 26cqw; text-align: left; background: rgba(6, 10, 18, .75); border: .3cqh solid rgba(255, 255, 255, .16); color: var(--text); box-shadow: .5cqh .5cqh 0 #000; transition: transform .08s, border-color .15s; }
.menu-actions button:hover, .menu-actions button:focus-visible { border-color: var(--cyan); transform: translateX(.6cqw); outline: none; }
.menu-actions button.primary { background: linear-gradient(90deg, #c8195a, #ff3f8e); border-color: #ffd0e6; color: #fff; text-shadow: .2cqh .2cqh 0 #5a0a2a; }
.menu-actions button small { display: block; margin-top: .6cqh; font: 1.5cqh/1 var(--sk); letter-spacing: .1em; opacity: .85; }
.menu-actions.compact { flex-direction: row; flex-wrap: wrap; justify-content: center; }
.menu-actions.compact button { min-width: 0; text-align: center; }
.stat-strip { margin-top: 2.4cqh; display: flex; gap: 1.8cqw; flex-wrap: wrap; font: 1.6cqh/1 var(--sk); color: var(--muted); }
.stat-strip b { color: var(--gold); font-weight: 400; }
.tip { margin-top: 1.4cqh; font: 1.4cqh/1 var(--sk); color: rgba(255, 255, 255, .35); }
#load-text { margin-top: 2cqh; font: 1.8cqh/1 var(--sk); color: var(--muted); }

.panel { width: min(88cqw, 150cqh); max-height: 94cqh; overflow: auto; padding: 3cqh 3cqw; background: var(--panel); border: .35cqh solid rgba(255, 255, 255, .14); box-shadow: 0 0 0 .3cqh #000, 1cqh 1cqh 0 rgba(0, 0, 0, .6); text-align: center; }
.panel-sm { width: min(60cqw, 100cqh); }
.panel h2 { margin: 1cqh 0 2cqh; font: 700 5.4cqh/1 var(--px); color: #f4f1ea; text-shadow: .4cqh .4cqh 0 #000; }
.readable { text-align: left; }
.readable h2 { text-align: left; }
.how-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4cqh 2cqw; }
.how-grid div { padding: 1.2cqh 1cqw; background: rgba(255, 255, 255, .03); border-left: .4cqh solid var(--pink); }
.how-grid b { display: block; font: 700 2.1cqh/1 var(--px); color: var(--gold); margin-bottom: .7cqh; }
.how-grid span { font: 500 1.9cqh/1.4 var(--px); color: #cfd6e0; }
.how-grid em { color: var(--pink); font-style: normal; }
.cut { font: 700 16cqh/1 var(--px); color: var(--gold); letter-spacing: .06em; text-shadow: .8cqh .8cqh 0 #000; transform: rotate(-3deg); margin: 1cqh 0; }
.subtitle { font: 500 2.4cqh/1.4 var(--px); color: #c9d2de; }
.leaderboard-list { display: flex; flex-direction: column; gap: .8cqh; min-height: 20cqh; }
.lb-row { display: flex; gap: 1.6cqw; align-items: center; padding: 1cqh 1.4cqw; background: rgba(255, 255, 255, .04); font: 500 2.2cqh/1 var(--px); }
.lb-row b { color: var(--orange); width: 3ch; }
.lb-row span { flex: 1; }
.lb-row em { font-style: normal; color: var(--gold); font-family: var(--sk); }
.muted { color: var(--muted); font: 1.9cqh/1.4 var(--px); }
.clear h2 { margin-bottom: 1.4cqh; }
.grade-row { display: flex; justify-content: center; align-items: center; gap: 3cqw; }
.grade { font: 700 20cqh/1 var(--px); color: var(--gold); text-shadow: .8cqh .8cqh 0 #000, 0 0 4cqh rgba(255, 210, 63, .6); width: 18cqh; }
.grade[data-grade="S"] { color: var(--pink); text-shadow: .8cqh .8cqh 0 #000, 0 0 5cqh rgba(255, 63, 142, .9); }
.final-score { font: 700 7cqh/1 var(--sk); color: #f4f1ea; }
.newbest { margin-top: 1cqh; font: 1.8cqh/1 var(--sk); color: var(--cyan); }
.stat-grid { margin: 2.4cqh auto 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 1cqh 1.4cqw; max-width: 110cqh; }
.stat-grid span { display: flex; flex-direction: column; gap: .5cqh; padding: 1cqh; background: rgba(255, 255, 255, .04); font: 1.5cqh/1 var(--sk); color: var(--muted); }
.stat-grid b { font: 700 2.6cqh/1 var(--px); color: #f4f1ea; }
.next { margin-top: 2cqh; font: 500 2.1cqh/1.3 var(--px); color: #c9d2de; }
.next b { color: var(--teal); }

/* ── touch controls ──────────────────────────────────────────────────── */
.touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .touch:not(.hidden) { display: block; position: absolute; inset: 0; z-index: 16; pointer-events: none; }
  .stick-zone { position: absolute; left: 0; bottom: 0; width: 42%; height: 62%; pointer-events: auto; touch-action: none; }
  .stick { position: absolute; left: max(22px, var(--safe-left)); bottom: max(22px, var(--safe-bottom)); width: 112px; height: 112px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .22); background: radial-gradient(circle, rgba(255, 255, 255, .08), rgba(0, 0, 0, .25)); }
  .stick i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255, 255, 255, .28); border: 2px solid rgba(255, 255, 255, .5); }
  .pad { position: absolute; right: max(14px, var(--safe-right)); bottom: max(14px, var(--safe-bottom)); width: 232px; height: 200px; pointer-events: none; }
  .tb { position: absolute; pointer-events: auto; width: 60px; height: 60px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(8, 12, 20, .55); font-size: 22px; line-height: 1; display: grid; place-items: center; touch-action: none; user-select: none; -webkit-user-select: none; }
  .tb.on { background: rgba(255, 63, 142, .55); transform: scale(.94); }
  .tb small { font: 700 9px/1 var(--sk); display: block; margin-top: 2px; }
  .tb.punch { right: 0; bottom: 66px; width: 72px; height: 72px; font-size: 28px; border-color: rgba(255, 210, 63, .7); }
  .tb.kick { right: 78px; bottom: 30px; }
  .tb.jump { right: 4px; bottom: -4px; width: 64px; height: 64px; }
  .tb.dodge { right: 150px; bottom: 0; width: 52px; height: 52px; }
  .tb.shoot { right: 84px; bottom: 104px; width: 54px; height: 54px; }
  .tb.crouch { right: 150px; bottom: 62px; width: 48px; height: 48px; font-size: 18px; }
  .tb.ctx { display: none; right: 16px; bottom: 150px; width: 66px; height: 66px; font-size: 22px; }
  .tb.filmy { border-color: var(--gold); background: rgba(255, 63, 142, .6); box-shadow: 0 0 18px rgba(255, 63, 142, .9); animation: blink .6s steps(2) infinite; right: 150px; bottom: 120px; }
  body.can-talk .tb.talk { display: grid; }
  body.filmy-ready:not(.calm) .tb.filmy { display: grid; }
  body.calm .tb.punch, body.calm .tb.kick, body.calm .tb.shoot, body.calm .tb.dodge, body.calm .tb.crouch, body.calm .tb.jump { display: none; }
  body.calm .tb.talk { right: 30px; bottom: 40px; width: 84px; height: 84px; font-size: 28px; }
  .hud-taali .ready kbd { display: none; }
}

/* Portrait phones: playfield on top, controls in the space below. */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  .game-wrap { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; }
  .stage-box { width: 100%; flex-shrink: 0; }
  .touch:not(.hidden) { position: relative; inset: auto; flex: 1; min-height: 0; }
  .stick-zone { width: 50%; height: 100%; }
  .stick { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: 130px; height: 130px; }
  .pad { right: 16px; bottom: auto; top: 50%; transform: translateY(-50%); }
  .screen { padding: 2cqh 3cqw; }
  #screen-menu { padding-left: 4cqw; background: rgba(3, 5, 10, .7); }
  .title-block { max-width: 92cqw; }
  .logo { font-size: 15cqh; }
  .tagline { display: none; }
  .menu-actions { flex-direction: row; flex-wrap: wrap; margin-top: 2cqh; }
  .menu-actions button { min-width: 0; font-size: 4cqh; padding: 2cqh 3cqw; }
  .stat-strip, .tip, .hindi { display: none; }
  .hud { font-size: 2.6cqh; }
  .panel { width: 96cqw; max-height: 96cqh; padding: 2cqh 2cqw; }
  .how-grid { grid-template-columns: 1fr 1fr; }
  .how-grid span { font-size: 3.4cqh; }
  .how-grid b { font-size: 3.6cqh; }
  .dialog { width: 96cqw; bottom: 2cqh; }
  .dlg-text { font-size: 4.4cqh; }
  .dlg-name { font-size: 3.4cqh; }
  .hud-tr { max-width: 44cqw; }
  .obj-text { font-size: 3.4cqh; }
}
@media (orientation: portrait) {
  .game-wrap { container-type: size; }
}
@media (max-height: 460px) and (orientation: landscape) {
  .pad { transform: scale(.8); transform-origin: bottom right; }
  .stick { transform: scale(.85); transform-origin: bottom left; }
  .game-bar { height: 38px; padding-top: max(2px, var(--safe-top)); padding-bottom: 2px; }
  .icon-btn { width: 30px; height: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .crt { display: none; }
  .toast.show, .hud-taali.full .ready, .tb.filmy, .comic-hint, .dlg-next { animation: none; opacity: 1; }
}
