:root {
  --bg: #101a14;
  --panel: rgba(18, 24, 32, 0.88);
  --panel-solid: #161e28;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f1ece2;
  --muted: #a6a39b;
  --gold: #f2c94c;
  --good: #4ade80;
  --bad: #f87171;
  --accent: #60a5fa;
  --prem: #c084fc;
  --haven: #f7efe0;
  --haven-ink: #3b2a20;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; -webkit-user-select: none; user-select: none; touch-action: none; }
#game, #game canvas { position: fixed; inset: 0; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui > .hud { pointer-events: none; } /* full-screen HUD layers must let map clicks through; their children opt back in */
#fps { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 44px); z-index: 98; font: 700 12px/1 Inter, system-ui, sans-serif; padding: 5px 9px; border-radius: 6px; background: rgba(0,0,0,.75); color: #fff; pointer-events: none; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { #fps { top: auto; bottom: calc(env(safe-area-inset-bottom, 0px) + 2px); left: 4px; transform: none; font-size: 10px; padding: 3px 6px; opacity: .85; } .toasts { top: 86px; } } /* phones: keep the timer and menu button clear */
#fps.good { color: #86efac; } #fps.ok { color: #fde047; } #fps.bad { color: #fca5a5; }
.perftoggle { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); cursor: pointer; }
#err { display: none; position: fixed; left: 8px; bottom: 8px; background: #7f1d1d; color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; z-index: 99; max-width: 90vw; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); font-size: 12px; }
.small { font-size: 11px; }
.bad { color: var(--bad); }
.good { color: var(--good); }

