/* Toshi: Saving Private Bulla — retro FPS shell */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --blue: #0052FF;
  --blue-soft: #6f9bff;
  --teal: #40e0bb;
  --orange: #ff6501;
  --gold: #ffd23f;
  --red: #ff4d4d;
  --bg: #0a1128;
  --panel: rgba(10, 16, 30, 0.72);
  --panel-edge: rgba(0, 82, 255, 0.35);
  --codec-green: #7dffb2;
  --text: #e8ecff;
  --muted: #93a0c9;
  --btn-shadow: rgba(0, 0, 30, 0.45);
}

html, body {
  height: 100%;
  background: #000;
  overflow: hidden;
  font-family: "Inter Tight", system-ui, sans-serif;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;          /* kill pinch-zoom / double-tap zoom */
  overscroll-behavior: none;
}

input { user-select: text; -webkit-user-select: text; touch-action: manipulation; }

#game, #hud {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  image-rendering: pixelated;
}
#hud { pointer-events: none; }

/* ============ screens ============ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
}
.screen.visible { display: flex; }
.screen.dim { background: rgba(5, 8, 20, 0.82); }
.screen.solid { background: #0a1128; }
#screen-codec.screen.solid { background: #04070d; }

/* animated depth layer behind menu-panel content (never flat black) */
.screen.dim::before,
.screen.solid:not(#screen-codec)::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.22;
  background:
    radial-gradient(60% 50% at 30% 30%, rgba(0, 82, 255, 0.65), transparent 70%),
    repeating-linear-gradient(0deg, rgba(140, 170, 255, 0.16) 0 1px, transparent 1px 4px);
  background-size: 220% 220%, auto;
  animation: glowDrift 18s ease-in-out infinite alternate;
}
@keyframes glowDrift {
  from { background-position: 0% 0%, 0 0; }
  to   { background-position: 100% 100%, 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .screen.dim::before,
  .screen.solid:not(#screen-codec)::before { animation: none; }
}

/* ============ menu ============ */
#screen-menu { flex-direction: column; overflow: hidden; }
.menu-bg {
  position: absolute; inset: 0;
  background: url("../assets/menu.webp") center / cover no-repeat, #0a0d18;
  animation: menuDrift 30s ease-in-out infinite alternate;
}
@keyframes menuDrift { from { transform: scale(1); } to { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) { .menu-bg { animation: none; } }
.menu-vignette {
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(4,6,12,0.6) 0%, rgba(4,6,12,0.08) 30%, rgba(4,6,12,0.2) 60%, rgba(2,4,9,0.94) 100%),
    radial-gradient(ellipse at center, transparent 40%, rgba(2,4,9,0.55) 100%);
}
.menu-content {
  position: relative;
  height: 100%; width: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  padding-bottom: 5vh;
  text-align: center;
}
.logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.logo-img { width: min(360px, 40vw); filter: drop-shadow(0 6px 0 rgba(4,8,16,0.9)) drop-shadow(0 12px 30px rgba(0,0,0,0.7)); }
.logo-sub {
  font-weight: 900; font-size: clamp(16px, 2.4vw, 26px); letter-spacing: 8px;
  color: var(--gold);
  text-shadow: 0 3px 0 #16244f, 0 6px 20px rgba(0,0,0,0.6);
}
.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.btn {
  font-family: "Inter Tight", sans-serif;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.06em;
  color: #fff;
  background: linear-gradient(180deg, #2e6bff, var(--blue));
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 0 var(--btn-shadow), 0 10px 24px rgba(0,0,0,0.5);
  padding: 13px 44px;
  min-height: 44px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.1); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--btn-shadow), 0 6px 16px rgba(0,0,0,0.4); }
.btn-big {
  font-size: 26px; padding: 16px 66px; letter-spacing: 0.07em;
  background: linear-gradient(180deg, #ff8534, var(--orange));
}
.btn-ghost {
  background: rgba(10, 16, 30, 0.6);
  color: var(--text);
  font-size: 15px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 4px 0 var(--btn-shadow);
}
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn.hidden { display: none; }

.controls-hint { margin-top: 16px; font-size: 13px; font-weight: 700; color: rgba(235,238,255,0.8); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }

/* ============ codec cutscene ============ */
.codec {
  width: min(860px, 94vw);
  display: flex; flex-direction: column; gap: 18px;
  font-family: "VT323", monospace;
  color: var(--codec-green);
  position: relative;
}
.codec::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.25) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.codec-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.codec-portrait {
  width: 220px; height: 220px;
  border: 2px solid rgba(125,255,178,0.5);
  background: #020804;
  box-shadow: 0 0 30px rgba(125,255,178,0.15), inset 0 0 24px rgba(0,0,0,0.8);
  overflow: hidden;
}
.codec-portrait img { width: 100%; height: 100%; object-fit: cover; image-rendering: pixelated; filter: brightness(1.05); }
.codec-portrait.speaking { border-color: var(--codec-green); box-shadow: 0 0 40px rgba(125,255,178,0.4); }
.codec-freq { text-align: center; flex: 1; }
.codec-freq-num { font-size: 54px; letter-spacing: 4px; text-shadow: 0 0 12px rgba(125,255,178,0.7); }
.codec-freq-label { font-size: 18px; opacity: 0.7; letter-spacing: 6px; }
.codec-wave { height: 40px; margin-top: 10px; background: repeating-linear-gradient(90deg, rgba(125,255,178,0.5) 0 2px, transparent 2px 7px); animation: wave 0.5s steps(4) infinite; opacity: 0.5; }
@keyframes wave { from { background-position-x: 0; } to { background-position-x: 14px; } }
.codec-textbox {
  border: 2px solid rgba(125,255,178,0.5);
  background: rgba(2, 10, 5, 0.9);
  min-height: 120px;
  padding: 16px 22px;
}
.codec-speaker { font-size: 20px; letter-spacing: 3px; opacity: 0.75; margin-bottom: 6px; }
.codec-text { font-size: 28px; line-height: 1.3; min-height: 74px; }
.codec-hint { text-align: center; font-size: 18px; opacity: 0.55; letter-spacing: 2px; }
/* always inside the viewport, even on a landscape phone where the codec block overflows */
.codec-skip {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  z-index: 2;
  font-family: "VT323", monospace;
  font-size: 22px; letter-spacing: 2px;
  color: var(--codec-green);
  background: rgba(2, 10, 5, 0.85);
  border: 2px solid rgba(125,255,178,0.6);
  padding: 8px 18px; min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.codec-skip:hover, .codec-skip:active { border-color: var(--codec-green); box-shadow: 0 0 18px rgba(125,255,178,0.35); }
/* landscape phones: compact codec so the dialogue line itself stays on screen */
@media (max-height: 500px) {
  /* landscape phone: centred, compact menu; the logo no longer runs off the top */
  .menu-content { justify-content: center; padding: 2vh 0; }
  .logo { gap: 4px; margin-bottom: 8px; }
  .logo-img { width: min(300px, 36vw, 85vh); }
  .logo-sub { font-size: 13px; letter-spacing: 5px; }
  .menu-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-items: center; gap: 6px 10px; width: min(92vw, 640px); }
  .menu-buttons .btn-big { grid-column: 1 / -1; font-size: 20px; padding: 10px 44px; min-height: 42px; }
  .menu-buttons .btn { padding: 8px 22px; font-size: 14px; min-height: 40px; }
  .menu-buttons .btn-ghost { font-size: 13px; }
  .menu-best { margin-top: 6px; font-size: 12px; }
  .controls-hint { margin-top: 6px; font-size: 11px; }
  .codec { gap: 8px; width: min(860px, 92vw); }
  .codec-portrait { width: 110px; height: 110px; }
  .codec-freq-num { font-size: 34px; }
  .codec-freq-label { font-size: 13px; letter-spacing: 4px; }
  .codec-wave { height: 18px; margin-top: 4px; }
  .codec-textbox { min-height: 80px; padding: 8px 14px; }
  .codec-speaker { font-size: 16px; margin-bottom: 2px; }
  .codec-text { font-size: 22px; min-height: 52px; }
  .codec-hint { font-size: 14px; }
}

/* ============ panels (shared with game 1 styling) ============ */
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  box-shadow: 0 0 24px rgba(0, 82, 255, 0.18), 0 24px 60px rgba(0,0,0,0.6);
  padding: 32px 44px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 420px; max-width: 92vw; max-height: 88vh;
}
.panel-wide { min-width: 620px; }
.panel-title {
  font-weight: 900; font-size: 34px; letter-spacing: 3px; color: #fff;
  text-shadow: 0 3px 0 #16244f, 0 6px 18px rgba(0, 82, 255, 0.35);
}
.panel-mascot {
  width: 52px; height: 52px;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 30, 0.45));
  margin-bottom: -6px;
}
.pvp-sub { font-weight: 700; color: #aab6e0; font-size: 14px; }
.go-flavor { font-weight: 700; color: var(--muted); margin-top: -8px; }
.go-stats { text-align: center; }
.go-score {
  font-family: "VT323", monospace; font-weight: 400;
  font-size: 64px; color: var(--gold); line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 30, 0.5), 0 0 18px rgba(255, 210, 63, 0.35);
}
.go-substats { font-weight: 700; color: #aab6e0; font-size: 15px; margin-top: 6px; }
.go-newbest {
  display: inline-block; vertical-align: middle; margin-left: 12px;
  font-family: "Inter Tight", sans-serif; font-size: 14px; font-weight: 900; letter-spacing: 1px;
  color: #0a1128; background: var(--gold); border-radius: 8px; padding: 4px 9px;
  text-shadow: none; box-shadow: 0 3px 0 rgba(0, 0, 30, 0.35);
  animation: bestPop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.go-newbest.hidden { display: none; }
@keyframes bestPop { from { transform: scale(0.3) rotate(-8deg); opacity: 0; } to { transform: scale(1) rotate(-4deg); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .go-newbest { animation: none; } }
.go-grid { display: flex; justify-content: center; gap: 26px; margin: 10px 0 4px; }
.go-cell { display: flex; flex-direction: column; align-items: center; min-width: 96px; }
.go-val { font-family: "VT323", monospace; font-size: 32px; line-height: 1; color: var(--text); }
.go-lab { font-size: 11px; font-weight: 800; letter-spacing: 1.5px; color: var(--muted); margin-top: 2px; }
.go-best { font-weight: 800; font-size: 14px; color: var(--gold); margin-top: 8px; min-height: 18px; }
.menu-best { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 30px; margin-top: 14px; font-size: 14px; font-weight: 800; letter-spacing: 0.5px; color: var(--gold); text-shadow: 0 2px 4px rgba(0,0,0,0.9); }
.menu-best.hidden { display: none; }
.go-checking { font-weight: 700; font-size: 14px; color: #93a0c9; }
.go-checking.hidden, .go-submit.hidden, .end-unlock.hidden { display: none; }
.go-submit { display: flex; flex-direction: column; align-items: center; gap: 8px; background: rgba(255,101,1,0.08); border: 2px dashed rgba(255,101,1,0.5); border-radius: 16px; padding: 14px 20px; }
.go-top20 { font-weight: 900; color: var(--orange); font-size: 17px; }
.go-namerow { display: flex; gap: 10px; }
#end-name {
  font-family: "Inter Tight", sans-serif;
  font-size: 19px; font-weight: 800; width: 210px;
  background: #0a1128; color: #fff;
  border: 2px solid var(--panel-edge); border-radius: 12px;
  padding: 9px 14px; outline: none; text-transform: uppercase;
}
#end-name:focus { border-color: var(--blue); }
.go-submit-msg { font-size: 14px; font-weight: 700; color: var(--muted); min-height: 18px; }
.go-submit-msg.ok { color: var(--gold); }
.go-submit-msg.err { color: var(--red); }
.end-unlock { font-weight: 800; color: var(--gold); font-size: 15px; }

.lb-list { touch-action: pan-y; width: 100%; max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding-right: 6px; }
.lb-row { display: grid; grid-template-columns: 52px 1fr auto; align-items: baseline; gap: 10px; background: rgba(0, 82, 255, 0.09); border: 1px solid rgba(0, 82, 255, 0.18); border-radius: 10px; padding: 7px 14px; font-size: 18px; font-weight: 700; }
.lb-row .lb-rank { font-weight: 900; color: var(--blue-soft); }
.lb-row:nth-child(1) .lb-rank { color: var(--orange); }
.lb-row .lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .lb-score { font-family: "VT323", monospace; font-weight: 400; font-size: 24px; color: var(--gold); }
.lb-loading, .lb-error { text-align: center; padding: 30px 0; color: var(--muted); font-weight: 700; }

/* ============ touch controls ============ */
#touch-ui { display: none; }
@media (pointer: coarse) {
  body.in-game #touch-ui { display: block; }
}
.tbtn {
  position: fixed;
  z-index: 8;
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(0, 82, 255, 0.5);
  background: rgba(10, 16, 30, 0.55);
  color: #fff;
  font-size: 24px;
  font-weight: 900;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.tbtn:active { background: rgba(0, 82, 255, 0.5); }
.tbtn-fire { right: calc(env(safe-area-inset-right, 0px) + 26px); bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); width: 72px; height: 72px; font-size: 19px; border-color: rgba(255, 101, 1, 0.6); }
/* jump lives on the move-hand side, above the stick zone, so the aim zone stays clean */
.tbtn-jump { left: calc(env(safe-area-inset-left, 0px) + 110px); bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }
.tbtn-weapon { right: calc(env(safe-area-inset-right, 0px) + 40px); bottom: calc(env(safe-area-inset-bottom, 0px) + 210px); }
.tbtn-use { right: calc(env(safe-area-inset-right, 0px) + 148px); bottom: calc(env(safe-area-inset-bottom, 0px) + 152px); border-color: rgba(255, 210, 63, 0.7); }
.tbtn.hidden { display: none; }   /* E only appears within reach of the one thing it does */
.tbtn-menu { left: calc(env(safe-area-inset-left, 0px) + 16px); top: calc(env(safe-area-inset-top, 0px) + 58px); width: 48px; height: 48px; font-size: 18px; }

/* ============ rotate gate ============ */
#rotate-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(60% 45% at 50% 32%, rgba(0, 82, 255, 0.22), transparent 70%),
    var(--bg);
  align-items: center; justify-content: center; text-align: center;
}
.rotate-inner p { font-weight: 800; font-size: 18px; color: #c9d4ff; line-height: 1.5; }
.rotate-icon { font-size: 56px; margin-bottom: 14px; animation: wiggle 1.2s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-12deg); } to { transform: rotate(78deg); } }
@media (pointer: coarse) and (orientation: portrait) {
  #rotate-overlay { display: flex; }
}

.loading-inner { text-align: center; font-weight: 700; color: var(--muted); }
.loading-inner p { font-family: "VT323", monospace; font-weight: 400; font-size: 22px; letter-spacing: 2px; }
.loading-cat { width: 90px; height: 90px; image-rendering: auto; animation: bounce 0.8s ease-in-out infinite alternate; }
@keyframes bounce { from { transform: translateY(0); } to { transform: translateY(-14px); } }

/* ============ install-on-phone page ============ */
.install-panel {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 640px; padding: 18px 22px; text-align: center;
  max-height: 100dvh; overflow-y: auto;
}
.install-icon { width: 56px; height: 56px; border-radius: 14px; }
.install-title {
  font-size: 24px; font-weight: 900; letter-spacing: 0.04em; color: #fff;
  text-shadow: 0 3px 0 #16244f;
}
.install-lead { color: var(--muted); font-size: 14px; max-width: 460px; }
.install-cols { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.install-col {
  background: rgba(10, 16, 30, 0.72); border: 1px solid var(--panel-edge);
  box-shadow: 0 0 24px rgba(0, 82, 255, 0.12);
  border-radius: 16px; padding: 12px 18px; min-width: 220px; text-align: left;
}
.install-col h3 { font-size: 14px; font-weight: 800; color: var(--blue-soft); margin-bottom: 6px; }
.install-col ol { margin: 0; padding-left: 18px; color: #d6ddf5; font-size: 13px; line-height: 1.75; }
.install-glyph { color: #8ecbff; }
