/* BAYLE: Latent Space — DOM overlay (menus). Local/system fonts only. */
:root {
  --bg: #000000;
  --surface: #0B0F1A;
  --surface-2: #121A2B;
  --text: #E8EEFB;
  --muted: #93A0BB;
  --accent: #2456E8;
  --accent-hover: #1F5BFF;
  --accent-text: #7AA2FF;
  --accent-soft: #A9C4FF;
  --line: rgba(122, 162, 255, .14);
  --line-strong: rgba(122, 162, 255, .32);
  --danger: #FF9D9D;
  --gold: #FFD27A;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
}
canvas#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

#ui {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: radial-gradient(ellipse at center, rgba(11, 15, 26, .55), rgba(0, 0, 0, .82));
}
#ui.on { display: flex; }

.screen {
  width: 100%;
  max-width: 720px;
  margin: auto;
  padding: 32px 24px;
  text-align: center;
  background: rgba(11, 15, 26, .72);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}
.screen-title { background: transparent; border-color: transparent; }

.logo { display: block; margin: 0 auto 12px; filter: drop-shadow(0 0 24px rgba(36, 86, 232, .55)); }
h1.title { margin: 8px 0 4px; font-size: clamp(28px, 6vw, 48px); font-weight: 800; letter-spacing: -.02em; }
h2 { margin: 4px 0 12px; font-size: clamp(22px, 4vw, 32px); font-weight: 750; }
p { color: var(--text); line-height: 1.5; margin: 8px 0; }
.tagline { color: var(--accent-text); font-size: 18px; margin-bottom: 24px; }
.muted { color: var(--muted); }
.accent { color: var(--accent-text); font-weight: 600; }
.danger { color: var(--danger); }
.gold { color: var(--gold); }
.mono { font-family: var(--mono); }
.kicker { color: var(--accent-text); letter-spacing: .12em; text-transform: uppercase; font-size: 12px; }
.fine { color: var(--muted); font-size: 12px; margin-top: 20px; }

.stack { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 16px 0; }

.btn {
  font: 600 15px var(--sans);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 11px 22px;
  min-width: 200px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--accent-text); }
.btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.langs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; padding-bottom: 4px; }
.btn.lang { min-width: 0; padding: 6px 12px; font: 600 12px var(--mono); }
.btn.lang.on { border-color: var(--accent-text); color: var(--accent-text); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 20px; }
.btn.card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  text-align: left;
  min-width: 0;
  padding: 16px;
}
.btn.card strong { font-size: 16px; }
.btn.card .desc { color: var(--muted); font-weight: 500; font-size: 13px; line-height: 1.4; }
.btn.card .mono { color: var(--accent-text); font-size: 12px; }
.btn.card.rec { border-color: var(--accent-text); }