/* ---------- buttons ---------- */
.btn { background: linear-gradient(#3f7be0, #2c5cb3); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: 14px; margin: 3px; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.btn:active { transform: translateY(1px); }
.btn.big { padding: 12px 22px; font-size: 16px; width: 100%; margin-top: 10px; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.ghost { background: rgba(255,255,255,.08); }
.btn.good { background: linear-gradient(#34c06a, #1f8f4b); }
.btn.danger { background: linear-gradient(#e05050, #a92e2e); }
.btn.prem { background: linear-gradient(#a56ef0, #7440c8); }
.btn.disabled { opacity: .5; }
.chip { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.chip.alert { border-color: #facc15; color: #facc15; }
.chip.small { font-size: 12px; padding: 3px 8px; margin: 2px; display: inline-block; cursor: pointer; }

/* ---------- menu ---------- */
.menu { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 16px; overflow-y: auto; }
.menu > .menu-card { margin: auto 0; } /* centred when it fits; top-aligned and scrollable when taller than the screen (phones) */
.menu-card { width: min(920px, 100%); text-align: center; }
.logo { font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; font-weight: 900; font-size: clamp(40px, 9vw, 84px); letter-spacing: .06em; color: #f6e7b8; text-shadow: 0 0 24px rgba(139, 92, 246, .55), 0 4px 0 #3b2a20; }
.tagline { color: var(--muted); margin-bottom: 18px; }
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; text-align: left; backdrop-filter: blur(6px); }
.mode h2 { font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; margin: 6px 0; font-size: 28px; }
.mode p { color: #d8d3c8; font-size: 14px; line-height: 1.45; min-height: 60px; }
.micon { font-size: 36px; }
.haven-mode { border-color: rgba(247, 201, 76, .35); }
.siege-mode { border-color: rgba(96, 165, 250, .35); }
.rumble-mode { grid-column: 1 / -1; border-color: rgba(250, 204, 21, .35); }
.rumble-mode .segrow { flex-wrap: wrap; }
.segrow { display: flex; gap: 6px; margin: 6px 0; }
.seg { flex: 1; background: rgba(255,255,255,.06); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px; font-weight: 600; }
.seg.on { background: #2c5cb3; border-color: #60a5fa; }
.seg.locked { opacity: 0.55; }
.profile { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; background: var(--panel); border-radius: 12px; padding: 10px; border: 1px solid var(--line); font-size: 14px; }
@media (max-width: 680px) { .modes { grid-template-columns: 1fr; } .mode p { min-height: 0; } }

/* ---------- shared HUD ---------- */
.hud { position: absolute; inset: 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); background: linear-gradient(rgba(0,0,0,.6), rgba(0,0,0,0)); flex-wrap: wrap; }
.resgroup { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.res { background: rgba(0,0,0,.45); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 14px; white-space: nowrap; }
.res b { font-weight: 800; }
.res.prem { border-color: rgba(192,132,252,.6); cursor: pointer; }
.clock { font-variant-numeric: tabular-nums; }
.toasts { position: absolute; z-index: 6; top: 56px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(520px, 92vw); }
.toast { background: rgba(10,14,20,.88); border: 1px solid var(--line); padding: 7px 14px; border-radius: 10px; font-size: 13px; text-align: center; animation: fadein .2s; }
.toast.warn { border-color: #facc15; color: #fde68a; }
.toast.good { border-color: #4ade80; color: #bbf7d0; }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; } }
.modal { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 16px; z-index: 20; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.modal > .modal-card { margin: auto 0; } /* centred when it fits; scrolls on short phone screens (doctrine picker, result, pause) */
.modal-card { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(520px, 100%); text-align: center; }
.modal-card h1 { font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; font-size: 48px; margin: 0 0 6px; }
.modal-card h1.win { color: #fde68a; }
.modal-card h1.lose { color: #fca5a5; }
.modal-card .row { display: flex; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.stats { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.stats th, .stats td { padding: 5px; border-bottom: 1px solid var(--line); }
.reward { color: var(--gold); font-weight: 700; }
.celebrate { background: var(--haven); color: var(--haven-ink); }
.celebrate .burst { font-size: 40px; }

/* ---------- Siege HUD ---------- */
.bottombar { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,.65) 30%); align-items: end; }
.miniwrap { background: rgba(0,0,0,.6); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.minimap { display: block; width: 240px; height: 120px; cursor: crosshair; }
.infopanel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 13px; min-height: 84px; line-height: 1.45; }
.iname { font-weight: 800; font-size: 15px; }
.queue { display: flex; gap: 4px; margin-top: 4px; align-items: center; flex-wrap: wrap; }
.qitem { background: rgba(255,255,255,.08); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.qitem.active { outline: 1px solid #c084fc; }
.cmdcard { display: grid; grid-template-columns: repeat(4, 74px); gap: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; }
.cbtn { position: relative; height: 58px; background: linear-gradient(#2a3646, #1c2633); color: var(--text); border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 4px; font-size: 11px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.cbtn:hover { border-color: #60a5fa; }
.cbtn.disabled { opacity: .45; }
.clabel { font-weight: 700; line-height: 1.15; }
.uicon { width: 20px; height: 20px; vertical-align: -5px; border-radius: 4px; object-fit: contain; }
.uicon.ibig { width: 32px; height: 32px; vertical-align: -10px; }
.uicon.cico { display: block; width: 20px; height: 20px; margin: 0 auto; }
.cbtn:has(.cico) { padding: 2px 4px; }
.cbtn .clabel { line-height: 1.05; }
.cbtn .csub { margin-top: 1px; line-height: 1.1; }
.qitem .uicon { width: 22px; height: 22px; vertical-align: middle; }
.csub { color: var(--muted); font-size: 10px; margin-top: 2px; }
.ckey { position: absolute; top: 2px; right: 4px; font-size: 9px; color: #93c5fd; }
.cardnote { grid-column: 1 / -1; font-size: 11px; color: var(--muted); padding: 2px; }
.touchbar { position: absolute; right: 10px; top: calc(var(--top-h, 48px) + 6px); display: none; flex-direction: column; gap: 6px; }
.tbtn { background: rgba(0,0,0,.6); color: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.tbtn.on { border-color: #4ade80; color: #bbf7d0; }
@media (pointer: coarse) { .touchbar { display: flex; } }
.midcol { display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; min-width: 0; } /* group bar stacked on the info panel */
.groupbar { align-self: flex-start; display: none; gap: 4px; padding: 3px; background: rgba(0,0,0,.45); border: 1px solid var(--line); border-radius: 10px; }
.gslot { position: relative; width: 46px; height: 46px; padding: 0; background: rgba(0,0,0,.55); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; touch-action: manipulation; cursor: pointer; }
.gslot .gkey { position: absolute; left: 4px; top: 1px; font-size: 10px; font-weight: 700; color: var(--muted); }
.gslot .gnum { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: 800; text-shadow: 0 1px 2px #000; }
.gslot .gimg { width: 30px; height: 30px; object-fit: contain; pointer-events: none; }
.gslot.on { background: linear-gradient(#2a3646, #1c2633); border-color: rgba(147,197,253,.55); }
.gslot.cur { border-color: #4ade80; box-shadow: 0 0 0 1px #4ade80 inset; }
.gslot.add { border-style: dashed; border-color: rgba(125,255,154,.6); color: #bbf7d0; font-size: 22px; }
@media (any-pointer: coarse) { .groupbar { display: flex; } } /* touch: control groups 1-5 (the number keys do the same) */
@media (max-width: 900px) {
  .bottombar { grid-template-columns: 1fr auto; }
  .miniwrap { position: absolute; left: 8px; bottom: calc(100% + 4px); }
  .minimap { width: 160px; height: 80px; }
  .infopanel { min-height: 0; font-size: 12px; }
  .cmdcard { grid-template-columns: repeat(4, 62px); }
  .cbtn { height: 52px; }
  .uicon.cico { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; transform: translate(-50%, -58%); opacity: .3; pointer-events: none; }
  .cbtn .clabel, .cbtn .csub { text-shadow: 0 1px 2px #000; }
}
@media (max-width: 560px) {
  .bottombar { grid-template-columns: 1fr; }
  .infopanel { display: block; min-height: 0; max-height: 74px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; font-size: 11px; padding: 4px 8px; line-height: 1.35; } /* phones: name + HP + why a button is greyed */
  .cmdcard { grid-template-columns: repeat(4, 1fr); }
  .cmdcard.many { grid-template-columns: repeat(5, 1fr); gap: 4px; } /* long build menus: five across keeps it four rows high */
  .cmdcard.many .cbtn { font-size: 10px; padding: 2px; }
}

/* ---------- Haven HUD ---------- */
.haven-top { background: linear-gradient(rgba(30,20,10,.55), rgba(0,0,0,0)); }
.haven .res { background: rgba(247, 239, 224, .92); color: var(--haven-ink); border-color: rgba(59,42,32,.25); }
.haven .res.prem { border-color: #a56ef0; }
.lvl { display: flex; align-items: center; gap: 8px; background: rgba(247,239,224,.92); color: var(--haven-ink); border-radius: 999px; padding: 3px 12px 3px 3px; }
.lvlnum { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(#f7c948, #d99a00); color: #3b2a20; font-weight: 900; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.xpbar { width: 90px; height: 8px; background: rgba(59,42,32,.2); border-radius: 4px; overflow: hidden; }
.xpfill { height: 100%; background: linear-gradient(90deg, #7ddc5a, #34c06a); }
.xptxt { font-size: 11px; font-weight: 700; }
.quests { position: absolute; left: 10px; top: 64px; display: flex; flex-direction: column; gap: 6px; width: min(260px, 60vw); }
.quest { background: rgba(247,239,224,.94); color: var(--haven-ink); border-radius: 12px; padding: 7px 10px; border: 2px solid #e2c48a; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.qname { font-weight: 800; font-size: 13px; }
.qobj { font-size: 12px; }
.havenbar { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: center; gap: 8px; padding: 8px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.hbtn { background: rgba(247,239,224,.95); color: var(--haven-ink); border: 2px solid #e2c48a; border-radius: 14px; padding: 6px 12px; font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; min-width: 70px; box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.hico { font-size: 22px; }
.siegebtn { background: linear-gradient(#3f7be0, #2c5cb3); color: #fff; border-color: #93c5fd; }
.modebar { position: absolute; top: 60px; left: 50%; transform: translateX(-50%); background: rgba(247,239,224,.95); color: var(--haven-ink); border-radius: 12px; padding: 4px 10px; display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 13px; }
.modebar:empty { display: none; }
.sheet { position: absolute; left: 50%; transform: translateX(-50%); bottom: 86px; width: min(640px, 96vw); max-height: 55vh; overflow-y: auto; background: var(--haven); color: var(--haven-ink); border-radius: 16px; border: 2px solid #e2c48a; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.sheet.hidden { display: none; }
.sheet .muted { color: #7a6a5a; }
.sheethead { display: flex; justify-content: space-between; align-items: flex-start; padding: 12px 14px 6px; position: sticky; top: 0; z-index: 2; background: var(--haven); } /* above .card.locked (opacity makes its own stack) */
.sheettitle { font-weight: 900; font-size: 17px; font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; }
.xbtn { background: none; border: none; font-size: 18px; color: var(--haven-ink); }
.sheetbody { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.card { background: #fff; color: var(--haven-ink); border: 2px solid #e2c48a; border-radius: 12px; padding: 8px; text-align: left; font-size: 12px; }
.card.locked { opacity: .55; }
.card.royal { border-color: #a56ef0; background: #faf5ff; }
.ctitle { font-weight: 800; font-size: 13px; }
.cicon { font-size: 26px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.timerrow { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-weight: 700; }
.person { display: flex; gap: 10px; align-items: center; }
.pface, .dface { width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 2px solid #e2c48a; display: flex; align-items: center; justify-content: center; font-size: 24px; flex: none; }
.dialog { position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px; width: min(560px, 94vw); background: var(--haven); color: var(--haven-ink); border: 2px solid #e2c48a; border-radius: 16px; padding: 12px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.45); z-index: 10; }
.dialog .btn { flex: none; white-space: nowrap; }
.dialog > div:nth-child(2) { min-width: 0; }
.dname { font-weight: 900; font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; }
.dtext { font-size: 14px; line-height: 1.4; }
@media (max-width: 560px) { .quests { top: 100px; width: 46vw; } .quest .qobj { font-size: 11px; } .hbtn { min-width: 56px; padding: 5px 6px; font-size: 11px; } }

.pface, .dface { overflow: hidden; }
.pface .portrait, .dface .portrait { width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; display: block; }
.dface { width: 64px; height: 64px; }

/* ---------- Doctrines: CP bar, calldowns, picker ---------- */
.docbar { position: absolute; left: 8px; top: calc(var(--top-h, 46px) + 6px); display: flex; gap: 6px; align-items: stretch; background: var(--panel); border: 1px solid rgba(250, 204, 21, .45); border-radius: 12px; padding: 6px; }
.docbar:empty { display: none; }
.doctoggle { flex: none; width: 26px; background: rgba(0,0,0,.3); color: #fde68a; border: 1px solid rgba(250, 204, 21, .35); border-radius: 8px; font-size: 14px; padding: 0; cursor: pointer; }
.docbar.collapsed { padding: 4px; gap: 4px; }
.docbar.collapsed .docinfo { min-width: 0; flex-direction: row; align-items: center; gap: 6px; }
.docbar.collapsed .doc-emblem { margin-right: 0; }
.docready { color: #4ade80; font-weight: 700; }
/* touch: keep the bar clear of the Army / Box / Queue / Base column; phones get slimmer calldown buttons */
@media (pointer: coarse) { .docbar { max-width: calc(100% - 112px); } .doctoggle { width: 34px; min-height: 32px; } }
@media (pointer: coarse) and (max-width: 560px), (pointer: coarse) and (max-height: 480px) { .docbar .docinfo small { display: none; } .docbar:not(.collapsed) .docinfo { min-width: 72px; } .docbar .cdbtn { width: 56px; } .docbar .cdname { font-size: 9px; } }
.docinfo { font-size: 11px; min-width: 104px; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.docinfo b { font-size: 12px; color: #fde68a; }
.pips { display: flex; gap: 3px; }
.pip { width: 12px; height: 12px; transform: rotate(45deg); border: 1px solid #facc15; background: transparent; border-radius: 2px; }
.pip.on { background: #facc15; box-shadow: 0 0 6px rgba(250, 204, 21, .7); }
.cdbtn { position: relative; width: 78px; background: linear-gradient(#3a3218, #241f10); color: var(--text); border: 1px solid rgba(250, 204, 21, .5); border-radius: 8px; padding: 4px; font-size: 10px; display: flex; flex-direction: column; align-items: center; gap: 1px; }
.cdbtn.disabled { opacity: .45; }
.cdicon { font-size: 18px; }
.cdname { font-weight: 700; line-height: 1.1; text-align: center; }
.cdcost { color: #fde68a; font-variant-numeric: tabular-nums; }
.doctrine-pick { width: min(760px, 100%); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin: 12px 0; text-align: left; }
.doc-card { background: linear-gradient(#2a3646, #1c2633); color: var(--text); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.doc-card:not(.locked):hover { border-color: #facc15; }
.doc-card.locked { opacity: .5; }
.doc-name { font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; font-weight: 700; font-size: 16px; }
.doc-tag { color: #fde68a; font-size: 12px; }
@media (max-width: 900px) { .cdbtn { width: 64px; } .docinfo { min-width: 84px; } }

/* soft cinematic vignette over the battlefield (pointer-transparent) */
.hud > .vignette { position: absolute; inset: 0; pointer-events: none; z-index: 0; background: radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 55%, rgba(4,8,12,0.38) 100%); }

/* ---- Key art (Higgsfield, art/ART-MANIFEST.md) ---- */
.menu { background: #0b1016; }
/* slow cinematic drift on the key art (sits under the menu video; .menu-shade supplies the gradient) */
.menu::before { content: ''; position: fixed; inset: -4%; z-index: 0; pointer-events: none; background: url('../ui/menu-bg.jpg') center 30% / cover no-repeat; animation: menuDrift 38s ease-in-out infinite alternate; }
@keyframes menuDrift { from { transform: scale(1) translate3d(0, 0, 0); } to { transform: scale(1.07) translate3d(-1.2%, -0.8%, 0); } }
@media (prefers-reduced-motion: reduce) { .menu::before { animation: none; } }
.menu > .menu-video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; opacity: 0; transition: opacity .8s; pointer-events: none; z-index: 0; }
.menu > .menu-video.on { opacity: 1; }
.menu > .menu-shade { position: fixed; inset: 0; pointer-events: none; z-index: 0; background: linear-gradient(180deg, rgba(6,10,16,.30) 0%, rgba(6,10,16,.55) 55%, rgba(6,10,16,.88) 100%); }
.menu > .menu-card { position: relative; z-index: 1; }
.menu .logo { text-shadow: 0 3px 18px rgba(0,0,0,.75); }
.menu .mode { background: rgba(10,15,22,.74); }
.loading-screen { position: absolute; inset: 0; z-index: 50; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 12px; padding: 0 16px 9vh;
  background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(4,8,12,.9) 100%), url('../ui/loading-bg.jpg') center / cover no-repeat; transition: opacity .45s; }
.loading-screen.done { opacity: 0; pointer-events: none; }
.ls-title { font-family: 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; font-weight: 700; letter-spacing: .12em; font-size: clamp(18px, 3vw, 30px); text-shadow: 0 2px 12px #000; }
.ls-bar { width: min(520px, 90vw); height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; }
.ls-fill { height: 100%; width: 40%; background: linear-gradient(90deg, #3b82f6, #93c5fd); animation: lsmove 1.1s ease-in-out infinite alternate; }
@keyframes lsmove { from { margin-left: 0; } to { margin-left: 60%; } }
.ls-tip { max-width: 620px; text-align: center; font-size: 14px; color: #cbd5e1; text-shadow: 0 1px 6px #000; }
.comms { position: absolute; left: 8px; bottom: calc(196px + env(safe-area-inset-bottom, 0px)); display: flex; gap: 10px; align-items: center; width: min(420px, calc(100vw - 16px));
  background: rgba(8,12,18,.88); border: 1px solid rgba(59,130,246,.55); border-radius: 12px; padding: 8px; animation: fadein .25s; transition: opacity .35s; pointer-events: none; }
.comms.enemy { border-color: rgba(239,68,68,.6); }
/* emote wheel (Siege vs bot): 2x2 picker under the topbar, and the emote that pops over the battlefield */
.emotewheel { position: absolute; z-index: 7; top: calc(52px + env(safe-area-inset-top, 0px)); right: 8px; display: grid; grid-template-columns: repeat(2, 64px); gap: 6px; padding: 8px;
  background: var(--panel, rgba(15,20,28,.88)); border: 1px solid var(--line, rgba(255,255,255,.14)); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.emote-b { position: relative; width: 64px; height: 64px; padding: 4px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: inherit; font-size: 11px; cursor: pointer; }
.emote-b:hover, .emote-b:focus-visible { background: rgba(255,255,255,.12); }
.emote-b img { width: 100%; height: 100%; object-fit: contain; }
.emote-k { position: absolute; right: 3px; bottom: 1px; font-size: 10px; opacity: .7; }
.emote-pop { position: absolute; z-index: 6; left: 50%; top: 22%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; pointer-events: none; animation: emotein .35s cubic-bezier(.2,1.6,.4,1); transition: opacity .4s, transform .4s; }
.emote-pop img { width: 112px; height: 112px; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.55)); }
.emote-who { margin-top: 2px; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: rgba(15,20,28,.8); }
.emote-pop.done { opacity: 0; transform: translateX(-50%) translateY(-14px); }
@keyframes emotein { from { transform: translateX(-50%) scale(.3); opacity: 0; } to { transform: translateX(-50%) scale(1); opacity: 1; } }
@media (max-width: 560px) { .emotewheel { top: calc(86px + env(safe-area-inset-top, 0px)); } .emote-pop img { width: 88px; height: 88px; } }
.comms.done { opacity: 0; }
.comms img { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex: none; border: 1px solid rgba(255,255,255,.2); }
.comms .cname { font-size: 12px; font-weight: 700; color: #93c5fd; }
.comms.enemy .cname { color: #fca5a5; }
.comms .ctext { font-size: 13px; line-height: 1.35; }
.comms .clist { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.35; }
.comms .clist li + li { margin-top: 2px; }
.doc-face { width: 100%; height: 104px; object-fit: cover; object-position: 50% 18%; border-radius: 8px; margin-bottom: 4px; }
.doc-face.none { display: flex; align-items: center; justify-content: center; height: 40px; font-size: 20px; background: rgba(255,255,255,.05); }
.doctrine-pick { max-height: calc(100vh - 32px); overflow-y: auto; }
.modal.result { background-size: cover; background-position: center; }
.modal.result.won { background-image: linear-gradient(rgba(4,8,12,.25), rgba(4,8,12,.6)), url('../ui/victory-bg.jpg'); }
.modal.result.lost { background-image: linear-gradient(rgba(4,8,12,.25), rgba(4,8,12,.6)), url('../ui/defeat-bg.jpg'); }
.modal.result .modal-card { background: rgba(10,15,22,.82); backdrop-filter: blur(4px); }

/* ---- Haven v2 (gameplay UI) ---- */
.haven .res.full { background: #fee2e2; border-color: #ef4444; }
.res small { opacity: .7; font-size: 11px; }
.quest .qobj.done { color: #136f34; }
.quest .muted { color: #6b5a48; } /* readable on the cream card (the global muted grey is for dark panels) */
.quest.chapter { cursor: pointer; }
@media (max-width: 560px) { .quest.chapter:not(.open) .qbrief { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .quest.chapter:not(.open) .qreward { display: none; } } /* phones: tap the card for the whole brief */
.hbtn.alert { position: relative; }
.hbtn.alert::after { content: ''; position: absolute; top: 4px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 2px #fff; }
.jobrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dashed rgba(59,42,32,.2); font-size: 13px; }
.card.done { background: #ecfdf5; border-color: #86efac; }
/* Nation Shop (prototype: test grants only) */
.shopnote { background: #fff7d6; border: 2px dashed #d4a017; border-radius: 10px; padding: 8px 10px; font-size: 12px; font-weight: 700; }
.shopsec { margin-top: 6px; padding-top: 8px; border-top: 2px solid rgba(59,42,32,.15); }
.shopsec .ctitle { font-size: 15px; }
.shopcard { background: #faf5ff; border: 2px solid #a56ef0; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.shopcard.owned { background: #ecfdf5; border-color: #86efac; }
.shopcard .btn { align-self: flex-start; margin: 0; }
.shoptop { display: flex; gap: 10px; align-items: center; }
.shopprice { font-weight: 800; font-size: 12px; color: #6b3fb5; }
.shopcard.owned .shopprice { color: #187a3f; }
.shoplist { margin: 0; padding-left: 18px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.shopowned { font-weight: 800; color: #187a3f; font-size: 13px; }
.card.shoplum { display: flex; flex-direction: column; gap: 3px; }
.card.shoplum .btn, .card .btn.small { margin: 4px 0 0; align-self: flex-start; }
.cards.cal { grid-template-columns: repeat(7, 1fr); }
@media (max-width: 560px) { .cards.cal { grid-template-columns: repeat(4, 1fr); } }
.upgrade { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.quest .qname { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.gobtn { pointer-events: auto; background: #278039; color: #fff; border: 0; border-radius: 8px; padding: 6px 12px; min-height: 30px; font-weight: 800; font-size: 12px; box-shadow: 0 2px 0 rgba(0,0,0,.25); cursor: pointer; }
.quests { pointer-events: auto; }
.nextup { align-self: flex-start; background: rgba(30,43,24,.78); color: #fff; border: 1px solid rgba(242,201,76,.8); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.25); }

/* ---- Haven juice (graphics session): resources fly to the HUD, counters bump ---- */
.flyico { position: fixed; z-index: 80; width: 20px; height: 20px; font-size: 18px; line-height: 20px; text-align: center; pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.45)); transition: left .55s cubic-bezier(.5,-0.35,.6,1), top .55s cubic-bezier(.25,.9,.4,1), transform .55s, opacity .2s .45s; }
.flyico.go { transform: scale(.75); opacity: .2; }
.haven-top .res.bump, .haven-top .lvl.bump { animation: resbump .35s ease-out; }
@keyframes resbump { 0% { transform: scale(1); } 40% { transform: scale(1.18); filter: brightness(1.35); } 100% { transform: scale(1); } }

/* ---- Siege command-card portrait (graphics session) ---- */
.info-with-portrait { display: flex; gap: 10px; align-items: flex-start; }
.info-with-portrait .info-lines { min-width: 0; flex: 1; }
.uportrait { width: 72px; height: 72px; flex: none; border-radius: 6px; object-fit: cover; border: 1px solid rgba(59,130,246,.65);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 14px rgba(59,130,246,.35) inset; background: #05080d; }
.uportrait.enemy { border-color: rgba(239,68,68,.75); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 14px rgba(239,68,68,.35) inset; }
@media (max-width: 640px) { .uportrait { width: 52px; height: 52px; } }

.haven .quests { top: 108px; }

@media (max-width: 560px) { .havenbar { gap: 2px; padding-left: 4px; padding-right: 4px; pointer-events: auto; } .havenbar .hbtn { flex: 1 1 0; min-width: 0; padding: 4px 0; font-size: 10px; border-radius: 10px; } }

/* ---- Haven Album art + event banner (graphics session) ---- */
.card .cardart { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; margin-bottom: 6px; background: #f6efe2; }
.card.locked .cardart { filter: grayscale(1) blur(4px) brightness(.85); opacity: .5; }
.card.done .cardart { box-shadow: 0 0 0 2px #86efac; }
.eventbanner { display: block; width: 100%; aspect-ratio: 16 / 5; object-fit: cover; border-radius: 12px; margin: 0 0 10px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
/* obstacle panel picture (Blender render, proto/ui/ob/<type>.png) */
.obicon { display: block; width: 64px; height: 64px; margin: 0 auto 6px; image-rendering: auto; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
/* Siege Field Orders (vs-bot objectives) */
.fieldorders { position: absolute; left: 10px; top: calc(var(--top-h, 46px) + 6px); width: min(300px, 70vw); background: rgba(15,23,42,.86); border: 1px solid rgba(125,255,154,.45); border-radius: 10px; padding: 7px 10px; color: #e2e8f0; font-size: 13px; pointer-events: auto; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
/* with a doctrine committed the Command Point bar sits top-left: Field Orders go below it */
.has-doc .fieldorders { top: calc(var(--top-h, 46px) + var(--doc-h, 80px) + 12px); }
/* phones: the topbar wraps to 2-3 rows; siege-game.js measures it into --top-h (and the doctrine bar into --doc-h) */
.fieldorders .fohead { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: #7dff9a; font-size: 12px; margin-bottom: 3px; }
.fieldorders .foclose { background: none; border: 0; color: #94a3b8; cursor: pointer; font-size: 13px; padding: 0 2px; }
.fieldorders .fotext { line-height: 1.35; }
/* art session insignia (proto/ui/logo, proto/ui/doctrine) */
.logo-img { display: block; width: min(560px, 86vw); height: auto; margin: 0 auto; filter: drop-shadow(0 4px 18px rgba(0,0,0,.7)); }
.doc-name { display: flex; align-items: center; gap: 6px; }
.doc-emblem { width: 28px; height: 28px; flex: none; }
.docinfo .doc-emblem { width: 22px; height: 22px; vertical-align: middle; margin-right: 4px; }
.mgraphs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin: 4px 0 10px; text-align: left; }
.mgraph { background: rgba(0,0,0,.25); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.mgraph-h { font-size: 12px; font-weight: 600; margin-bottom: 4px; } .mgraph-h small { opacity: .6; font-weight: 400; }
.mgraph svg { display: block; width: 100%; height: 70px; }
/* first-hour fixes: bigger tap targets on touch, Build pulse until the first Farm, loss tip */
@media (pointer: coarse) { .gobtn, .xbtn, .btn.small, .fieldorders .foclose { min-height: 40px; min-width: 40px; } .btn.small { padding: 8px 12px; } }
@keyframes hpulse { 0%, 100% { box-shadow: 0 3px 0 rgba(0,0,0,.3), 0 0 0 0 rgba(250,204,21,.9); } 50% { box-shadow: 0 3px 0 rgba(0,0,0,.3), 0 0 0 8px rgba(250,204,21,0); } }
.hbtn.pulse { animation: hpulse 1.2s ease-in-out infinite; border-color: #facc15; }
.losstip { margin: 6px 0 2px; font-size: 13px; }
.aud-credit { font-size: 10px; color: var(--muted, #9aa59c); opacity: .8; margin-top: 2px; }
/* landscape phones: see the front-page block at the end of this file (main.js menu()) */

/* ---- First launch: name your President (main.js welcome()). welcome-bg.jpg is the front art; menu-bg.jpg shows until it exists ---- */
.welcome { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; padding: 16px 16px max(28px, env(safe-area-inset-bottom)); overflow-y: auto;
  background: url('../ui/welcome-bg.jpg') center 35% / cover no-repeat, url('../ui/menu-bg.jpg') center 30% / cover no-repeat, #0b1016; }
.welcome-shade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(5,9,13,.05) 0%, rgba(5,9,13,.15) 40%, rgba(5,9,13,.82) 100%); }
.welcome-card { position: relative; margin-top: auto; width: min(520px, 100%); text-align: center; padding: 22px 20px 20px; border-radius: 16px; background: rgba(10,16,22,.62); border: 1px solid rgba(214,170,96,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: 0 18px 50px rgba(0,0,0,.45); animation: welcomeIn .6s ease-out both; }
.welcome-logo { width: min(300px, 70%); display: block; margin: 0 auto 10px; }
.welcome-kicker { font: 700 13px 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; letter-spacing: .22em; text-transform: uppercase; color: #d6aa60; margin-top: 4px; }
.welcome-title { font: 700 clamp(24px, 6vw, 36px)/1.15 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; margin: 6px 0 6px; color: #f3efe6; text-shadow: 0 2px 10px rgba(0,0,0,.6); overflow-wrap: anywhere; }
.welcome-card.sworn .welcome-title { font-size: clamp(28px, 7.5vw, 44px); animation: welcomeIn .5s ease-out both; }
.welcome-sub { color: #cfd6dc; margin: 0 0 14px; }
.welcome-name { width: 100%; box-sizing: border-box; font: 600 20px 'Inter', sans-serif; text-align: center; padding: 12px 14px; border-radius: 10px; border: 1px solid rgba(214,170,96,.5);
  background: rgba(0,0,0,.45); color: #fff; outline: none; }
.welcome-name:focus { border-color: #d6aa60; box-shadow: 0 0 0 3px rgba(214,170,96,.25); }
.welcome-err { min-height: 20px; color: #fca5a5; font-size: 14px; margin: 6px 0 4px; }
.welcome-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
@keyframes welcomeIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.pres-chip { display: inline-flex; align-items: center; gap: 8px; margin: -8px auto 16px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(214,170,96,.45); background: rgba(10,16,22,.55);
  color: #f3efe6; font: 700 15px 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; letter-spacing: .03em; cursor: pointer; }
.pres-chip .pres-edit { opacity: .7; font-size: 13px; }
/* landscape phones: drop the logo and tighten so the whole card fits */
/* tall phones: the art fills the top 60% (palace at x ≈ 66% in frame, above the card) and fades into the dark behind the card */
@media (orientation: portrait) { .welcome { background: linear-gradient(to bottom, rgba(11, 16, 22, 0) 40%, #0b1016 60%), url('../ui/welcome-bg.jpg') 72% 0 / auto 60% no-repeat, #0b1016; } }
@media (max-height: 520px) { .welcome { padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); } .welcome-logo { display: none; } .welcome-card { padding: 12px 18px 14px; }
  .welcome-title, .welcome-card.sworn .welcome-title { font-size: 24px; margin: 2px 0 4px; } .welcome-sub { margin-bottom: 8px; } .welcome-name { padding: 8px 12px; font-size: 18px; } .welcome-err { min-height: 16px; margin: 4px 0 2px; } }
@media (prefers-reduced-motion: reduce) { .welcome-card, .welcome-card.sworn .welcome-title { animation: none; } }

/* ---- Intro cinematic (js/intro.js): a 16:9 frame that covers the screen (letterboxed on tall phones), slow camera moves on stills ---- */
.intro { position: fixed; inset: 0; z-index: 90; background: #000; overflow: hidden; pointer-events: auto; color: #f3ead8; transition: opacity .5s; }
.intro.out { opacity: 0; pointer-events: none; }
.intro-stage { position: absolute; inset: 0; }
.intro-frame { position: absolute; left: 50%; top: 50%; width: max(100vw, 177.78vh); height: max(56.25vw, 100vh); transform: translate(-50%, -50%); overflow: hidden; opacity: 0; transition: opacity .9s ease, filter 1.2s ease; }
@media (orientation: portrait) { .intro-frame { width: 106.67vh; height: 60vh; } }
.intro-frame.on { opacity: 1; }
.intro-frame.dim { filter: brightness(.3) saturate(.7); }
.intro-frame.cut { transition: filter 1.2s ease; } /* montage shots hard-cut in */
.intro-frame.cut .intro-clip { transition: none; }
.intro-cam { position: absolute; inset: 0; will-change: transform; }
.intro-img, .intro-clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.intro-clip { opacity: 0; transition: opacity .5s; }
.intro-clip.on { opacity: 1; }
@keyframes intro-push { from { transform: scale(1.04); } to { transform: scale(1.17); } }
@keyframes intro-dolly { from { transform: scale(1.13) translateX(3.2%); } to { transform: scale(1.13) translateX(-3.2%); } }
@keyframes intro-crane { from { transform: scale(1.14) translateY(-3.5%); } to { transform: scale(1.16) translateY(3.5%); } }
@keyframes intro-clash { from { transform: scale(1.05); } to { transform: scale(1.2); } }
/* light through the banners, drifting haze over the muster field */
.intro-rays { position: absolute; inset: -10%; mix-blend-mode: screen; pointer-events: none;
  background: linear-gradient(112deg, transparent 22%, rgba(255,214,150,.16) 30%, transparent 37%, rgba(255,214,150,.11) 46%, transparent 52%, rgba(255,214,150,.14) 61%, transparent 68%);
  animation: intro-rays 8s ease-in-out both; }
@keyframes intro-rays { from { opacity: 0; transform: translateX(-4%); } 30% { opacity: 1; } to { opacity: .75; transform: translateX(4%); } }
.intro-haze { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(to top, rgba(196,160,110,.32), rgba(196,160,110,0) 45%); animation: intro-haze 8s ease-in-out both; }
@keyframes intro-haze { from { opacity: .3; } 50% { opacity: .9; } to { opacity: .6; } }
/* muzzle flashes and blasts, placed in % of the frame so they sit on the art */
.intro-flash { position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.4); opacity: 0; pointer-events: none; mix-blend-mode: screen; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,250,225,1) 0, rgba(255,196,96,.85) 18%, rgba(255,110,30,.35) 42%, rgba(255,80,20,0) 70%); }
.intro-flash.muzzle.go { animation: intro-muzzle .32s ease-out; }
.intro-flash.blast.go { animation: intro-blast 1.3s ease-out; }
@keyframes intro-muzzle { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); } 15% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); } }
@keyframes intro-blast { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.2); } 8% { opacity: 1; transform: translate(-50%, -50%) scale(.8); } 40% { opacity: .55; transform: translate(-50%, -50%) scale(1.3); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.7); } }
.intro-stage.jolt { animation: intro-jolt .4s ease-out; }
@keyframes intro-jolt { 0% { transform: translate(0, 0); } 20% { transform: translate(-6px, 4px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-3px, 2px); } 100% { transform: translate(0, 0); } }
.intro-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.intro-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 50%, rgba(0,0,0,.6) 100%); }
.intro-cap { position: absolute; left: 50%; bottom: max(9vh, calc(env(safe-area-inset-bottom, 0px) + 28px)); width: min(880px, 90vw); transform: translate(-50%, 8px); text-align: center; opacity: 0; transition: opacity .8s, transform .8s;
  font: 500 clamp(16px, 2.3vw, 28px)/1.35 Georgia, 'Times New Roman', serif; letter-spacing: .02em; text-shadow: 0 2px 14px rgba(0,0,0,.95), 0 0 2px #000; pointer-events: none; }
@media (orientation: portrait) { .intro-cap { bottom: max(6vh, calc(env(safe-area-inset-bottom, 0px) + 24px)); } }
.intro-cap.on { opacity: 1; transform: translate(-50%, 0); }
.intro-skip { position: absolute; z-index: 3; top: max(12px, env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); padding: 8px 16px; border-radius: 999px; border: 1px solid rgba(255,255,255,.35); background: rgba(0,0,0,.45); color: #f3ead8; font: 600 14px/1 Inter, system-ui, sans-serif; cursor: pointer; opacity: .75; }
.intro-skip:hover { opacity: 1; }
.intro-title { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; opacity: 0; transform: scale(.94); transition: opacity 1.2s ease, transform 4.5s ease-out; pointer-events: none; }
.intro-title.on { opacity: 1; transform: scale(1); }
.intro-logo { width: min(760px, 78vw); filter: drop-shadow(0 6px 30px rgba(0,0,0,.9)); }
.intro-tag { font: 600 clamp(15px, 2vw, 22px)/1 Inter, system-ui, sans-serif; letter-spacing: .32em; text-transform: uppercase; color: #e8c787; text-shadow: 0 2px 12px #000; }
.intro-gate { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; border: 0; background: radial-gradient(ellipse at 50% 45%, #141c26 0, #000 70%); color: #f3ead8; cursor: pointer; }
.intro-gate-logo { width: min(520px, 70vw); opacity: .92; }
.intro-gate-tap { font: 600 15px/1 Inter, system-ui, sans-serif; letter-spacing: .3em; text-transform: uppercase; animation: intro-pulse 1.8s ease-in-out infinite; }
@keyframes intro-pulse { 50% { opacity: .35; } }
.intro-replay { position: fixed; z-index: 2; top: max(10px, env(safe-area-inset-top, 0px)); left: max(10px, env(safe-area-inset-left, 0px)); padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(214,170,96,.45); background: rgba(10,16,22,.55); color: #f3ead8; font: 600 13px/1 Inter, system-ui, sans-serif; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { .intro-title { transform: none; } .intro-rays, .intro-haze { animation: none; } .intro-gate-tap { animation: none; } }

/* ---- Siege resume, first-Rumble cards, Graphics High/Low (siege-resume.js, siege-game.js rumbleIntro, main.js gfxToggle) ---- */
.resume-offer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.resume-offer .seg { flex: 0 0 auto; padding: 5px 12px; }
.gfxtoggle { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.gfxtoggle .seg { flex: 0 0 auto; padding: 3px 10px; font-size: 12px; }
.rumble-intro { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.35); z-index: 30; padding: 16px; }
.ri-card { width: min(420px, 100%); max-height: calc(100% - 32px); overflow: auto; background: var(--panel-solid); border: 1px solid rgba(214,170,96,.5); border-radius: 14px; padding: 16px 18px; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
.ri-head { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.ri-icon { font-size: 24px; line-height: 1; }
.ri-step { margin-left: auto; font-size: 12px; color: var(--muted); }
.ri-text { margin: 10px 0 14px; font-size: 14px; line-height: 1.45; }
.ri-row { display: flex; justify-content: flex-end; gap: 8px; }
.ri-row .btn { margin: 0; }
.loading-screen .ls-cancel { min-height: 44px; min-width: 120px; margin-top: 4px; }
/* Raid Board (haven-game.js panelRaids) and the raid stars on the Siege result screen */
.raidlist { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.raidcard { display: flex; flex-direction: column; gap: 4px; }
.raidtop { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.raidbest { color: #c48a06; font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.raidstars-l { list-style: none; margin: 2px 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.raidstars-l li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; }
.raidres { margin-bottom: 6px; display: flex; flex-direction: column; gap: 2px; }
.raidres.won { background: #ecfdf5; border-color: #86efac; }
.raidres.lost { background: #fef2f2; border-color: #fca5a5; }
.raidtot { margin: 2px 0 4px; }
.raidstars { margin: 8px auto; max-width: 440px; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.raidstars .rs-head { font-weight: 800; text-align: center; }
.raidstars .rs-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,.07); }
.raidstars .rs-row span:nth-child(2) { flex: 1; }
.raidstars .rs-star { font-size: 18px; }
.raidstars .rs-row.yes .rs-star { color: #facc15; }
.raidstars .rs-row.no { opacity: .7; }

/* ---- Front page (main.js menu()): slim top bar, three mode cards with badge slots (ui/mode/<nation|siege|rumble>.webp, emoji fallback),
   setup / Online / Settings sheets (.msheet). Phones portrait: stacked cards with the badge at the left; short landscape: compact row of three ---- */
.menu-card { width: min(980px, 100%); }
.menu-top { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; }
.menu-top .pres-chip { margin: 0; min-height: 40px; min-width: 0; flex: 0 1 auto; font-size: 14px; }
.pres-chip .pres-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-top-gap { flex: 1 1 0; }
.menu-gear { display: inline-flex; align-items: center; gap: 6px; flex: none; min-height: 40px; min-width: 40px; padding: 6px 14px; border-radius: 999px; border: 1px solid rgba(214,170,96,.45);
  background: rgba(10,16,22,.6); color: #f3efe6; font: 700 14px 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; letter-spacing: .03em; cursor: pointer; }
.menu-gear .gear { font-size: 18px; line-height: 1; }
.menu-gear:hover, .menu-gear:focus-visible, .menu-top .pres-chip:hover { border-color: #d6aa60; }
.menu .tagline { font-size: 12px; margin: 2px 0 14px; }
.menu .modes { grid-template-columns: repeat(3, 1fr); gap: 14px; }
.menu .mode { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 16px 14px; }
.menu .rumble-mode { grid-column: auto; }
.mode-badge { width: 120px; height: 120px; display: flex; align-items: center; justify-content: center; margin: 0 auto 4px; flex: none; }
.mode-badge img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 14px rgba(0,0,0,.6)); -webkit-user-drag: none; }
.mode-badge .micon { font-size: 64px; line-height: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,.6)); }
.mode-txt { display: flex; flex-direction: column; align-items: center; flex: 1 1 auto; min-width: 0; }
.menu .mode h2 { margin: 2px 0 4px; font-size: 26px; letter-spacing: .02em; }
.menu .mode p { min-height: 0; margin: 0 0 6px; font-size: 13.5px; line-height: 1.4; }
.mode-sum { color: #cbbf9f; font-size: 12px; min-height: 16px; }
.mode-act { display: flex; gap: 8px; width: 100%; margin-top: auto; padding-top: 10px; }
.mode-act .btn.big { margin: 0; flex: 1 1 0; min-height: 46px; }
.mode-act .btn.big.mode-bot { flex: 0 1 38%; }
/* the small game-type line above a mode card title (Nation builder / Game type: Siege) */
.mode-kick { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #cbd5e1; opacity: .8; }
.mode-extra { width: 100%; margin-top: 8px; }
.menu-rule { margin: 14px auto 0; max-width: 640px; font-size: 11.5px; color: var(--muted); text-shadow: 0 1px 4px #000; }
@media (max-width: 760px) {
  .menu .modes { grid-template-columns: 1fr; gap: 10px; }
  .menu .mode { display: grid; grid-template-columns: 76px 1fr; grid-template-areas: "b t" "a a" "x x"; column-gap: 12px; align-items: center; text-align: left; padding: 12px; }
  .menu .mode .mode-badge { grid-area: b; width: 76px; height: 76px; margin: 0; }
  .menu .mode .micon { font-size: 44px; }
  .menu .mode .mode-txt { grid-area: t; align-items: flex-start; }
  .menu .mode h2 { font-size: 22px; margin: 0 0 2px; }
  .menu .mode p { font-size: 13px; margin: 0 0 3px; }
  .menu .mode .mode-act { grid-area: a; }
  .menu .mode .mode-extra { grid-area: x; }
  .menu-gear .menu-gear-t { display: none; }
  .menu-gear { padding: 6px 10px; }
  .menu .logo-img { width: min(420px, 82vw); }
  .menu .tagline { margin-bottom: 10px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: 8px; }
  .menu .logo-img { width: auto; height: 60px; }
  .menu .tagline { margin: 0 0 6px; font-size: 11px; }
  .menu-top { margin-bottom: 2px; }
  .menu .modes { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .menu .mode { display: flex; padding: 8px 10px 10px; text-align: center; }
  .menu .mode .mode-badge { width: 54px; height: 54px; margin: 0 auto 2px; }
  .menu .mode .micon { font-size: 34px; }
  .menu .mode .mode-txt { align-items: center; }
  .menu .mode h2 { margin: 0 0 2px; font-size: 18px; }
  .menu .mode p { display: none; }
  .menu .mode .mode-act { padding-top: 6px; }
  .menu .mode .btn.big { padding: 8px 10px; min-height: 40px; font-size: 15px; }
  .menu-rule { margin-top: 6px; font-size: 10.5px; }
}
.msheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); background: rgba(3,6,10,.6); animation: fadein .15s; }
.msheet-card { margin: auto 0; width: min(560px, 100%); text-align: left; background: rgba(12,18,26,.95); border: 1px solid rgba(214,170,96,.4); border-radius: 16px; padding: 14px 18px 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); outline: none; touch-action: pan-y; }
.msheet-head { display: flex; align-items: center; gap: 10px; }
.msheet-head h2 { flex: 1; margin: 0; font: 700 22px 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; letter-spacing: .03em; color: #f3efe6; }
.msheet-x { width: 40px; height: 40px; flex: none; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.06); color: #e5e7eb; font-size: 15px; cursor: pointer; }
.msheet-x:hover, .msheet-x:focus-visible { border-color: #d6aa60; }
.msheet-lead { margin: 6px 0 2px; color: #d8d3c8; font-size: 13.5px; line-height: 1.45; }
.msheet-sec h3 { margin: 14px 0 6px; font: 700 12px 'Chakra Petch', Bahnschrift, 'Segoe UI', Roboto, system-ui, sans-serif; letter-spacing: .16em; text-transform: uppercase; color: #d6aa60; }
.msheet .segrow { flex-wrap: wrap; margin: 4px 0; }
.msheet .seg { flex: 1 1 auto; min-height: 40px; padding: 7px 10px; }
.msheet-tip { margin: 4px 0 0; line-height: 1.4; }
.msheet-tip:empty { display: none; }
.msheet .btn.big { margin: 16px 0 0; min-height: 48px; }
.msheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.msheet-grid .btn { margin: 0; min-height: 66px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.msheet-grid .btn small { font-weight: 500; font-size: 11.5px; opacity: .8; }
.msheet-row { display: flex; align-items: center; gap: 4px 10px; flex-wrap: wrap; margin: 6px 0; }
.msheet-lbl { flex: 1 1 150px; font-size: 13.5px; color: #e5e1d8; }
.msheet-row .segrow { flex: 1 1 240px; margin: 0; }
.msheet .gfxtoggle { display: flex; flex-wrap: wrap; width: 100%; gap: 6px 10px; font-size: 13.5px; color: #e5e1d8; }
.msheet .gfxtoggle .seg { flex: 1 1 0; padding: 7px 10px; font-size: 14px; }
.msheet .perftoggle { display: flex; min-height: 40px; margin-top: 4px; font-size: 13.5px; color: #e5e1d8; }
.msheet .perftoggle input { width: 20px; height: 20px; margin: 0; accent-color: #facc15; }
.msheet .aud-set { display: flex; flex-direction: column; align-items: stretch; gap: 6px; font-size: 13.5px; color: #e5e1d8; }
.msheet .aud-row { display: flex; justify-content: space-between; gap: 12px; min-height: 38px; }
.msheet .aud-row input[type=range] { flex: 1 1 auto; width: auto; max-width: 300px; height: 28px; }
.msheet .aud-juke { flex: 1 1 auto; max-width: 300px; font-size: 14px; padding: 7px 8px; }
.msheet .aud-set .aud-mute { align-self: flex-start; margin: 0 0 2px; }
.msheet-more { margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: rgba(255,255,255,.03); }
.msheet-more summary { cursor: pointer; padding: 11px 0; font-weight: 700; font-size: 14px; }
.msheet-more[open] { padding-bottom: 10px; }
.msheet-more .aud-row { margin-top: 6px; font-size: 13.5px; color: #e5e1d8; }
.msheet-credits { font-size: 12px; color: var(--muted); line-height: 1.5; }
.msheet-credits p { margin: 0 0 6px; }
.msheet-credits .aud-credit { font-size: 12px; opacity: 1; margin: 0 0 6px; }
.msheet .btn.ghost { margin: 0; }
.msheet .btn.big.ghost { margin-top: 16px; }
/* the sheet's primary action stays in reach: sticky at the bottom of the scrolling sheet, opaque with a short fade above it */
.msheet-foot { position: sticky; bottom: calc(-1 * max(12px, env(safe-area-inset-bottom))); /* flush with the screen edge, over the sheet's bottom padding */ z-index: 2; margin: 12px -18px -18px; padding: 10px 18px max(14px, env(safe-area-inset-bottom));
  background: rgb(12,18,26); border-radius: 0 0 16px 16px; }
.msheet-foot::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 18px; background: linear-gradient(rgba(12,18,26,0), rgb(12,18,26)); pointer-events: none; }
.msheet-foot .btn.big { display: block; width: 100%; margin: 0; }
@media (max-height: 520px) and (orientation: landscape) {
  .msheet-card:has(.msheet-cols) { width: min(780px, 100%); }
  .msheet-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; align-items: start; }
  .msheet-cols .msheet-sec h3 { margin-top: 10px; }
  .msheet-card:has(.msheet-cols) .msheet-lead { display: none; }
}

/* ---- Store (store.js, RF.Store.open() from the front page's top bar): a .msheet with flat cards. Prototype test grants only;
   no countdown, badge or "limited" styling anywhere (monetization-plan.md §2.3-§2.4). Phones portrait: one column; short
   landscape: the Lumens packs sit in one row ---- */
.store-sheet .msheet-card { width: min(600px, 100%); }
.store-note { margin: 8px 0 4px; padding: 8px 10px; border: 1px dashed rgba(250,204,21,.6); border-radius: 10px; background: rgba(250,204,21,.08); color: #fde68a; font-size: 12.5px; font-weight: 700; line-height: 1.4; }
.store-wallet { margin: 6px 0 0; font-size: 13.5px; color: #e5e1d8; }
.store-msg { min-height: 0; margin: 6px 0 0; font-size: 13px; font-weight: 700; line-height: 1.4; }
.store-msg:empty { display: none; }
.store-msg.good { color: #86efac; }
.store-msg.warn { color: #fca5a5; }
.store-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }
.store-sec > .store-sub { margin: -2px 0 8px; }
.store-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid rgba(165,110,240,.55); border-radius: 12px; background: rgba(165,110,240,.08); }
.store-card + .store-card { margin-top: 8px; }
.store-card.owned { border-color: rgba(134,239,172,.55); background: rgba(52,192,106,.08); }
.store-top { display: flex; align-items: center; gap: 10px; }
.store-ico { font-size: 28px; line-height: 1; flex: none; }
.store-img { display: block; width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,.55)); }
.store-img.lum { width: 76px; height: 76px; align-self: center; margin: -2px 0 2px; }
.shop-img { display: block; width: 52px; height: 52px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.45)); }
.store-ttl { display: flex; flex-direction: column; min-width: 0; }
.store-ttl b { font-size: 15px; color: #f3efe6; }
.store-price { font-size: 12.5px; font-weight: 800; color: #d8b4fe; }
.store-card.owned .store-price { color: #86efac; }
.store-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.4; color: #e5e1d8; }
.store-owned { font-weight: 800; font-size: 13.5px; color: #86efac; outline: none; }
.store-lock { font-size: 13px; color: #cbd5e1; outline: none; }
.store-sec > .store-lock { margin: 0 0 8px; }
.msheet .btn.store-buy { margin: 0; align-self: flex-start; min-height: 40px; white-space: normal; text-align: left; }
.store-lums { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.store-lum { display: flex; flex-direction: column; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); }
.store-lum b { font-size: 14px; color: #f3efe6; }
.store-lum .btn.store-buy { margin-top: 4px; align-self: stretch; text-align: center; }
.store-lum > .store-sub[tabindex] { outline: none; margin-top: 4px; }
.msheet .btn.store-locker { margin: 10px 0 0; min-height: 44px; }
@media (max-width: 420px) {
  .store-lums { grid-template-columns: 1fr 1fr; }
  .msheet .btn.store-buy { align-self: stretch; text-align: center; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .store-sheet .msheet-card { width: min(760px, 100%); }
  .store-lums { grid-template-columns: repeat(5, 1fr); }
  .store-sheet .msheet-lead { display: none; }
}

/* ---------- age check (legal.js) ---------- */
.age-row { display: flex; gap: 8px; margin: 12px 0 8px; flex-wrap: wrap; }
.age-sel { flex: 1 1 140px; min-height: 46px; font: 600 16px Inter, system-ui, sans-serif; color: var(--text); background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.age-sel option { color: #111; }
.msheet-foot .btn.big:disabled { opacity: .45; cursor: default; }
/* legal pages (legal.js RF.Legal): small links, and the page shown in a sheet */
.legal-links { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12.5px; margin-top: 6px; }
.legal-links.inline { display: inline-flex; margin-top: 0; }
.legal-links a { color: #c9d6e8; text-decoration: underline; text-underline-offset: 2px; }
.legal-links a:hover, .legal-links a:focus-visible { color: #fff; }
.legal-dot { color: rgba(255,255,255,.35); }
.menu-legal { justify-content: center; margin: 6px auto 0; opacity: .85; }
.legal-note { margin: 10px 0 0; }
.legal-sheet .msheet-card { width: min(820px, 100%); }
.legal-frame { display: block; width: 100%; height: min(72vh, 760px); border: 0; border-radius: 10px; background: #101a14; }
.legal-sheet-foot { margin-top: 6px; text-align: right; }
.legal-sheet-foot a { color: #c9d6e8; }

/* report / block (safety.js) */
.safety-btn { padding: 0 8px; min-width: 0; margin-left: 4px; line-height: 1.4; vertical-align: middle; }
.safety-reasons { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.safety-sheet h3 { margin: 14px 0 4px; }
.safety-list .msheet-row { justify-content: space-between; }

/* Skarn Siege (co-op) card: a full-width strip under the three mode cards */
.skarn-mode { border-color: rgba(139, 92, 246, .45); }
@media (min-width: 761px) {
  .menu .skarn-mode { grid-column: 1 / -1; flex-direction: row; align-items: center; text-align: left; gap: 16px; }
  .menu .skarn-mode .mode-badge { width: 84px; height: 84px; margin: 0; }
  .menu .skarn-mode .mode-txt { align-items: flex-start; }
  .menu .skarn-mode .mode-act { width: 220px; flex: none; margin-top: 0; padding-top: 0; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .menu .skarn-mode .mode-badge { width: 54px; height: 54px; }
}

/* ---------- accessibility basics (B15) ---------- */
/* keyboard focus: one visible ring on everything that takes focus; the cream Haven panels get a dark ring. Mouse and touch clicks do not show it. */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [role="button"]:focus-visible, [role="tab"]:focus-visible, [tabindex="0"]:focus-visible { outline: 2px solid #fcd34d; outline-offset: 2px; }
.sheet :focus-visible, .celebrate :focus-visible, .dialog :focus-visible, .haven .res:focus-visible { outline-color: #3b2a20; }
[tabindex="-1"]:focus { outline: none; } /* dialogs take focus on open; the ring belongs on the controls inside */
/* muted text on the cream Haven cards (the global muted grey is for dark panels) */
.celebrate .muted, .dialog .muted { color: #6b5a48; }
/* reduced motion: no pulses, bumps, drifts or slide-ins in the DOM UI; fades stay but near-instant. Canvas effects are untouched. */
@media (prefers-reduced-motion: reduce) {
  .toast, .meta-toast, .msheet, .comms, .emote-pop, .meta-mpop, .welcome-card, .welcome-card.sworn .welcome-title, .hbtn.pulse, .haven-top .res.bump, .haven-top .lvl.bump,
  .ls-fill, .intro-gate-tap, .intro-flash.muzzle.go, .intro-flash.blast.go, .intro-stage.jolt, .toast.kf-rampage { animation: none !important; }
  .menu > .menu-video, .loading-screen, .comms, .meta-mpop, .flyico, .intro-frame, .intro-clip, .intro-cap, .intro-title { transition-duration: .01ms !important; transition-delay: 0s !important; }
}
