/* ÇAĞLAR — app shell, HUD and menu styles.
   Visual language: dark walnut & leather panels, gold trim, parchment tooltips,
   Cinzel for titles/numbers, Nunito for UI text. No CSS filters/backdrop-filters (§15.1). */

:root {
  --walnut-0: #0d0804;
  --walnut-1: #1b1009;
  --walnut-2: #2a180c;
  --walnut-3: #3b2414;
  --walnut-4: #533320;
  --gold-0: #4e3110;
  --gold-1: #8a5f22;
  --gold-2: #c99a3e;
  --gold-3: #e8c25f;
  --gold-4: #f6dc8c;
  --gold-5: #fff4cc;
  --parch-1: #f6e9c8;
  --parch-2: #e4cd9c;
  --ink: #2b1a0e;
  --ink-2: #6b4a22;
  --text: #f4e8cf;
  --text-2: #d2bd95;
  --text-3: #a08a66;
  --red: #e2503a;
  --red-2: #ff8f74;
  --green: #8fd16b;
  --amber: #f2ad45;
  --food: #ffb26b;
  --wood: #d8a46a;
  --gold: #ffd94f;
  --stone: #cfd3d8;
  --p0: #ff5a4e;
  --p1: #5b95ff;
  --p2: #c07bff;
  --p3: #4fd46a;
  --pad-t: max(6px, env(safe-area-inset-top));
  --pad-r: max(6px, env(safe-area-inset-right));
  --pad-b: max(6px, env(safe-area-inset-bottom));
  --pad-l: max(6px, env(safe-area-inset-left));
  --f-title: 'Cinzel', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --f-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ring-gold: 0 0 0 1px #0b0603, 0 0 0 2.5px #b98a35, 0 0 0 3.5px #0b0603;
  --bevel: inset 0 1px 0 rgba(255, 236, 190, 0.22), inset 0 -2px 4px rgba(0, 0, 0, 0.45);
  --walnut-bg: linear-gradient(180deg, rgba(255, 228, 170, 0.06), rgba(0, 0, 0, 0.25)), var(--tex-walnut, linear-gradient(#3b2516, #22140b));
  --leather-bg: linear-gradient(180deg, rgba(255, 220, 160, 0.05), rgba(0, 0, 0, 0.2)), var(--tex-leather, linear-gradient(#2a190d, #1b1008));
  --inset: inset 0 0 0 1px rgba(0, 0, 0, 0.65), inset 0 2px 7px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 222, 150, 0.16);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  position: fixed; inset: 0; margin: 0; padding: 0; overflow: hidden;
  overscroll-behavior: none; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  background: #1a120b; color: var(--text); font-family: var(--f-ui); font-size: 14px;
}
canvas { touch-action: none; display: block; }
img { pointer-events: none; -webkit-user-drag: none; }
button { font: inherit; color: inherit; border: 0; margin: 0; padding: 0; background: none; cursor: pointer; touch-action: manipulation; -webkit-appearance: none; appearance: none; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid var(--gold-4); outline-offset: 2px; }
.scroll-y { overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; overflow: hidden; background: #0d0905; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; }
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; overflow: hidden; }
#screens { position: absolute; inset: 0; z-index: 20; pointer-events: none; overflow: hidden; }

.ico { display: block; background: center / contain no-repeat; }
.glyph { background: center / contain no-repeat; }

/* ------------------------------------------------------------------------------------------ panels */
.panel {
  background: var(--walnut-bg);
  background-size: auto, 256px 256px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.5), inset 0 0 0 2px rgba(30, 16, 7, 0.9),
    inset 0 0 0 3px rgba(201, 154, 62, 0.28), inset 0 3px 12px rgba(0, 0, 0, 0.45),
    0 0 0 1px #0b0603, 0 4px 14px rgba(0, 0, 0, 0.55);
}
.panel-strip {
  background: var(--walnut-bg);
  background-size: auto, 256px 256px;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.45), inset 0 -2px 0 rgba(0, 0, 0, 0.35), 0 0 0 1px #0b0603, 0 3px 8px rgba(0, 0, 0, 0.5);
  border-radius: 10px;
}
.parchment {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(140, 95, 40, 0.12)), var(--tex-parch, linear-gradient(#f4e6c4, #dcc48f));
  background-size: auto, 192px 192px;
  color: var(--ink);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(110, 72, 30, 0.55), inset 0 0 14px rgba(120, 80, 30, 0.25), 0 0 0 1px #3b2410, 0 6px 18px rgba(0, 0, 0, 0.55);
}

/* ------------------------------------------------------------------------------------------ buttons */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 46px; padding: 0 22px; border-radius: 12px;
  font: 700 16px/1 var(--f-title); letter-spacing: 0.04em;
  transition: transform 0.08s ease, box-shadow 0.12s ease;
}
.btn .ico { width: 20px; height: 20px; flex: none; }
.btn-primary {
  color: #2a1606;
  background: linear-gradient(180deg, #fff0b8 0%, #f2cf6c 30%, #d6a23d 62%, #a8711f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), inset 0 -3px 0 rgba(90, 50, 10, 0.45), 0 0 0 1px #3b220a, 0 0 0 3px rgba(26, 14, 5, 0.85), 0 5px 12px rgba(0, 0, 0, 0.55);
  text-shadow: 0 1px 0 rgba(255, 245, 210, 0.6);
}
.btn-secondary {
  color: var(--gold-4);
  background: var(--walnut-bg);
  background-size: auto, 256px 256px;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.55), var(--bevel), 0 0 0 1px #0b0603, 0 4px 10px rgba(0, 0, 0, 0.5);
  text-shadow: 0 1px 0 #000;
}
.btn-small { min-height: 44px; padding: 0 14px; font-size: 13px; }
.btn-danger { color: #ffc6b8; }
.btn-danger-primary { background: linear-gradient(180deg, #ffb39e 0%, #e5664c 40%, #a8321d 100%); color: #2a0b04; }
.btn.is-down { transform: translateY(2px) scale(0.97); }
.btn-primary.is-down { box-shadow: inset 0 2px 6px rgba(90, 50, 10, 0.55), 0 0 0 1px #3b220a, 0 0 0 3px rgba(26, 14, 5, 0.85), 0 2px 5px rgba(0, 0, 0, 0.5); }
.btn-secondary.is-down { box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.7), inset 0 3px 8px rgba(0, 0, 0, 0.6), 0 0 0 1px #0b0603; }

.ibtn {
  position: relative; width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 35%, #4d311b, #22140a 70%);
  box-shadow: var(--ring-gold), 0 3px 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s;
}
.ibtn .ico { position: absolute; inset: 11px; }
.ibtn.is-down { transform: scale(0.92); }

/* ========================================================================================== HUD */
.hud-layer {
  position: absolute; inset: 0; pointer-events: none;
  /* compact info box: 140 px when the bar has room, shrinking to 112 px before the panel would overflow */
  --btn: 44px; --rbtn: 48px; --mm-w: 120px; --mm-h: 64px; --info-w: 140px; --info-min: 112px; --gap: 6px; --sp-pad: 4px;
}
.hud-layer.is-regular { --btn: 48px; --rbtn: 56px; --mm-w: 136px; --mm-h: 72px; --info-w: 156px; --info-min: 156px; --sp-pad: 2px; }
.safe-probe { position: absolute; visibility: hidden; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* ---- top bar */
.hud-top { position: absolute; top: var(--pad-t); left: var(--pad-l); right: var(--pad-r); height: 36px; display: flex; align-items: flex-start; gap: 5px; }
.hb {
  position: relative; pointer-events: auto; width: 40px; height: 36px; border-radius: 10px; flex: none;
  background: var(--walnut-bg); background-size: auto, 256px 256px;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.5), 0 0 0 1px #0b0603, 0 3px 8px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s;
}
.hb::after { content: ''; position: absolute; inset: -4px -2px -8px -4px; }
.hb .ico { position: absolute; inset: 2px 4px; }
.hb.is-down { transform: scale(0.92); }
.topbar { display: flex; align-items: center; height: 36px; padding: 0 4px; pointer-events: auto; }
.chip { position: relative; display: flex; align-items: center; gap: 4px; height: 36px; padding: 0 3px; flex: none; }
.topbar .chip + .chip::before { content: ''; position: absolute; left: -1px; top: 8px; bottom: 8px; width: 1px; background: linear-gradient(transparent, rgba(255, 220, 150, 0.28), transparent); }
.chip .ico { width: 20px; height: 20px; flex: none; }
.chip .num { font: 700 14px/1 var(--f-title); color: var(--text); text-shadow: 0 1px 0 #000, 0 0 4px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip-res { width: 60px; }
.chip-res .num.is-long { font-size: 12.5px; transform: scaleX(0.94); transform-origin: 0 50%; }
.chip-res .num.is-xlong { transform: scaleX(0.76); }
.chip-pop { width: 78px; }
.chip-pop .num.is-long { font-size: 12.5px; transform: scaleX(0.94); transform-origin: 0 50%; } /* "99/100", "100/100" stay clear of the faith icon */
.chip-faith { width: 58px; }
.chip-age { min-width: 34px; padding-right: 4px; }
.chip-age .ico { width: 24px; height: 24px; }
.age-name { display: none; font: 700 13px/1 var(--f-title); color: var(--gold-4); white-space: nowrap; text-shadow: 0 1px 0 #000; }
.is-regular .age-name { display: block; }
.chip .cbar { position: absolute; left: 6px; right: 6px; bottom: 3px; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, 0.55); overflow: hidden; }
.chip .cbar .fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); transition: transform 0.1s linear; }
.chip-faith .fill { background: linear-gradient(90deg, #f7d36b, #fff3b0); }
.chip-age .cbar { display: none; }
.chip-age.is-aging .cbar { display: block; }
.chip-age .fill { background: linear-gradient(90deg, #8fd16b, #d6f5a8); }
.chip-pop.is-capped .num { color: #ff7d66; }
.chip.is-flash { animation: chip-flash 0.7s ease 2; }
@keyframes chip-flash { 0%, 100% { background: transparent; } 50% { background: rgba(226, 80, 58, 0.55); border-radius: 8px; } }
.topright { margin-left: auto; display: flex; gap: 5px; pointer-events: none; }
.chip-peace, .chip-clock { padding: 0 9px; pointer-events: auto; }
.chip-peace .ico { width: 20px; height: 20px; }
.chip-peace .num { color: #e9f2d0; font-size: 13px; }
.chip-clock .num { font-size: 14px; color: var(--gold-4); }
.chip-fps { position: absolute; top: calc(var(--pad-t) + 40px); right: var(--pad-r); height: 22px; padding: 0 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); }
.chip-fps .num { font: 700 12px/1 var(--f-ui); color: #b8f59a; }

/* ---- message column */
.hud-msgs { position: absolute; top: calc(var(--pad-t) + 42px); left: 50%; transform: translateX(-50%); width: min(60%, 520px); display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; }
.banner {
  pointer-events: auto; max-width: 100%; padding: 7px 16px; border-radius: 9px; text-align: center;
  font: 700 13px/1.25 var(--f-ui); color: var(--gold-5); text-shadow: 0 1px 0 #000;
  background: rgba(20, 11, 5, 0.86); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.45), 0 3px 10px rgba(0, 0, 0, 0.5);
}
.banner-ls {
  position: absolute; left: var(--pad-l); right: var(--pad-r); top: calc(var(--pad-t) + 41px); max-width: none; width: auto; padding: 6px 16px;
  font: 700 14px/1.2 var(--f-title); letter-spacing: 0.02em; color: #fff1e8;
  background: linear-gradient(90deg, rgba(110, 16, 8, 0.2), rgba(150, 24, 12, 0.92) 20%, rgba(150, 24, 12, 0.92) 80%, rgba(110, 16, 8, 0.2));
  box-shadow: inset 0 1px 0 rgba(255, 180, 160, 0.5), inset 0 -1px 0 rgba(0, 0, 0, 0.6), 0 3px 10px rgba(0, 0, 0, 0.5);
  border-radius: 4px; animation: pulse-red 1.6s ease-in-out infinite;
}
.banner-ls.is-enemy { background: linear-gradient(90deg, rgba(90, 60, 10, 0.2), rgba(120, 86, 20, 0.92) 20%, rgba(120, 86, 20, 0.92) 80%, rgba(90, 60, 10, 0.2)); animation: none; color: var(--gold-5); }
.hud-layer:has(.banner-ls:not([hidden])) .hud-msgs { top: calc(var(--pad-t) + 80px); }
.hud-layer.is-ended { opacity: 0; visibility: hidden; transition: opacity 0.4s ease, visibility 0s 0.4s; }
.banner-tc { color: #fff; background: linear-gradient(180deg, #c3341f, #8d1d10); box-shadow: inset 0 0 0 1px rgba(255, 190, 170, 0.6), 0 3px 10px rgba(0, 0, 0, 0.5); animation: pulse-red 1.2s ease-in-out infinite; }
.banner-mode { pointer-events: none; color: var(--gold-4); }
.banner-mode.is-bad { color: #ffb4a0; box-shadow: inset 0 0 0 1px rgba(255, 120, 100, 0.65), 0 3px 10px rgba(0, 0, 0, 0.5); }
@keyframes pulse-red { 0%, 100% { opacity: 1; } 50% { opacity: 0.82; } }

.toasts { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.toast {
  pointer-events: none; display: flex; align-items: center; gap: 8px; max-width: 100%;
  padding: 6px 14px 6px 8px; border-radius: 20px;
  font: 700 13px/1.25 var(--f-ui); color: var(--text); text-shadow: 0 1px 0 #000;
  background: linear-gradient(180deg, rgba(48, 30, 16, 0.95), rgba(24, 14, 7, 0.95));
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.45), 0 4px 12px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: translateY(-8px) scale(0.96); transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.toast.is-tap { pointer-events: auto; }
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(-6px); transition: opacity 0.2s, transform 0.2s; }
.toast.is-bump { animation: bump 0.3s ease; }
@keyframes bump { 40% { transform: scale(1.06); } }
.toast .ico { width: 24px; height: 24px; flex: none; }
.toast .toast-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toast-good { box-shadow: inset 0 0 0 1px rgba(255, 222, 120, 0.85), 0 0 12px rgba(246, 210, 100, 0.25), 0 4px 12px rgba(0, 0, 0, 0.55); color: var(--gold-5); }
.toast-warn { box-shadow: inset 0 0 0 1px rgba(242, 173, 69, 0.85), 0 4px 12px rgba(0, 0, 0, 0.55); color: #ffe1b0; }
.toast-alert { background: linear-gradient(180deg, rgba(140, 26, 12, 0.96), rgba(84, 12, 5, 0.96)); box-shadow: inset 0 0 0 1px rgba(255, 150, 130, 0.8), 0 4px 14px rgba(0, 0, 0, 0.6); color: #fff1ec; }
.toast-miss { display: flex; gap: 2px; }
.toast-miss .ico { width: 22px; height: 22px; }

/* ---- edge arrow (off-screen attack) */
.edge-arrow { position: absolute; left: -24px; top: -24px; width: 48px; height: 48px; pointer-events: auto; z-index: 3; }
.edge-arrow::before {
  content: ''; position: absolute; inset: 4px; border-radius: 50% 50% 50% 8%;
  background: radial-gradient(circle at 40% 40%, #e65a3f, #8f1c0e);
  box-shadow: 0 0 0 2px #2a0a04, 0 0 14px rgba(255, 80, 50, 0.6);
  transform: rotate(calc(var(--ang, 0rad) + 135deg));
}
.edge-arrow .ico { position: absolute; inset: 13px; }
.edge-arrow { animation: edge-pulse 0.9s ease-in-out infinite; }
@keyframes edge-pulse { 50% { opacity: 0.75; } }

/* ---- age flourish */
.age-flourish { position: absolute; left: 0; right: 0; top: 30%; text-align: center; pointer-events: none; opacity: 0; }
.age-flourish small { display: block; font: 700 14px/1 var(--f-title); letter-spacing: 0.3em; color: var(--gold-4); text-transform: uppercase; text-shadow: 0 2px 4px #000; }
.age-flourish span { display: inline-block; margin-top: 6px; font: 900 clamp(30px, 8vh, 54px)/1 var(--f-title); letter-spacing: 0.06em; color: var(--gold-5); text-shadow: 0 2px 0 #4a2a08, 0 4px 16px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 210, 100, 0.45); }
.age-flourish.is-on { animation: flourish 2.8s ease forwards; }
@keyframes flourish { 0% { opacity: 0; transform: scale(0.8); } 12% { opacity: 1; transform: scale(1.04); } 20% { transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: scale(1.02); } }

/* ---- bottom: minimap */
.minimap-frame {
  position: absolute; left: var(--pad-l); bottom: var(--pad-b); width: var(--mm-w); height: var(--mm-h);
  pointer-events: auto; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 50%, #15100a 55%, #0b0703 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.55), inset 0 0 0 2px #120a04, inset 0 0 0 3px rgba(201, 154, 62, 0.3), 0 0 0 1px #0b0603, 0 4px 12px rgba(0, 0, 0, 0.55);
}
.minimap-frame::before, .minimap-frame::after { content: ''; position: absolute; width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff1b8, #b98a35 60%, #4e3110); top: 4px; }
.minimap-frame::before { left: 4px; }
.minimap-frame::after { right: 4px; }
.minimap { display: block; touch-action: none; }

/* ---- selection panel */
.selpanel {
  position: absolute; bottom: var(--pad-b);
  left: calc(var(--pad-l) + var(--mm-w) + var(--gap));
  right: calc(var(--pad-r) + var(--rbtn) + var(--gap));
  display: flex; flex-direction: column; align-items: flex-start; pointer-events: none;
}
.sp-body {
  pointer-events: auto; position: relative; display: flex; align-items: stretch; gap: 6px; max-width: 100%;
  height: calc(var(--btn) * 2 + 4px + var(--sp-pad) * 2); padding: var(--sp-pad); padding-right: calc(var(--btn) + var(--sp-pad) + 4px);
  border-radius: 12px; background: var(--walnut-bg); background-size: auto, 256px 256px;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.5), inset 0 3px 10px rgba(0, 0, 0, 0.4), 0 0 0 1px #0b0603, 0 0 0 2.5px rgba(185, 138, 53, 0.75), 0 0 0 3.5px #0b0603, 0 5px 14px rgba(0, 0, 0, 0.55);
}
.sp-info { position: relative; width: var(--info-w); flex: 0 1 auto; display: flex; flex-direction: column; gap: 3px; padding: 4px 5px 3px 4px; min-width: var(--info-min); border-radius: 9px; background: var(--leather-bg); background-size: auto, 128px 128px; box-shadow: var(--inset); }
.sp-head { display: flex; gap: 6px; align-items: center; min-width: 0; }
.p-wrap { position: relative; flex: none; }
.portrait { display: block; width: 38px; height: 38px; border-radius: 8px; background: center / contain no-repeat; }
.is-regular .portrait { width: 44px; height: 44px; }
.portrait.is-res { background-size: 82%; background-color: rgba(0, 0, 0, 0.35); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.45); }
.p-badge { position: absolute; right: -5px; bottom: -4px; padding: 1px 4px; border-radius: 7px; font: 800 12px/1.1 var(--f-ui); color: #fff; background: #1d120a; box-shadow: 0 0 0 1px rgba(255, 222, 150, 0.6); }
.p-badge:empty { display: none; }
.p-idle { position: absolute; left: -3px; top: -6px; padding: 1px 4px; border-radius: 5px; font: 900 12px/1.1 var(--f-ui); color: #2a0b04; background: #ffb43c; box-shadow: 0 0 0 1px #3b1d04; animation: pulse-red 1s infinite; }
.sp-titles { min-width: 0; flex: 1; }
.sp-name { font: 700 13px/1.15 var(--f-title); color: var(--gold-4); text-shadow: 0 1px 0 #000; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: normal; word-break: normal; hyphens: none; }
.sp-name.is-long { font-size: 11px; letter-spacing: -0.01em; } /* set by the HUD when a word would not fit: never split a word */
.sp-sub { font: 700 12px/1.2 var(--f-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.sp-hp { display: flex; align-items: center; gap: 4px; }
.hpbar { position: relative; flex: 1; height: 7px; border-radius: 4px; overflow: hidden; background: #160c05; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 222, 150, 0.25); }
.hpbar .fill { position: absolute; inset: 0; transform-origin: 0 50%; background: linear-gradient(180deg, #a7ec7a, #4f9e2c); transition: transform 0.12s linear; }
.hpbar.is-mid .fill { background: linear-gradient(180deg, #ffe07a, #c99a1e); }
.hpbar.is-low .fill { background: linear-gradient(180deg, #ff8a6c, #c0301b); }
.hp-text { font: 700 12px/1 var(--f-ui); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-compact .hp-text { font-size: 11px; }
.sp-line { font: 700 12px/1.2 var(--f-ui); color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-line.has-ico { padding-left: 18px; background: var(--ico) 0 50% / 16px 16px no-repeat; }
.sp-stats { display: flex; gap: 7px; font: 700 12px/1 var(--f-title); color: var(--text); }
.sp-stats .st { display: flex; align-items: center; gap: 2px; }
.sp-stats .glyph { width: 14px; height: 14px; display: block; }
.sp-grid { display: grid; grid-template-columns: repeat(var(--cols, 5), var(--btn)); grid-auto-rows: var(--btn); gap: 4px; align-content: center; }
.sp-close {
  position: absolute; top: var(--sp-pad); right: var(--sp-pad); width: var(--btn); height: var(--btn); border-radius: 9px;
  background: linear-gradient(180deg, #3b2414, #1c1008); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.4), 0 0 0 1px #0b0603;
  transition: transform 0.08s;
}
.sp-close .ico { position: absolute; inset: 12px; }
.sp-close.is-down { transform: scale(0.9); }
.sp-body:not(.has-grid) { padding-right: calc(var(--btn) + var(--sp-pad) + 4px); }
.sp-body:not(.has-grid) .sp-info { width: auto; min-width: var(--info-w); max-width: min(270px, 42vw); padding-bottom: 6px; }
.sp-body:not(.has-grid) { height: auto; min-height: calc(var(--btn) + var(--sp-pad) * 2 + 8px); } /* info-only: no empty grid rows */

/* ---- action buttons */
.ab {
  position: relative; width: var(--btn); height: var(--btn); border-radius: 9px; overflow: visible;
  background: #1d120a; box-shadow: 0 0 0 1px #0b0603, 0 2px 0 #0b0603, 0 3px 5px rgba(0, 0, 0, 0.45);
  transition: transform 0.07s ease;
}
.ab .ico { position: absolute; inset: 0; border-radius: 9px; background-size: 100% 100%; }
.ab::after { content: ''; position: absolute; inset: 0; border-radius: 9px; pointer-events: none; background: transparent; transition: background 0.15s; }
.ab .ab-cost {
  position: absolute; left: 1px; right: 1px; bottom: 1px; display: flex; justify-content: center; gap: 2px; z-index: 2;
  font: 800 12px/1 var(--f-ui); letter-spacing: -0.4px; text-shadow: 0 1px 0 #000, 0 0 3px #000, 0 0 2px #000; pointer-events: none;
  padding: 7px 0 2px; border-radius: 0 0 8px 8px; background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.82) 55%);
}
.ab .ab-cost:empty { display: none; }
.c-food { color: var(--food); }
.c-wood { color: var(--wood); }
.c-gold { color: var(--gold); }
.c-stone { color: var(--stone); }
.c.is-miss { color: #ff6b55; }
.ab-badge { position: absolute; right: -4px; top: -5px; z-index: 3; padding: 1px 4px; border-radius: 7px; font: 800 12px/1.1 var(--f-ui); color: #fff; background: #2a1a0e; box-shadow: 0 0 0 1px rgba(255, 222, 150, 0.6); }
.ab-badge:empty { display: none; }
.ab-glyph { position: absolute; right: 1px; top: 1px; width: 18px; height: 18px; z-index: 2; display: none; }
.ab.is-toggle .ab-glyph { display: block; border-radius: 50%; background-color: rgba(20, 10, 4, 0.85); background-size: 14px; box-shadow: 0 0 0 1px rgba(255, 222, 150, 0.5); }
.ab.is-danger.has-glyph .ab-glyph { display: block; right: -3px; top: -3px; width: 20px; height: 20px; border-radius: 50%; background-color: #8a1a0b; background-size: 14px; box-shadow: 0 0 0 1.5px #2a0a04, 0 1px 3px rgba(0, 0, 0, 0.6); }
.ab-lock { position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -14px 0 0 -10px; z-index: 3; display: none; }
.ab.is-off::after { background: rgba(12, 7, 3, 0.55); }
.ab.is-locked::after { background: rgba(12, 7, 3, 0.68); }
.ab.is-locked .ab-lock { display: block; }
.ab.is-locked .ab-cost { opacity: 0.6; }
.ab.is-warn::before { content: '!'; position: absolute; left: -4px; top: -5px; z-index: 3; width: 16px; height: 16px; border-radius: 50%; background: var(--amber); color: #2a1404; font: 900 12px/16px var(--f-ui); text-align: center; box-shadow: 0 0 0 1px #3b1d04; }
.ab.is-busy::after { background: rgba(12, 7, 3, 0.45); }
.ab.is-busy .ab-lock { display: none; }
.ab.is-active { box-shadow: 0 0 0 1px #0b0603, 0 0 0 3px #e8c25f, 0 0 10px rgba(246, 210, 100, 0.6); }
.ab.is-toggle:not(.is-active)::after { background: rgba(12, 7, 3, 0.5); }
.ab.is-toggle:not(.is-active) .ab-glyph { opacity: 0.55; }
.ab.is-armed { box-shadow: 0 0 0 1px #0b0603, 0 0 0 3px #e5533c, 0 0 12px rgba(255, 80, 50, 0.7); animation: pulse-red 0.6s infinite; }
.ab.is-down { transform: translateY(1px) scale(0.92); }
.ab.is-down::after { background: rgba(255, 230, 160, 0.16); }

/* ---- production queue strip */
.queue-strip { pointer-events: auto; display: flex; gap: 4px; margin: 0 0 7px 2px; padding: 3px; border-radius: 10px; background: var(--leather-bg); background-size: auto, 128px 128px; box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.35), 0 0 0 1px #0b0603, 0 3px 8px rgba(0, 0, 0, 0.45); }
.qi { position: relative; width: 44px; height: 44px; border-radius: 8px; background: #1d120a; box-shadow: 0 0 0 1px #0b0603; transition: transform 0.07s; }
.qi .ico { position: absolute; inset: 0; border-radius: 8px; }
.qi .qi-bar { position: absolute; left: 3px; right: 3px; bottom: 3px; height: 5px; border-radius: 3px; background: rgba(0, 0, 0, 0.7); overflow: hidden; display: none; }
.qi-first .qi-bar { display: block; }
.qi .qi-bar .fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(90deg, #8fd16b, #e3f7b8); transition: transform 0.1s linear; }
.qi .qi-x { position: absolute; right: -4px; top: -4px; width: 16px; height: 16px; border-radius: 50%; background-color: #3a0f06; background-size: 10px; box-shadow: 0 0 0 1px rgba(255, 170, 150, 0.6); }
.qi:not(.qi-first)::after { content: ''; position: absolute; inset: 0; border-radius: 8px; background: rgba(10, 6, 3, 0.35); }
.qi .qi-wait { position: absolute; left: -4px; right: -4px; top: 14px; text-align: center; white-space: nowrap; font: 900 12px/1 var(--f-ui); color: #ffd2c4; text-shadow: 0 1px 0 #000, 0 0 4px #000; transform: scaleX(0.8); pointer-events: none; }
.qi.is-waiting { box-shadow: 0 0 0 1px #0b0603, 0 0 0 2.5px #e5533c; }
.qi.is-waiting .qi-bar .fill { background: linear-gradient(90deg, #e5533c, #ff9a7c); }
.qi.is-down { transform: scale(0.92); }

/* ---- right column, mode buttons */
.rightcol, .modecol { position: absolute; right: var(--pad-r); bottom: var(--pad-b); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.rb, .mb {
  position: relative; pointer-events: auto; width: var(--rbtn); height: var(--rbtn); border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #5a3a20, #24150a 72%);
  box-shadow: var(--ring-gold), 0 4px 10px rgba(0, 0, 0, 0.55);
  transition: transform 0.08s ease;
}
.rb .ico { position: absolute; inset: 4px; border-radius: 50%; }
.rb.is-down, .mb.is-down { transform: scale(0.9); }
.rb-badge { position: absolute; right: -4px; top: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; font: 900 12px/20px var(--f-ui); text-align: center; color: #fff; background: linear-gradient(180deg, #e65a3f, #a5260f); box-shadow: 0 0 0 1.5px #2a0a04; }
.rb-badge:empty { display: none; }
.rb.has-idle { animation: idle-glow 1.6s ease-in-out infinite; }
@keyframes idle-glow { 50% { box-shadow: var(--ring-gold), 0 0 14px rgba(255, 210, 110, 0.75); } }
.rb-pow.has-ready .rb-dot { display: block; min-width: 12px; width: 12px; height: 12px; padding: 0; right: 0; top: 0; background: radial-gradient(circle at 40% 35%, #fff6c8, #f2c34a 60%, #9a6a12); box-shadow: 0 0 0 1.5px #2a1404, 0 0 8px rgba(255, 220, 120, 0.9); }
.rb.is-active { box-shadow: 0 0 0 1px #0b0603, 0 0 0 3px #f6dc8c, 0 0 14px rgba(246, 210, 100, 0.65); }
.modecol { gap: 10px; }
.mb { width: 56px; height: 56px; }
.mb .ico { position: absolute; inset: 14px; }
.mb-ok { background: radial-gradient(circle at 50% 30%, #3f6b26, #172a0c 75%); }
.mb-no { background: radial-gradient(circle at 50% 30%, #7a2a1a, #2c0c05 75%); }
.mb.is-off { background: radial-gradient(circle at 50% 30%, #4a443c, #1b1814 75%); box-shadow: 0 0 0 1px #0b0603, 0 0 0 2.5px #6d6352, 0 0 0 3.5px #0b0603, 0 4px 10px rgba(0, 0, 0, 0.55); }
.mb.is-off .ico { opacity: 0.35; }

/* ---- power bar */
.powerbar { position: absolute; bottom: var(--pad-b); right: calc(var(--pad-r) + var(--rbtn) + 10px); display: flex; gap: 6px; padding: 6px; pointer-events: auto; animation: pop-in 0.16s ease; transform-origin: 100% 50%; }
@keyframes pop-in { from { opacity: 0; transform: scale(0.9) translateX(10px); } }
.pw { position: relative; width: 52px; height: 52px; border-radius: 10px; background: #160d06; box-shadow: 0 0 0 1px #0b0603, 0 2px 4px rgba(0, 0, 0, 0.5); transition: transform 0.07s; }
.pw .ico { position: absolute; inset: 0; border-radius: 10px; }
.pw .pw-cd { position: absolute; inset: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center; font: 700 15px/1 var(--f-title); color: #fff; text-shadow: 0 1px 2px #000; background: conic-gradient(rgba(8, 4, 2, 0.74) calc(var(--cd, 0) * 360deg), transparent 0); }
.pw .pw-cost { position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); padding: 1px 6px; border-radius: 8px; font: 800 12px/1.15 var(--f-ui); color: #2a1606; background: linear-gradient(180deg, #fff1b8, #e0b04a); box-shadow: 0 0 0 1px #3b220a; z-index: 2; }
.pw::after { content: ''; position: absolute; left: 4px; right: 4px; bottom: 3px; height: 3px; border-radius: 2px; background: #ffe48a; transform-origin: 0 50%; transform: scaleX(var(--fp, 0)); opacity: 0; }
.pw.is-poor::after { opacity: 1; }
.pw.is-off::before { content: ''; position: absolute; inset: 0; border-radius: 10px; background: rgba(10, 6, 3, 0.5); }
.pw.is-ready { box-shadow: 0 0 0 1px #0b0603, 0 0 0 2.5px #e8c25f, 0 0 12px rgba(246, 210, 100, 0.55); }
.pw .pw-lock { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -13px 0 0 -11px; display: none; z-index: 1; }
.pw.is-locked .pw-lock { display: block; }
.pw.is-locked::before { background: rgba(10, 6, 3, 0.68); }
.pw.is-down { transform: scale(0.92); }

/* ---- tooltip */
.tooltip { position: absolute; left: 0; top: 0; z-index: 30; width: max-content; max-width: min(260px, 70vw); padding: 9px 12px 10px; pointer-events: none; animation: tt-in 0.12s ease; }
@keyframes tt-in { from { opacity: 0; } }
.tt-title { font: 700 15px/1.15 var(--f-title); color: #3a1f08; }
.tt-sub { font: 700 12px/1.2 var(--f-ui); color: var(--ink-2); }
.tt-desc { margin-top: 3px; font: 600 12.5px/1.3 var(--f-ui); color: #3b2512; }
.tt-cost { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.tt-c { display: flex; align-items: center; gap: 3px; font: 800 13px/1 var(--f-ui); color: #3a240f; }
.tt-c .ico { width: 18px; height: 18px; }
.tt-c.is-miss { color: #b3240e; }
.tt-time { color: var(--ink-2); }
.tt-req { margin-top: 5px; font: 800 12px/1.2 var(--f-ui); color: #a3260f; }
.tt-extra { margin-top: 4px; font: 700 12px/1.25 var(--f-ui); color: var(--ink-2); }

/* ---- input overlays */
.lp-ring { position: absolute; left: -30px; top: -30px; width: 60px; height: 60px; border-radius: 50%; pointer-events: none; z-index: 5; }
.lp-ring::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgba(255, 228, 140, 0.95); box-shadow: 0 0 12px rgba(255, 210, 110, 0.7), inset 0 0 10px rgba(255, 210, 110, 0.4); }
.lp-ring.is-on::before { animation: ring-in 0.22s ease-out; }
@keyframes ring-in { from { transform: scale(0.4); opacity: 0; } }
.box-sel { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 5; border: 1.5px dashed rgba(255, 228, 140, 0.95); background: rgba(255, 220, 120, 0.1); border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45); }

/* ---- guided tips */
.tip-arrow { position: absolute; left: -18px; top: -40px; width: 36px; height: 36px; pointer-events: none; z-index: 27; animation: tip-bounce 0.9s ease-in-out infinite; }
.tip-arrow .ico { width: 100%; height: 100%; }
.tip-arrow.is-up { top: 6px; }
.tip-arrow.is-up .ico { transform: rotate(180deg); }
@keyframes tip-bounce { 50% { margin-top: -8px; } }
.tip-arrow.is-up { animation-name: tip-bounce-up; }
@keyframes tip-bounce-up { 50% { margin-top: 8px; } }
.tip-bubble { position: absolute; left: 0; top: 0; z-index: 26; width: min(280px, 46vw); padding: 7px 10px 9px; pointer-events: none; }
.tip-bubble.is-in { animation: tt-in 0.25s ease; }
.tip-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.tip-ico { width: 18px; height: 18px; flex: none; display: block; }
.tip-count { font: 700 12px/1 var(--f-title); color: var(--ink-2); }
.tip-skip { position: relative; pointer-events: auto; margin-left: auto; display: flex; align-items: center; gap: 4px; min-height: 32px; padding: 0 4px 0 10px; border-radius: 8px; font: 800 12px/1 var(--f-ui); color: #5a3a1a; }
.tip-skip::after { content: ''; position: absolute; inset: -8px -8px -6px -10px; }
.tip-skip .ico { width: 16px; height: 16px; }
.tip-skip.is-down { background: rgba(90, 58, 26, 0.15); }
.tip-text { font: 700 13px/1.3 var(--f-ui); color: #33200d; }

/* ---- HUD in modes */
.hud-layer.is-mode .selpanel { display: none; }

/* ========================================================================================== screens */
#screens > .backdrop, #screens > .vignette { position: absolute; inset: 0; pointer-events: none; }
.backdrop { background: radial-gradient(ellipse at 50% 40%, #3a2a16, #120b05 75%); }
.demo-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.vignette { background: radial-gradient(ellipse at 50% 45%, rgba(10, 6, 2, 0) 30%, rgba(10, 6, 2, 0.55) 70%, rgba(6, 3, 1, 0.9) 100%), linear-gradient(180deg, rgba(8, 4, 1, 0.45), rgba(8, 4, 1, 0) 30%, rgba(8, 4, 1, 0) 60%, rgba(8, 4, 1, 0.6)); }
#screens[data-backdrop='none'] > .backdrop, #screens[data-backdrop='none'] > .vignette,
#screens[data-backdrop='end'] > .backdrop { display: none; }
#screens[data-backdrop='end'] > .vignette { background: radial-gradient(ellipse at 50% 35%, rgba(30, 18, 8, 0.82), rgba(6, 3, 1, 0.94) 75%); }
#screens[data-backdrop='dark'] > .backdrop { background: radial-gradient(ellipse at 50% 40%, #2c1d0e, #0b0703 80%); }
.base-layer, .modal-layer { position: absolute; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; opacity: 0; transition: opacity 0.25s ease; padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l); display: flex; align-items: stretch; justify-content: center; }
.screen.is-in { opacity: 1; }
.screen.is-out { opacity: 0; pointer-events: none; }

.boot-splash, .loading-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: radial-gradient(ellipse at 50% 40%, #2c1d0e, #0b0703 80%); pointer-events: auto; }
.loading-wrap { background: transparent; position: relative; inset: auto; width: 100%; }
.game-title {
  margin: 0; position: relative; isolation: isolate;
  font: 900 clamp(44px, 14vh, 84px)/1.22 var(--f-title); letter-spacing: 0.08em; color: #f6d77a;
}
.game-title > span {
  background: linear-gradient(180deg, #fffbe6 0%, #f8de8a 35%, #d9a23d 62%, #f3cf72 78%, #9a6418 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;
}
.game-title::before {
  content: attr(data-text); position: absolute; left: 0; top: 0; z-index: -1; white-space: nowrap;
  -webkit-text-fill-color: #2a1505; color: #2a1505;
  text-shadow: 0 2px 0 #1a0c03, 0 4px 0 #120803, 0 10px 24px rgba(0, 0, 0, 0.9), 0 0 40px rgba(255, 200, 90, 0.25);
}
.game-sub { display: flex; align-items: center; gap: 12px; font: 700 clamp(14px, 4.2vh, 20px)/1 var(--f-title); letter-spacing: 0.22em; color: var(--text-2); text-shadow: 0 2px 4px #000; text-transform: uppercase; }
.game-sub .orn { width: 40px; height: 2px; background: linear-gradient(90deg, transparent, var(--gold-2), transparent); }
.progress { position: relative; width: min(340px, 64vw); height: 10px; margin-top: 18px; border-radius: 6px; overflow: hidden; background: #140b05; box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.45), 0 0 0 1px #000, 0 2px 8px rgba(0, 0, 0, 0.6); }
.progress-fill { position: absolute; inset: 2px; border-radius: 4px; transform-origin: 0 50%; transform: scaleX(0); background: linear-gradient(180deg, #fff1b8, #e0b04a 55%, #a8711f); transition: transform 0.15s linear; }
.loading-label { font: 700 13px/1 var(--f-ui); color: var(--text-3); letter-spacing: 0.04em; min-height: 14px; }

/* ---- main menu */
.menu-wrap { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 4vh, 26px); }
/* soft dark pool behind the title & buttons so they stay legible over the live demo match */
.menu-wrap::before { content: ''; position: absolute; left: 50%; top: 50%; width: min(760px, 96vw); height: 100%; transform: translate(-50%, -50%); background: radial-gradient(ellipse at 50% 46%, rgba(10, 6, 2, 0.62) 0%, rgba(10, 6, 2, 0.38) 42%, rgba(10, 6, 2, 0) 72%); pointer-events: none; }
.menu-wrap > * { position: relative; }
.menu-wrap > .menu-foot { position: absolute; }
.menu-titles { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.menu-titles .game-title { font-size: clamp(48px, 17vh, 96px); }
.menu-buttons { display: flex; flex-direction: column; align-items: stretch; gap: 10px; width: min(280px, 60vw); }
.btn-play { min-height: 56px; font-size: 22px; }
.menu-buttons .btn-secondary { min-height: 44px; font-size: 15px; }
.menu-record { display: flex; gap: 8px; font: 700 13px/1 var(--f-ui); color: var(--text-2); text-shadow: 0 1px 2px #000; }
.menu-record .dot { color: var(--gold-2); }
.menu-foot { position: absolute; left: 4px; right: 4px; bottom: 2px; display: flex; align-items: flex-end; justify-content: space-between; }
.version { font: 700 12px/1 var(--f-ui); color: var(--text-3); text-shadow: 0 1px 2px #000; }
.lang-toggle { display: flex; min-height: 44px; align-items: center; padding: 3px; border-radius: 10px; background: rgba(20, 11, 5, 0.85); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.45); }
.lang-toggle span { padding: 8px 10px; border-radius: 7px; font: 800 13px/1 var(--f-ui); color: var(--text-3); }
.lang-toggle span.is-on { background: linear-gradient(180deg, #fff0b8, #d6a23d); color: #2a1606; }

/* ---- install ("Telefona Yükle"): bottom-left corner group, mirrors the language toggle */
/* the foot strip spans the screen width: only its corner groups take taps (never the menu buttons above) */
.menu-foot { pointer-events: none; }
.menu-foot > * { pointer-events: auto; }
.menu-foot-l, .menu-install { pointer-events: none; }
.menu-foot-l > *, .menu-install > * { pointer-events: auto; }
.menu-foot-l { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.menu-install { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; max-width: calc(50vw - 150px - var(--pad-l)); }
.btn-install { gap: 7px; padding: 0 12px 0 10px; font-size: 12px; white-space: nowrap; }
.btn-install .ico { width: 22px; height: 22px; }
.install-hint { position: relative; display: flex; align-items: flex-start; gap: 2px; width: min(220px, 100%); padding: 7px 4px 8px 10px; animation: hint-in 0.45s ease 0.9s both; }
.install-hint::after { content: ''; position: absolute; left: 22px; bottom: -6px; width: 12px; height: 12px; transform: rotate(45deg); background: #e2cd9c; box-shadow: 1px 1px 0 #3b2410; }
.install-hint.is-out { opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; }
.install-hint-text { flex: 1; min-width: 0; text-align: left; font: 800 12.5px/1.3 var(--f-ui); color: #33200d; }
.install-hint-close { position: relative; flex: none; width: 24px; height: 24px; border-radius: 6px; }
.install-hint-close::after { content: ''; position: absolute; inset: -10px -8px -10px -8px; } /* ≥ 40 px touch target */
.install-hint-close .ico { position: absolute; inset: 5px; }
.install-hint-close.is-down { background: rgba(90, 58, 26, 0.18); }
@keyframes hint-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) {
  .btn-install { width: 44px; padding: 0; }
  .btn-install .btn-label { display: none; }
  .menu-install { max-width: calc(50vw - 146px); }
}

/* install sheet */
.inst-panel { width: min(660px, 100%); max-height: 100%; padding: 10px 16px 12px; display: flex; flex-direction: column; gap: 8px; }
.inst-head { display: flex; align-items: center; gap: 10px; flex: none; }
.inst-head .screen-title { flex: 1; min-width: 0; font-size: clamp(18px, 5.6vh, 24px); }
.inst-head-ico { width: 26px; height: 26px; flex: none; }
.inst-close { width: 40px; height: 40px; }
.inst-close::after { content: ''; position: absolute; inset: -4px; }
.inst-close .ico { inset: 11px; }
.inst-lead { margin: 0; font: 700 13.5px/1.35 var(--f-ui); color: var(--text); }
.inst-steps { margin: 0; padding: 0; list-style: none; display: flex; gap: 10px; flex: none; }
.inst-step { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 10px 10px; border-radius: 12px; text-align: center; background: rgba(12, 7, 3, 0.55); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.22); }
.inst-num { display: inline-block; width: 20px; height: 20px; margin-right: 6px; vertical-align: 1px; border-radius: 50%; font: 700 11.5px/20px var(--f-title); text-align: center; color: #2a1606; background: linear-gradient(180deg, #fff1b8, #d6a23d); box-shadow: 0 0 0 1px #2a1606; }
.inst-art { align-self: stretch; height: 46px; display: flex; align-items: center; justify-content: center; }
.inst-step-text { font: 800 13.5px/1.25 var(--f-ui); color: var(--gold-4); }
.inst-step-sub { font: 600 12px/1.3 var(--f-ui); color: var(--text-2); }
/* mocks of the platform UI: light keys, menu rows and dialog buttons */
.inst-key { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 11px; background: linear-gradient(180deg, #ffffff, #e9e9ee); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.45); }
.inst-glyph { display: block; width: 26px; height: 26px; flex: none; background: center / contain no-repeat; }
.inst-row { display: flex; align-items: center; gap: 8px; max-width: 100%; min-height: 40px; padding: 4px 10px; border-radius: 10px; background: #fbfbfd; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.45); font: 600 13px/1.1 -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif; color: #1c1c1e; white-space: nowrap; }
.inst-row span { white-space: normal; text-align: left; line-height: 1.15; }
.inst-row.is-ios { gap: 14px; padding: 0 10px 0 12px; }
.inst-row .inst-glyph { width: 22px; height: 22px; }
.inst-pill { display: flex; align-items: center; justify-content: center; min-width: 72px; min-height: 36px; padding: 0 14px; border-radius: 18px; background: #fbfbfd; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.45); font: 700 14px/1 -apple-system, system-ui, 'Segoe UI', Roboto, sans-serif; }
.inst-pill.is-ios { font-weight: 600; font-size: 15px; }
.inst-url { padding: 6px 10px; border-radius: 8px; background: rgba(12, 7, 3, 0.85); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.3); font: 700 12.5px/1.3 ui-monospace, Menlo, Consolas, monospace; color: var(--gold-4); word-break: break-all; -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.inst-note { margin: 0; font: 600 12px/1.35 var(--f-ui); color: var(--text-3); }
.inst-btns { display: flex; justify-content: flex-end; gap: 10px; flex: none; }
.inst-btns .btn { min-height: 44px; }
.btn-inst-copy { gap: 8px; }
@media (max-height: 380px) {
  .inst-panel { padding: 8px 14px 10px; gap: 6px; }
  .inst-step { padding: 8px 8px 8px; gap: 4px; }
  .inst-art { height: 42px; }
  .inst-key { width: 40px; height: 40px; }
  .inst-lead { font-size: 13px; }
}
@media (max-width: 600px) {
  .inst-steps { gap: 6px; }
  .inst-step-sub { font-size: 11.5px; }
  .inst-row { font-size: 12px; padding: 0 8px; }
}

/* ---- shared screen chrome */
.screen-head { display: flex; align-items: center; gap: 12px; height: 46px; flex: none; margin-bottom: 6px; padding-left: 2px; }
.screen-head .btn-back { width: 40px; height: 40px; }
.screen-head .btn-back::after { content: ''; position: absolute; inset: -4px; } /* 48 px touch target */
.screen-head .btn-back .ico { inset: 10px; }
.screen-title { margin: 0; font: 700 clamp(18px, 6vh, 26px)/1 var(--f-title); letter-spacing: 0.06em; color: var(--gold-4); text-shadow: 0 2px 0 #1a0d04, 0 3px 10px rgba(0, 0, 0, 0.7); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; border-radius: 11px; background: rgba(12, 7, 3, 0.85); box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 222, 150, 0.3); }
.seg-item { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; min-width: 44px; padding: 0 12px; border-radius: 8px; font: 800 13px/1 var(--f-ui); color: var(--text-2); transition: background 0.15s, color 0.15s, transform 0.07s; }
.seg-item .ico { width: 22px; height: 22px; }
.seg-item.is-on { color: #2a1606; background: linear-gradient(180deg, #fff1bd, #f0c862 45%, #c18a2c); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.6); }
.seg-item.is-down { transform: scale(0.95); }
.seg-item { position: relative; }
.seg-item::after { content: ''; position: absolute; inset: -4px -1.5px; } /* hit area reaches the track edges (≥ 44 px) */
.row { display: flex; align-items: center; gap: 10px; min-height: 46px; }
.row-label { width: 92px; flex: none; font: 800 13px/1.15 var(--f-ui); color: var(--text-2); text-shadow: 0 1px 0 #000; }
.row-ctl { flex: 1; min-width: 0; display: flex; align-items: center; }
.slider { position: relative; flex: 1; max-width: 220px; height: 44px; touch-action: none; cursor: pointer; }
.slider::before { content: ''; position: absolute; left: 0; right: 0; top: 19px; height: 6px; border-radius: 3px; background: #120a04; box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.3); }
.slider-fill { position: absolute; left: 0; right: 0; top: 19px; height: 6px; border-radius: 3px; transform-origin: 0 50%; background: linear-gradient(90deg, #a8711f, #f6dc8c); }
.slider-knob { position: absolute; top: 10px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff6d0, #e3b54d 60%, #8a5f22); box-shadow: 0 0 0 1px #2a1606, 0 2px 5px rgba(0, 0, 0, 0.6); }

/* ---- setup */
.setup-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: 900px; }
.setup-body { flex: 1; min-height: 0; display: flex; gap: 12px; align-items: stretch; padding-bottom: 2px; }
.civ-cards { display: flex; flex-direction: column; gap: 10px; flex: 0.9; min-width: 0; }
.civ-card {
  position: relative; flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-columns: auto 1fr; grid-template-rows: repeat(4, auto); align-content: center;
  column-gap: 10px; row-gap: 3px; padding: 10px 12px 8px 10px; text-align: left; overflow: hidden;
  border-radius: 14px; background: var(--walnut-bg); background-size: auto, 256px 256px;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.4), 0 0 0 1px #0b0603, 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease, box-shadow 0.15s;
}
.civ-card.is-on { box-shadow: inset 0 0 0 1px rgba(255, 235, 170, 0.9), 0 0 0 1px #0b0603, 0 0 0 3.5px #e8c25f, 0 0 22px rgba(246, 210, 100, 0.4), 0 6px 14px rgba(0, 0, 0, 0.6); transform: translateY(-2px); }
.civ-card.is-down { transform: scale(0.98); }
.civ-emblem { grid-row: 1 / span 4; align-self: center; display: block; width: 58px; height: 58px; background: center / contain no-repeat; }
.civ-name { font: 700 clamp(15px, 5vh, 20px)/1.05 var(--f-title); color: var(--gold-4); text-shadow: 0 1px 0 #000; }
.civ-desc { font: italic 600 12px/1.25 var(--f-ui); color: var(--text-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.civ-bonus { margin: 2px 0 0; padding: 0 0 0 2px; list-style: none; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow: hidden; }
.civ-bonus li { position: relative; padding-left: 13px; font: 700 12px/1.2 var(--f-ui); color: var(--text-2); }
.civ-bonus li::before { content: ''; position: absolute; left: 1px; top: 5px; width: 5px; height: 5px; transform: rotate(45deg); background: var(--gold-2); }
.civ-unique { display: flex; align-items: center; gap: 6px; padding-top: 4px; border-top: 1px solid rgba(255, 222, 150, 0.18); font: 800 12px/1.1 var(--f-ui); color: var(--gold-4); }
.civ-unique .ico { width: 26px; height: 26px; flex: none; }
.setup-side { flex: 1.2; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.seg { flex-wrap: nowrap; }
.setup-opts { padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; flex: 1; min-height: 0; }
.setup-opts.panel { background: var(--leather-bg); background-size: auto, 128px 128px; }
.setup-opts .row { min-height: 44px; }
.setup-opts .row-label { width: 76px; }
.setup-opts .seg-item { min-height: 38px; padding: 0 10px; }
.btn-start { min-height: 50px; font-size: 20px; flex: none; }

/* ---- modals */
.modal { position: absolute; inset: 0; pointer-events: auto; display: flex; align-items: center; justify-content: center; padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l); opacity: 0; transition: opacity 0.18s ease; }
.modal.is-in { opacity: 1; }
.modal.is-out { opacity: 0; pointer-events: none; }
.modal-dim { background: rgba(8, 4, 1, 0.62); }
.modal-solid { background: radial-gradient(ellipse at 50% 40%, #2c1d0e, #0b0703 80%); }
.modal > * { transform: translateY(8px) scale(0.98); transition: transform 0.22s cubic-bezier(0.2, 1.3, 0.4, 1); }
.modal.is-in > * { transform: none; }
.pause-panel { width: min(420px, 92vw); max-height: 100%; padding: 14px 18px 16px; display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.pause-panel .screen-title { text-align: center; }
.pause-meta { display: flex; justify-content: center; gap: 8px; font: 700 13px/1 var(--f-ui); color: var(--text-3); }
.pause-meta .dot { color: var(--gold-2); }
.btn-resume { min-height: 50px; font-size: 19px; }
.pause-panel .row-label { width: 86px; }
.pause-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pause-grid .btn { min-height: 44px; padding: 0 10px; font-size: 13px; }
/* min-width:0 — without it the flex item's min-content width (card track) overrides max-width and pushes the screen off-canvas on narrow phones */
.settings-wrap, .howto-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; max-width: 760px; }
.settings-wrap { max-width: 880px; }
.modal-settings .settings-wrap { width: min(880px, 100%); height: 100%; }
.modal-howto .howto-wrap { width: min(760px, 100%); height: 100%; }
.modal-deep { background: radial-gradient(ellipse at 50% 40%, rgba(30, 18, 8, 0.9), rgba(6, 3, 1, 0.96) 80%); }
.settings-body { flex: 1; min-height: 0; display: flex; gap: 12px; align-items: flex-start; padding: 2px 2px 6px; }
.set-card { flex: 1 1 0; min-width: 0; padding: 8px 14px 8px; display: flex; flex-direction: column; }
.set-h { display: flex; align-items: center; gap: 8px; margin: 0 0 2px; padding: 2px 0 7px; border-bottom: 1px solid rgba(255, 222, 150, 0.2); font: 700 15px/1 var(--f-title); letter-spacing: 0.1em; color: var(--gold-3); text-transform: uppercase; text-shadow: 0 1px 0 #000; }
.set-h .ico { width: 20px; height: 20px; flex: none; }
.set-card .row { min-height: 50px; }
.set-card .row + .row { border-top: 1px solid rgba(255, 222, 150, 0.08); }
.set-card .row-label { width: 108px; }
.settings-hint { margin: -1px 0 6px; padding-left: 118px; font: 600 12px/1.25 var(--f-ui); color: var(--text-3); }
.confirm-panel { width: min(400px, 90vw); padding: 18px 20px 16px; text-align: center; }
.confirm-text { margin: 0 0 14px; font: 700 15px/1.35 var(--f-ui); color: var(--text); }
.confirm-btns { display: flex; justify-content: center; gap: 12px; }
.confirm-btns .btn { min-height: 44px; font-size: 14px; padding: 0 16px; }
.preparing-panel { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preparing-title { font: 700 24px/1 var(--f-title); letter-spacing: 0.08em; color: var(--gold-4); text-shadow: 0 2px 6px #000; }
.preparing-tip { max-width: min(460px, 80vw); text-align: center; font: 700 13px/1.35 var(--f-ui); color: var(--text-2); }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255, 222, 150, 0.2); border-top-color: var(--gold-3); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast-lite { position: absolute; left: 50%; bottom: 18%; transform: translate(-50%, 10px); padding: 8px 16px; border-radius: 18px; background: rgba(20, 11, 5, 0.92); box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.5); font: 700 13px/1.2 var(--f-ui); color: var(--gold-4); opacity: 0; transition: opacity 0.2s, transform 0.2s; z-index: 50; pointer-events: none; }
.toast-lite.is-in { opacity: 1; transform: translate(-50%, 0); }

/* ---- how to play */
.howto-body { flex: 1; min-height: 0; display: flex; align-items: center; gap: 8px; }
.howto-track { flex: 1; min-width: 0; height: 100%; display: flex; gap: 12px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; touch-action: pan-x; overscroll-behavior: contain; scrollbar-width: none; padding: 4px 2px 8px; }
.howto-track::-webkit-scrollbar { display: none; }
.howto-card { position: relative; flex: 0 0 min(300px, 72vw); scroll-snap-align: center; padding: 38px 14px 12px; display: flex; flex-direction: column; justify-content: flex-start; gap: 8px; }
.howto-num { position: absolute; right: 10px; top: 8px; width: 24px; height: 24px; border-radius: 50%; font: 700 13px/24px var(--f-title); text-align: center; color: #2a1606; background: linear-gradient(180deg, #fff1b8, #d6a23d); }
/* a little iso map plate: grass with a faint diamond grid, darkened rim */
.howto-art {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 84px; padding: 8px 10px; border-radius: 10px; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(0, 0, 0, 0) 40%, rgba(8, 5, 2, 0.75) 100%),
    repeating-linear-gradient(26.57deg, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-26.57deg, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 22px),
    linear-gradient(180deg, #5d7f35, #3f5c22);
  box-shadow: inset 0 0 0 1px rgba(255, 222, 150, 0.35), inset 0 2px 10px rgba(0, 0, 0, 0.5);
}
.art-ico { position: relative; display: block; width: 50px; height: 50px; flex: none; background: center / contain no-repeat; }
.art-ico.art-framed { border-radius: 9px; box-shadow: 0 3px 6px rgba(0, 0, 0, 0.55); }
.art-ico.glyph { width: 32px; height: 32px; }
.art-ico.art-sm { width: 38px; height: 38px; }
.art-flow { display: block; width: 18px; height: 18px; flex: none; opacity: 0.9; animation: art-flow 1.4s ease-in-out infinite; }
@keyframes art-flow { 50% { transform: translateX(3px); opacity: 0.6; } }
.art-tap, .art-tap2 { animation: art-tap 1.6s ease-in-out infinite; }
.art-tap2 { animation-delay: 0.8s; }
.art-tap::after, .art-tap2::after { content: ''; position: absolute; left: 2px; top: -2px; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 236, 160, 0.9); opacity: 0; animation: art-ripple 1.6s ease-out infinite; animation-delay: inherit; }
@keyframes art-tap { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(4px) scale(0.94); } }
@keyframes art-ripple { 35% { opacity: 0; transform: scale(0.4); } 45% { opacity: 1; } 100% { opacity: 0; transform: scale(2.2); } }
.art-ok { animation: art-ok 1.8s ease-in-out infinite; }
@keyframes art-ok { 0%, 60%, 100% { transform: scale(1); } 75% { transform: scale(1.18); } }
.art-pan { animation: art-pan 1.8s ease-in-out infinite; }
.art-pinch { animation: art-pinch 1.6s ease-in-out infinite; }
@keyframes art-pan { 50% { transform: translateX(12px); } }
@keyframes art-pinch { 50% { transform: scale(0.75) rotate(-12deg); } }
/* minimap mock: dark diamond with a pulsing white camera frame */
.art-mm { position: relative; display: block; width: 68px; height: 34px; flex: none; }
.art-mm::before { content: ''; position: absolute; inset: 0; background: #e8c25f; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.art-mm::after { content: ''; position: absolute; inset: 2px 4px; background: linear-gradient(135deg, #8db552 0%, #4f7a2a 45%, #1f2f10 46%, #120a04 100%); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.art-mm b { z-index: 1; }
.art-mm b { position: absolute; left: 22px; top: 9px; width: 18px; height: 11px; border: 1.5px solid #fff; animation: art-mm 2.2s ease-in-out infinite; }
@keyframes art-mm { 50% { transform: translate(10px, 4px); } }
.howto-title { margin: 2px 0 0; font: 700 17px/1.1 var(--f-title); color: var(--gold-4); }
.howto-text { margin: 0; font: 600 13px/1.35 var(--f-ui); color: var(--text); }
.howto-dots { display: flex; justify-content: center; gap: 6px; height: 14px; align-items: center; }
.howto-dots .dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 222, 150, 0.3); }
.howto-dots .dot.is-on { background: var(--gold-3); box-shadow: 0 0 6px rgba(246, 210, 100, 0.7); }

/* ---- end screen */
.end-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; min-height: 0; gap: 8px; max-width: 760px; width: 100%; }
.end-banner { display: flex; flex-direction: column; align-items: center; gap: 2px; flex: none; }
.end-ico { width: 34px; height: 34px; display: block; }
.end-title { margin: 0; font: 900 clamp(28px, 10vh, 50px)/1.05 var(--f-title); letter-spacing: 0.1em; }
.is-win .end-title { color: #ffe08a; text-shadow: 0 3px 0 #5a3a0a, 0 0 26px rgba(255, 210, 100, 0.55), 0 6px 18px rgba(0, 0, 0, 0.9); }
.is-loss .end-title { color: #ffb5a2; text-shadow: 0 3px 0 #4a0f05, 0 0 22px rgba(255, 80, 50, 0.4), 0 6px 18px rgba(0, 0, 0, 0.9); }
.end-sub { font: 700 13px/1.2 var(--f-ui); color: var(--text-2); }
.end-tables { flex: 0 1 auto; min-height: 0; display: flex; gap: 10px; width: 100%; justify-content: center; }
.end-table-wrap { flex: 1 1 0; min-height: 0; max-width: 380px; padding: 4px 12px 6px; }
.end-table { width: 100%; border-collapse: collapse; font: 700 13px/1.15 var(--f-ui); }
.end-table th { padding: 5px 4px; font: 700 13px/1.1 var(--f-title); text-align: right; white-space: nowrap; }
.end-table th.end-group { text-align: left; color: var(--gold-3); letter-spacing: 0.04em; }
.end-table th.pcol span { display: inline-block; max-width: 74px; overflow: hidden; text-overflow: ellipsis; vertical-align: -2px; }
.end-table th .ico { display: inline-block; width: 18px; height: 18px; vertical-align: -4px; margin-right: 4px; }
.end-table td { padding: 3px 4px; border-top: 1px solid rgba(255, 222, 150, 0.1); }
.end-table td.rl { color: var(--text-2); }
.end-table td.rv { text-align: right; font: 700 14px/1.15 var(--f-title); color: var(--text); white-space: nowrap; }
.end-table td.rv small { display: block; font: 700 12px/1.2 var(--f-ui); color: var(--text-3); white-space: nowrap; }
.end-table td.rv small .sep { font-style: normal; margin: 0 3px; color: var(--text-3); }
.end-table td.rl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.end-btns { display: flex; gap: 12px; flex: none; padding-bottom: 2px; }
.end-btns .btn { min-height: 46px; }

/* ---- rotate & fatal overlays */
#rotate { position: fixed; inset: 0; z-index: 100; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: radial-gradient(ellipse at 50% 40%, #2c1d0e, #0b0703 80%); color: var(--gold-4); text-align: center; padding: 24px; touch-action: none; }
@media (orientation: portrait) and (pointer: coarse) { #rotate { display: flex; } }
body.is-portrait #rotate { display: flex; } /* main.js pauses the match exactly while this shows */
.rotate-phone { width: 46px; height: 80px; border-radius: 9px; border: 3px solid var(--gold-3); position: relative; animation: rot 2.4s ease-in-out infinite; }
.rotate-phone span { position: absolute; left: 50%; bottom: 5px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: var(--gold-3); }
@keyframes rot { 0%, 20% { transform: rotate(0); } 50%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.rotate-title { font: 700 22px/1.2 var(--f-title); }
.rotate-text { font: 700 14px/1.3 var(--f-ui); color: var(--text-2); }
#fatal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(6, 3, 1, 0.8); pointer-events: auto; }
.fatal-panel { width: min(560px, 94vw); max-height: 92%; overflow: auto; padding: 16px 18px; border-radius: 12px; background: #1d120a; box-shadow: inset 0 0 0 1px rgba(255, 140, 110, 0.6), 0 8px 24px rgba(0, 0, 0, 0.7); color: var(--text); touch-action: pan-y; }
.fatal-panel h2 { margin: 0 0 6px; font: 700 18px/1.2 var(--f-title); color: #ffb4a0; }
.fatal-panel p { margin: 0 0 8px; font: 600 13px/1.35 var(--f-ui); }
.fatal-panel pre { margin: 0 0 10px; max-height: 140px; overflow: auto; padding: 8px; border-radius: 6px; background: #0b0603; font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #ffd8cc; white-space: pre-wrap; word-break: break-word; -webkit-user-select: text; user-select: text; }
.fatal-count { font: 700 12px/1 var(--f-ui); color: var(--text-3); }
.fatal-btns { display: flex; justify-content: flex-end; gap: 10px; }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: #f6dc8c; font: 700 16px var(--f-ui); }

/* ---- small heights (640×360 class) */
@media (max-height: 380px) {
  .civ-desc { display: none; }
  .screen-head { height: 42px; margin-bottom: 4px; }
  .setup-opts .row { min-height: 40px; }
  .setup-opts .seg-item { min-height: 36px; padding: 0 8px; font-size: 12px; }
  .seg-item .ico { width: 20px; height: 20px; }
  .civ-card { padding: 8px 10px 6px 8px; }
  .civ-emblem { width: 48px; height: 48px; }
  .btn-start { min-height: 46px; }
  .pause-panel { padding: 10px 14px 12px; gap: 6px; }
  .btn-resume { min-height: 46px; }
  .howto-card { padding: 34px 12px 10px; }
  .set-card .row { min-height: 46px; }
}
@media (max-width: 720px) {
  .seg-item .ico { display: none; }
  .end-table td.rv small { display: none; }
  .end-table th.pcol { font-size: 12px; }
  .end-table th.pcol span { max-width: 78px; }
  .end-table th .ico { width: 16px; height: 16px; margin-right: 3px; }
  .end-table td.rl { max-width: 128px; }
  .end-table-wrap { padding: 4px 8px 6px; }
  .set-card { padding: 6px 10px 6px; }
  .set-card .row-label { width: 82px; }
  .settings-hint { padding-left: 92px; }
  .settings-body { gap: 8px; }
  .setup-opts .row-label { width: 64px; }
  .seg-item { padding: 0 9px; }
}

/* ========================================================================================== ONLINE (SPEC §16.6) */
.mp-input {
  -webkit-user-select: text; user-select: text; touch-action: manipulation; -webkit-touch-callout: default;
  min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; outline: none; width: 100%;
  font: 700 16px/1 var(--f-ui); color: var(--text); background: rgba(12, 7, 3, 0.85);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 222, 150, 0.35);
}
.mp-input:focus { box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7), 0 0 0 2px var(--gold-3); }
.mp-code-input { min-height: 58px; text-align: center; text-transform: uppercase; font: 900 30px/1 var(--f-title); letter-spacing: 0.32em; padding-left: calc(12px + 0.32em); }
.mp-code-input::placeholder { color: rgba(210, 189, 149, 0.28); }
.online-wrap, .lobby-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: 900px; width: 100%; }
.online-body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 2px 2px 6px; }
.mp-name-row { display: flex; align-items: center; gap: 12px; padding: 6px 14px; flex: none; }
.mp-name-row .mp-input { max-width: 320px; }
.mp-cards { display: flex; gap: 12px; flex: none; }
.mp-card { flex: 1 1 0; min-width: 0; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 10px; justify-content: space-between; }
.mp-hint { margin: 0; font: 700 13px/1.35 var(--f-ui); color: var(--text-2); }
.mp-error { min-height: 18px; text-align: center; font: 800 13px/1.3 var(--f-ui); color: #ffb4a0; text-shadow: 0 1px 0 #000; }
.lobby-body { flex: 1; min-height: 0; display: flex; gap: 12px; align-items: stretch; padding-bottom: 2px; }
.mp-lobby-side { flex: 0 0 auto; width: min(250px, 34%); padding: 10px 12px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.mp-lobby-side .row { flex-direction: column; align-items: flex-start; gap: 4px; min-height: 0; }
.mp-lobby-side .row-label { width: auto; }
.mp-lobby-side .seg-item { min-height: 36px; padding: 0 9px; }
.mp-code-label { font: 800 12px/1 var(--f-ui); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.12em; text-align: center; }
.mp-code { text-align: center; font: 900 clamp(34px, 12vh, 54px)/1 var(--f-title); letter-spacing: 0.18em; color: #ffe08a; text-shadow: 0 3px 0 #5a3a0a, 0 0 18px rgba(255, 210, 100, 0.4); -webkit-user-select: text; user-select: text; }
.mp-ro { font: 800 14px/1 var(--f-ui); color: var(--text); }
.mp-lobby-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; touch-action: pan-y; overscroll-behavior: contain; }
.mp-seats { display: flex; flex-direction: column; gap: 5px; flex: none; }
.mp-seat { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 4px 12px; }
.mp-seat.is-me { box-shadow: inset 0 0 0 1px rgba(255, 235, 170, 0.85), 0 0 0 1px #0b0603, 0 0 0 2.5px #b98a35; }
.mp-seat.is-open { opacity: 0.6; }
.mp-swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: 0 0 0 1px #000, 0 0 0 2px rgba(255, 222, 150, 0.4); }
.mp-civ { width: 24px; height: 24px; flex: none; }
.mp-seat-name { flex: 1; min-width: 0; font: 800 15px/1.1 var(--f-ui); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-seat-civ { font: 700 12px/1 var(--f-ui); color: var(--text-2); white-space: nowrap; }
.mp-badges { display: flex; align-items: center; gap: 6px; flex: none; }
.mp-crown { width: 18px; height: 18px; }
.mp-ready { font: 800 12px/1 var(--f-ui); padding: 4px 7px; border-radius: 6px; color: var(--text-3); background: rgba(0, 0, 0, 0.4); }
.mp-ready.is-on { color: #1e3b10; background: linear-gradient(180deg, #c8f5a0, #7fcf55); }
.mp-conn { width: 10px; height: 10px; border-radius: 50%; background: #c8452f; box-shadow: 0 0 0 1px #000; }
.mp-conn.is-on { background: #6fdc5a; }
.mp-mine { flex: none; padding: 4px 12px 8px; }
.mp-mine .row { min-height: 44px; }
.mp-mine .row-label { width: 84px; }
.mp-mine .mp-input { max-width: 260px; }
.mp-mine .seg-item { min-height: 36px; }
.mp-colors { display: flex; gap: 10px; }
.mp-color { width: 40px; height: 40px; border-radius: 10px; box-shadow: 0 0 0 1px #000, inset 0 2px 0 rgba(255, 255, 255, 0.35), inset 0 -3px 0 rgba(0, 0, 0, 0.35); position: relative; }
.mp-color::after { content: ''; position: absolute; inset: -3px; }
.mp-color.is-on { box-shadow: 0 0 0 2px #1a0d04, 0 0 0 4.5px #ffe08a, inset 0 2px 0 rgba(255, 255, 255, 0.35); }
.mp-color.is-taken { opacity: 0.25; cursor: default; }
.mp-actions { display: flex; gap: 10px; margin-top: 6px; }
.mp-actions .btn { flex: 1; }
.btn-mp-ready.is-on { color: #c8f5a0; }
.btn.is-disabled, .btn:disabled { opacity: 0.45; cursor: default; }
.mp-status { text-align: center; font: 800 13px/1.3 var(--f-ui); color: var(--text-2); flex: none; }
.mp-status.is-bad { color: #ffb4a0; }
.mp-running { text-align: center; font: 700 12.5px/1.3 var(--f-ui); color: var(--gold-4); }
.end-reason { font: 800 14px/1.25 var(--f-ui); color: var(--gold-5); text-shadow: 0 1px 0 #000; text-align: center; }

/* in-match overlays (js/ui/mp-hud.js) */
.mp-layer { position: absolute; inset: 0; pointer-events: none; }
.mp-net { position: absolute; top: calc(var(--pad-t) + 40px); right: calc(var(--pad-r) + 2px); height: 22px; display: flex; align-items: center; gap: 5px; padding: 0 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); font: 800 12px/1 var(--f-ui); color: var(--text-2); }
.mp-net .mp-dot { width: 8px; height: 8px; border-radius: 50%; background: #888; }
.mp-net.is-good .mp-dot { background: #6fdc5a; }
.mp-net.is-mid .mp-dot { background: #f2c94c; }
.mp-net.is-bad .mp-dot { background: #e2553c; }
.mp-net.is-bad .mp-ping { color: #ffb4a0; }
.mp-banner { position: absolute; top: calc(var(--pad-t) + 42px); left: 50%; transform: translateX(-50%); max-width: min(70%, 560px); color: #fff1e8; background: linear-gradient(180deg, rgba(150, 70, 12, 0.94), rgba(100, 42, 8, 0.94)); animation: pulse-red 1.6s ease-in-out infinite; }
.hud-layer:has(.banner-ls:not([hidden])) ~ .mp-layer .mp-banner { top: calc(var(--pad-t) + 80px); }
.mp-catchup { position: absolute; top: calc(var(--pad-t) + 66px); right: calc(var(--pad-r) + 2px); padding: 3px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); font: 800 12px/1 var(--f-ui); color: var(--gold-4); }
.mp-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8, 4, 1, 0.45); pointer-events: auto; }
.mp-overlay-box { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 26px; max-width: min(420px, 86vw); text-align: center; }
.mp-overlay-title { font: 700 18px/1.1 var(--f-title); color: var(--gold-4); }
.mp-overlay-text { font: 700 13px/1.35 var(--f-ui); color: var(--text-2); }
@media (max-height: 380px) {
  .mp-code-input { min-height: 50px; font-size: 26px; }
  .mp-seat { min-height: 38px; }
  .mp-mine .row { min-height: 42px; }
}
@media (max-height: 340px) {
  .mp-seat { min-height: 34px; padding: 2px 10px; }
  .mp-mine { padding: 2px 10px 6px; }
  .mp-mine .row { min-height: 38px; }
  .mp-mine .seg-item { min-height: 32px; }
  .mp-color { width: 34px; height: 34px; }
  .mp-actions { margin-top: 2px; }
  .mp-actions .btn { min-height: 42px; }
  .mp-code { font-size: 34px; }
  .lobby-wrap .screen-head { height: 40px; margin-bottom: 4px; }
}