.taunt {
  margin: 18px auto;
  padding: 12px 16px;
  max-width: 520px;
  border-left: 3px solid var(--line-strong);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-style: italic;
}
.taunt .who { font: 600 11px var(--mono); font-style: normal; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

.grade { font: 800 72px var(--mono); margin: 4px 0 8px; color: var(--accent-text); }
.grade-S { color: var(--gold); }
.grade-C { color: var(--danger); }

.table { max-width: 420px; margin: 12px auto 20px; text-align: left; }
.row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.row .k { color: var(--muted); }
.row .v { font-family: var(--mono); text-align: right; }

/* ---------- T07 screens ---------- */
.small { font-size: 13px; }
h3 { margin: 18px 0 6px; font-size: 15px; font-weight: 700; color: var(--accent-soft); letter-spacing: .02em; }
.logo { animation: ring-glow 4s ease-in-out infinite; }
@keyframes ring-glow {
  0%, 100% { filter: drop-shadow(0 0 18px rgba(36, 86, 232, .45)); }
  50% { filter: drop-shadow(0 0 32px rgba(122, 162, 255, .7)); }
}
.badge { display: inline-block; font: 700 11px var(--mono); letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 10px; border: 1px solid rgba(255, 210, 122, .5); border-radius: 999px; margin-bottom: 4px; }
.stage { color: var(--accent-soft); font-size: 12px; opacity: .85; }
.card-head { display: flex; align-items: center; gap: 8px; }
.sector-cards { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.btn.card.region-east { border-left: 3px solid rgba(169, 196, 255, .6); }
.btn.card.region-europe { border-left: 3px solid rgba(255, 130, 5, .7); }
.btn.card.region-valley { border-left: 3px solid rgba(255, 157, 157, .7); }
.taunt-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 12px auto; max-width: 560px; }
.taunt-row .taunt { margin: 0; flex: 1; }
.icon { display: block; flex: none; }
.screen-hangar, .screen-victory, .screen-sectors { max-width: 760px; }
canvas.map, canvas.rain { display: block; margin: 8px auto 4px; max-width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .55); }
.hangar-head { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 12px 0; text-align: left; }
.hangar-head p { margin: 2px 0; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 8px 0; }
.btn.chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; padding: 4px 14px 4px 6px; font-size: 13px; }
.btn.chip.on { border-color: var(--accent-text); background: rgba(36, 86, 232, .28); }
.btn.gold-btn { background: rgba(255, 210, 122, .12); border-color: var(--gold); color: var(--gold); }
.btn.gold-btn:hover { background: rgba(255, 210, 122, .22); }
.settings { max-width: 460px; margin: 12px auto 20px; text-align: left; }
.setting { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting .k { flex: 1; color: var(--muted); }
.setting .v { width: 36px; text-align: right; }
.setting .langs { margin: 0; }
.setting input[type=range] { width: 160px; accent-color: var(--accent); }
.btn.toggle { min-width: 72px; padding: 6px 12px; font-size: 13px; }
.btn.toggle.on { border-color: var(--accent-text); color: var(--accent-text); }
.story p { color: var(--accent-soft); margin: 4px 0; }
.disclaimer { color: var(--muted); font-size: 12px; margin-top: 18px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 8px; }
#ui.ui-lagoonIntro, #ui.ui-lagoonPause, #ui.ui-lagoonEnd { background: radial-gradient(ellipse at center, rgba(4, 28, 32, .4), rgba(0, 0, 0, .7)); }
.screen-lagoonIntro, .screen-lagoonPause, .screen-lagoonEnd { background: rgba(4, 20, 24, .7); border-color: rgba(255, 210, 122, .22); }
.lagoon-title { letter-spacing: .28em; font-weight: 700; }
.lagoon-sub { color: var(--gold); font-style: italic; opacity: .85; }
.screen-lagoonEnd .icon { margin: 8px auto; }
.endcard { font-size: 17px; font-style: italic; max-width: 460px; margin: 12px auto; color: var(--text); }
.screen-title .stack .btn { min-width: 220px; }
@media (max-width: 560px) {
  .setting input[type=range] { width: 110px; }
  .hangar-head { flex-direction: column; text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  .logo { animation: none; }
}

.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }

@media (max-width: 560px) {
  .screen { padding: 24px 16px; }
  .btn { min-width: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}

/* sector clear: allies who joined (main.js finishSector → result.joined) */
.joined { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 6px 0; }
.joined p { flex-basis: 100%; margin: 0; font-style: italic; }

/* ---------- T13 mobile (08-open-world.md § Mobile) ---------- */
/* read by BG.Touch.readSafe() -> BG.HUD.safe */
.safe-probe {
  position: fixed; left: 0; top: 0; width: 0; height: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
/* buttons: no double-tap zoom, >= 44 px targets */
.btn { touch-action: manipulation; min-height: 44px; }
.btn.lang { min-height: 44px; min-width: 44px; }
.btn.toggle { min-height: 44px; }
.btn.chip { min-height: 44px; }
.setting input[type=range] { min-height: 44px; }
@media (pointer: coarse) {
  .btn:hover { border-color: var(--line-strong); }
  .btn.primary:hover { background: var(--accent); }
  .btn.lang { padding: 6px 14px; }
  .stack { gap: 12px; }
  .setting { min-height: 52px; }
}
/* phones in landscape: short screens */
@media (max-height: 500px) {
  .screen { padding: 16px 16px; }
  h1.title { margin: 4px 0 2px; font-size: clamp(24px, 5vw, 36px); }
  .tagline { margin-bottom: 8px; font-size: 15px; }
  .stack { margin: 8px 0; gap: 8px; }
  .screen-title .stack, .screen-pause .stack, .screen-over .stack, .screen-victory .stack { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .screen-pause .stack .btn, .screen-over .stack .btn, .screen-victory .stack .btn { flex: 1 1 40%; }
  /* the overlay (#ui) scrolls, not the card: an inner scroll box clipped the title's language buttons */
  .screen { max-height: none; overflow: visible; }
  .screen-title .logo { width: 60px !important; height: 64px !important; margin-bottom: 4px; } /* the canvas sets an inline size */
  .screen-title .langs { margin-top: 4px; }
  .screen-title { padding-top: 8px; padding-bottom: 8px; } /* 844 × 390: the whole title fits, no scroll bar */
  .fine { margin-top: 8px; }
}
/* narrow phones: the title's language row always fits and stays above the home indicator */
@media (max-width: 560px) {
  .screen-title .langs .btn.lang { min-width: 52px; flex: 0 0 auto; }
  .screen-title { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
/* Settings → Enemy density (10-v4-war.md): value + label, the mobile note on its own line */
.setting.density { flex-wrap: wrap; }
.setting.density .v { width: auto; min-width: 96px; margin-left: auto; white-space: nowrap; }
.setting.density .note { flex-basis: 100%; text-align: right; font-size: 12px; }
/* portrait rotate hint (BG.Touch.rotateHint toggles .on while playing) */
#rotate {
  position: fixed; inset: 0; z-index: 50; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 20px;
  padding: 24px; text-align: center; background: rgba(0, 0, 0, .92); color: var(--text);
}
#rotate.on { display: flex; }
#rotate p { max-width: 280px; font-size: 17px; font-weight: 600; color: var(--accent-soft); }
.rotate-phone {
  width: 54px; height: 92px; border: 3px solid var(--accent-text); border-radius: 12px;
  box-shadow: 0 0 24px rgba(36, 86, 232, .5);
  animation: rotate-phone 2.4s ease-in-out infinite;
}
@keyframes rotate-phone {
  0%, 25% { transform: rotate(0deg); }
  55%, 85% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) { .rotate-phone { animation: none; transform: rotate(-90deg); } }
@media (orientation: landscape) { #rotate.on { display: none; } }

/* iPhone tip: Add to Home Screen for full screen (js/ui/fullscreen.js) */
.fs-tip { position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); transform: translateX(-50%); z-index: 60;
  max-width: min(92vw, 420px); padding: 10px 40px 10px 14px; border-radius: 10px; background: rgba(11,15,26,.95);
  border: 1px solid rgba(122,162,255,.32); color: #E8EEFB; font: 13px/1.4 Inter, system-ui, sans-serif; }
.fs-tip button { position: absolute; top: 2px; right: 2px; width: 36px; height: 36px; border: 0; background: transparent;
  color: #93A0BB; font-size: 18px; cursor: pointer; }
