:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c232d; --line: #2d3540; --text: #e6edf3; --muted: #8b949e;
  --accent: #2f81f7; --accent2: #1f6feb; --good: #3fb950; --warn: #d29922; --bad: #f85149; --gold: #ffd33d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
#app { height: 100%; }
h1 { margin: 0 0 4px; font-size: 1.6rem; } h2 { margin: 0 0 8px; font-size: 1.15rem; } h3 { margin: 8px 0 6px; font-size: 1rem; }
.muted { color: var(--muted); } .error { color: var(--bad); padding: 6px 0; } .grow { flex: 1; } .nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; } .pad { padding: 4px 12px; }
input, select, button, textarea { font: inherit; color: var(--text); }
input, select { background: #0b0f14; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; min-height: 40px; }
label { display: block; margin: 8px 0; font-size: .9rem; color: var(--muted); } label input, label select { margin-top: 3px; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; margin: 6px 12px 6px 0; color: var(--text); } label.check input { width: 18px; height: 18px; min-height: 0; padding: 0; margin: 0; flex: none; }
button { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; min-height: 40px; cursor: pointer; text-align: left; }
button:hover:not(:disabled) { border-color: var(--accent); } button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; } button.primary:hover:not(:disabled) { background: var(--accent); }
button.link { background: none; border: none; color: var(--accent); padding: 4px 8px; min-height: 0; }
button.on { border-color: var(--accent); background: #12233f; } button.taken { opacity: .55; }
.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 12px; }
.narrow { width: 100%; max-width: 380px; margin: 0; } .narrow button { width: 100%; margin-top: 8px; text-align: center; }
.page { max-width: 760px; margin: 0 auto; padding-bottom: 40px; }
.bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; } .row input { flex: 1; min-width: 120px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; }
.seg { display: flex; gap: 6px; margin: 4px 12px; } .seg button { flex: 1; text-align: center; }
.list { list-style: none; padding: 0; margin: 0; } .list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); } .list li:first-child { border-top: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 5px; } .dot.live { background: var(--good); } .dot.connecting { background: var(--warn); } .dot.offline { background: var(--bad); } .dot.bot { background: var(--accent); }

/* game */
.game { height: 100%; display: flex; flex-direction: column; }
.banner { padding: 8px 12px; background: var(--panel2); border-bottom: 1px solid var(--line); font-weight: 600; }
.banner.mine { background: #12331f; color: #b6f0c4; }
.banner.warn { background: #3a2d0d; color: #f2d58a; }
.players { display: flex; gap: 6px; padding: 6px 8px; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.pl { min-width: 120px; flex: 1 0 120px; border-top: 4px solid var(--muted); background: var(--panel2); border-radius: 8px; padding: 4px 8px; font-size: .8rem; }
.pl.acting { outline: 2px solid var(--gold); } .pl.passed { opacity: .55; } .pl-name { font-weight: 700; font-size: .85rem; white-space: nowrap; } .pl-stats { color: var(--muted); white-space: nowrap; }
main { flex: 1; min-height: 0; overflow: auto; }
.pane { display: none; } .tabs-act .pane-act, .tabs-empire .pane-empire, .tabs-cards .pane-cards, .tabs-board .pane-board, .tabs-chat .pane-chat, .tabs-log .pane-log, .tabs-menu .pane-menu { display: block; }
.tabbar { display: flex; flex: none; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; text-align: center; border: 0; border-radius: 0; background: none; padding: 12px 4px; position: relative; } .tabbar button.on { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.tabbar button.attn { color: var(--good); font-weight: 700; } .badge { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 6px; font-size: .7rem; font-style: normal; margin-left: 4px; }
.toast { position: fixed; left: 12px; right: 12px; bottom: 70px; background: #3b1d1d; border: 1px solid var(--bad); color: #ffd7d5; padding: 10px 12px; border-radius: 8px; z-index: 10; }
@media (min-width: 1000px) {
  main { display: grid; grid-template-columns: minmax(0, 1fr) 440px; overflow: hidden; }
  .pane-board { display: block !important; grid-column: 1; grid-row: 1; overflow: auto; }
  .pane-act, .pane-empire, .pane-cards, .pane-chat, .pane-log, .pane-menu { grid-column: 2; grid-row: 1; overflow: auto; border-left: 1px solid var(--line); }
  .tabs-board .pane-act { display: block; }
  .tabbar { justify-content: center; } .tabbar button { max-width: 160px; }
}

/* board */
.board { position: relative; } .boardscroll { overflow: auto; padding: 4px; }
.zoom { position: absolute; right: 8px; top: 8px; display: flex; gap: 4px; z-index: 2; } .zoom button { width: 36px; text-align: center; padding: 4px; }
svg { display: block; margin: 0 auto; max-width: none; } .tname { font-size: 9px; fill: #cfd8e3; } .tplanet { font-size: 8px; fill: #9fb0c3; } .ulabel { font-size: 8px; fill: #000; font-weight: 700; }
.ucount { font-size: 10px; font-weight: 800; fill: #fff; stroke: #000; stroke-width: 2.5px; paint-order: stroke; }
.tileinfo .planet { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }

/* panels */
.group { padding: 0 12px; } .group h3 { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 4px; } .group .btns { padding: 0; }
.order { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; } .order span { border: 2px solid var(--line); border-radius: 12px; padding: 1px 8px; font-size: .8rem; } .order span.now { background: #12233f; font-weight: 700; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; padding: 0 12px; }
.dcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; } .dcard.taken { opacity: .5; } .dcard .sheet { width: 100%; border-radius: 6px; margin-bottom: 6px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; } .slot { display: flex; flex-direction: column; align-items: center; }
.thumb { overflow: hidden; border-radius: 6px; } .thumb img { width: 100%; height: 100%; object-fit: contain; } .thumb.click { cursor: pointer; } .thumb.active { outline: 3px solid var(--gold); }
.chip { display: flex; align-items: center; justify-content: center; height: 100%; width: 100%; font-size: .65rem; text-align: center; padding: 2px; background: #1d3557; border-radius: 6px; } .chip.red { background: #4a2430; }

.chat { display: flex; flex-direction: column; height: 100%; } .messages { flex: 1; overflow: auto; padding: 8px 12px; min-height: 160px; max-height: 50vh; }
.msg { margin: 4px 0; word-wrap: break-word; } .msg.system { color: var(--muted); font-size: .85rem; } .msg.private { background: #1b1830; border-radius: 6px; padding: 2px 6px; } .time { color: var(--muted); font-size: .7rem; margin-left: 6px; }
.composer { padding: 8px 12px; border-top: 1px solid var(--line); } .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; } .chips button { padding: 4px 10px; min-height: 30px; border-width: 2px; border-radius: 16px; }
.deals { padding: 0 12px 12px; } .deal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin: 6px 0; } .deal.accepted { border-color: var(--good); } .deal.declined, .deal.failed, .deal.cancelled, .deal.undone { opacity: .6; }
.log, .steps { padding: 8px 12px; } .logline { padding: 3px 0; border-bottom: 1px solid #1b222b; font-size: .92rem; } .dice { font-size: .78rem; margin-left: 10px; }
.step { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.seat { padding: 6px 0; border-bottom: 1px solid var(--line); } .menu .card { margin: 12px; } .menu > button { margin: 0 12px 24px; }

/* popups and help */
.tip { position: fixed; z-index: 50; background: #0b0f14; border: 1px solid var(--accent); border-radius: 10px; padding: 8px 10px; box-shadow: 0 8px 28px #000a; font-size: .85rem; pointer-events: none; white-space: pre-line; }
.tip > b { display: block; margin-bottom: 2px; } .tip .tilepreview svg { display: block; margin: 4px auto; } .tiletext { font-size: .8rem; max-height: 220px; overflow: hidden; } .tiletext h3 { margin: 2px 0; font-size: .9rem; }
.rulebox { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); white-space: normal; } .rulebox ul, .rulelist { margin: 4px 0 0; padding-left: 18px; } .rulebox li, .rulelist li { margin: 2px 0; }
.rulebox.pinned { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 4px 0 8px; }
.help { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; min-height: 0; padding: 0; margin-left: 4px; border-radius: 50%; font-size: .75rem; font-weight: 700; text-align: center; color: var(--accent); }
details { margin: 4px 0; } summary { cursor: pointer; padding: 4px 0; }

/* turn order and next steps */
.turnpanel { background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.tp-head { width: 100%; border: 0; border-radius: 0; background: none; display: flex; gap: 8px; align-items: center; padding: 6px 12px; min-height: 0; } .chev { color: var(--muted); }
.tp-body { padding: 0 12px 10px; max-height: 36vh; overflow: auto; }
.flow { display: flex; gap: 4px; margin: 2px 0 8px; flex-wrap: wrap; } .flow span { padding: 2px 10px; border-radius: 12px; background: var(--panel2); color: var(--muted); font-size: .8rem; } .flow span.now { background: var(--accent2); color: #fff; font-weight: 700; } .flow span.done { color: var(--good); } .flow.small span { font-size: .72rem; padding: 1px 8px; }
.tp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 16px; } .tp-title { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.order-list { margin: 0; padding: 0; list-style: none; } .order-list li { padding: 2px 0; } .order-list li.now { font-weight: 700; color: var(--gold); } .order-list li.done { opacity: .5; text-decoration: line-through; }
.next { margin: 0; padding-left: 18px; } .next li { margin: 2px 0; }

.btnrow { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* empire */
.empire .stats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 6px; } ul.plain { list-style: none; margin: 0; padding: 0; } ul.plain li { padding: 3px 0; border-bottom: 1px solid #1b222b; } ul.plain li.exhausted { opacity: .6; }
.tag { margin-left: 6px; font-size: .7rem; color: var(--warn); font-style: normal; }
.techs { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 8px; } .tech { padding: 3px 9px; border-radius: 12px; font-size: .82rem; border: 1px solid var(--line); background: var(--panel2); cursor: default; }
.tech.blue { border-color: #3e7bfa; } .tech.green { border-color: #3fb950; } .tech.yellow { border-color: #e3b341; } .tech.red { border-color: #e5484d; } .tech.grey { border-color: #8b949e; } .tech.locked { opacity: .5; }

/* ---- score ---- */
.score-btn { min-height: 32px; padding: 4px 12px; border-color: var(--gold); color: var(--gold); font-weight: 600; }
.scorestrip { display: flex; align-items: center; gap: 12px; width: 100%; padding: 6px 12px; min-height: 36px; border-radius: 0; border: 0; border-bottom: 1px solid var(--line); background: #1a1f27; overflow-x: auto; white-space: nowrap; flex: none; font-size: .85rem; }
.scorestrip b:first-child { color: var(--gold); } .scorestrip .me { color: var(--gold); } .scorestrip span { display: inline-flex; align-items: center; gap: 4px; }
.modal { position: fixed; inset: 0; background: #000a; z-index: 50; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-panel { max-width: 780px; margin: 0 auto; min-height: 100%; background: var(--bg); padding-bottom: 40px; }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sheet-head h2 { margin: 0; }
.objs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.obj { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.obj.scored { border-color: var(--good); } .obj-head { display: flex; justify-content: space-between; gap: 8px; } .vp { color: var(--gold); font-weight: 700; white-space: nowrap; }
.small { font-size: .8rem; } .good { color: var(--good); }
.prog { display: flex; align-items: center; gap: 8px; } .bar2 { flex: 1; height: 8px; background: #0b0f14; border-radius: 4px; overflow: hidden; } .bar2.big { height: 10px; margin: 4px 0; }
.bar2 i { display: block; height: 100%; background: var(--accent); } .bar2 i.met { background: var(--good); }
.small-btn { min-height: 30px; padding: 4px 10px; font-size: .8rem; align-self: flex-start; }
.score-row { padding: 8px 0; border-bottom: 1px solid var(--line); } .score-row:last-child { border-bottom: 0; }
.ledger { margin: 6px 0 0; padding-left: 18px; font-size: .85rem; }
.ways { padding-left: 18px; margin: 6px 0 12px; } .ways li { margin: 8px 0; }
.vpform { display: flex; flex-direction: column; gap: 8px; } .vpform .row select { flex: 1; min-width: 100px; }
.narrowpanel { max-width: 520px; }
.cards .objs { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.agendacard h3 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.outcomes { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.outcome { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.outcome.has { border-color: var(--gold); }
.outcome-head { display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; } .outcome-head b { white-space: nowrap; color: var(--gold); }
.voter { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; } .voter.now { color: var(--gold); font-weight: 700; }
.voteorder { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; }

/* chat recipients: unselected names fade once someone is picked, AI names are greyer */
.chips button.off { opacity: .45; } .chips button.ai { color: var(--muted); } .chips button.on { color: #fff; font-weight: 600; }

/* starry backdrop for the sign-in screen and the game list */
.stars { position: relative; min-height: 100%; background: radial-gradient(ellipse at 20% 15%, #1b2a55 0%, transparent 55%), radial-gradient(ellipse at 80% 85%, #3a1d52 0%, transparent 50%), #05070d; overflow: hidden; }
.stars::before, .stars::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-repeat: repeat; }
.stars::before { background-image: radial-gradient(1px 1px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 90px 140px, #cfe3ff, transparent), radial-gradient(1.5px 1.5px at 160px 60px, #fff, transparent), radial-gradient(1px 1px at 230px 200px, #ffe9c4, transparent), radial-gradient(1px 1px at 300px 90px, #fff, transparent), radial-gradient(1.5px 1.5px at 60px 220px, #bcd4ff, transparent); background-size: 340px 260px; opacity: .8; animation: drift 240s linear infinite; }
.stars::after { background-image: radial-gradient(1px 1px at 50px 70px, #fff, transparent), radial-gradient(1px 1px at 180px 180px, #fff, transparent), radial-gradient(2px 2px at 260px 20px, #aecbff, transparent), radial-gradient(1px 1px at 120px 250px, #fff, transparent); background-size: 410px 310px; opacity: .55; animation: drift 400s linear infinite reverse; }
.stars > * { position: relative; z-index: 1; }
@keyframes drift { to { background-position: 340px 260px; } }
@media (prefers-reduced-motion: reduce) { .stars::before, .stars::after { animation: none; } }

/* setup panel: lists sit side by side without a wide empty gap */
.tp-cols { grid-template-columns: repeat(auto-fit, minmax(200px, max-content)); gap: 4px 40px; }
.tp-body .flow { margin-bottom: 4px; }
.order-list.wrap { display: flex; flex-wrap: wrap; gap: 2px 14px; } .order-list.wrap li { padding: 0; }

/* big preview of a slice or faction in the draft */
.preview { margin: 8px 12px; padding: 10px; background: var(--panel); border: 1px solid var(--gold); border-radius: var(--radius); }
.preview .pv-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; } .preview img.sheet { width: 100%; max-width: 720px; border-radius: 8px; display: block; margin: 0 auto; }
.dcard.click { cursor: pointer; } .dcard.sel { outline: 2px solid var(--gold); }

/* map: pan by dragging, wheel zoom, floating info and context menu */
.boardscroll { cursor: grab; touch-action: none; } .boardscroll.drag { cursor: grabbing; }
.tilecard { position: absolute; left: 8px; top: 8px; z-index: 3; width: min(320px, calc(100% - 16px)); max-height: 70%; overflow: auto; background: #0b0f14ee; border: 1px solid var(--accent); border-radius: 10px; padding: 8px 10px; font-size: .85rem; box-shadow: 0 8px 28px #000a; }
.tilecard .x { position: absolute; right: 4px; top: 2px; min-height: 0; padding: 0 8px; border: 0; background: none; font-size: 1.2rem; }
.ctxmenu { position: fixed; z-index: 60; min-width: 190px; background: #0b0f14; border: 1px solid var(--accent); border-radius: 8px; padding: 4px; box-shadow: 0 8px 28px #000a; }
.ctxmenu button { display: block; width: 100%; min-height: 0; padding: 6px 10px; border: 0; background: none; border-radius: 6px; } .ctxmenu button:hover:not(:disabled) { background: #12233f; } .ctxmenu .hd { padding: 4px 10px; color: var(--muted); font-size: .75rem; }
.board .boardscroll { overflow: hidden; padding: 0; height: calc(100vh - 250px); min-height: 360px; }
.preview.inline { display: block; } @media (min-width: 1000px) { .preview.inline { display: none; } }

/* command sheet */
.matbox { padding: 12px; } .mat { position: relative; max-width: 700px; margin: 0 auto; } .mat img { width: 100%; display: block; border-radius: 8px; }
.matcount { position: absolute; transform: translate(-50%, -50%); min-width: 34px; padding: 2px 8px; text-align: center; font-size: 1.4rem; font-weight: 800; color: #fff; background: #000a; border: 2px solid #ff4d4d; border-radius: 10px; }
.matbox .stats { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-top: 10px; }

.minimap { position: absolute; right: 8px; bottom: 8px; z-index: 2; margin: 0; background: #05070dcc; border: 1px solid var(--accent); border-radius: 6px; cursor: crosshair; touch-action: none; }
.fold { cursor: pointer; user-select: none; } .ringhead { font-size: .85rem; color: var(--muted); padding: 4px 0 2px; } .ring { margin-bottom: 4px; } .group h3.fold { color: var(--text); font-size: .9rem; }
@media (min-width: 1000px) {
  .pane-board { display: flex !important; flex-direction: column; overflow: hidden; }
  .pane-board > .board { flex: 1; min-height: 0; } .board .boardscroll { height: 100%; min-height: 0; }
  .pane-board > .pad { flex: none; margin: 0; font-size: .8rem; }
}

.foldcard > summary { list-style: none; cursor: pointer; } .foldcard > summary::-webkit-details-marker { display: none; } .foldcard > summary h3 { margin: 0; display: inline; } .foldcard > summary::before { content: "▸ "; color: var(--muted); } .foldcard[open] > summary::before { content: "▾ "; }
.foldcard > :not(summary) { margin-top: 8px; }

.turnpanel.mine .tp-head { background: #12331f; } .tp-note { font-size: .85rem; color: var(--muted); text-align: right; } .turnpanel.mine .tp-note { color: #b6f0c4; font-weight: 600; }
.tp-head { flex-wrap: wrap; }

.row label.check input { flex: none; min-width: 0; width: 18px; }

.sub { margin: 10px 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); } .tag.good { color: var(--good); } .tag.warn { color: var(--warn); } .tag.muted { color: var(--muted); }

/* player cards: the faction emblem in a ring of the player's colour; whose turn it is is shown by an arrow and a lighter card, not a ring */
.pl.acting { outline: none; background: #26324a; } .pl-top { display: flex; align-items: center; gap: 6px; min-width: 0; } .pl-id { min-width: 0; }
.ficon { flex: none; display: inline-block; border: 3px solid var(--muted); border-radius: 50%; background-color: #0b0f14; background-repeat: no-repeat; }
.undo-btn { min-height: 32px; padding: 4px 10px; text-align: center; } .undo-btn:disabled { opacity: .35; }

.pools { display: inline-flex; gap: 8px; vertical-align: middle; } .poolnum { display: inline-flex; align-items: center; gap: 2px; }
.pool { position: relative; display: inline-flex; } .pool img { display: block; } .pool i { position: absolute; right: -3px; bottom: -4px; font-size: 8px; font-style: normal; font-weight: 800; color: #fff; text-shadow: 0 0 2px #000, 0 0 2px #000; }
.pooltxt { font-weight: 700; color: var(--muted); }
.pl { min-width: 150px; flex: 1 0 150px; } .pl-stats { overflow: hidden; text-overflow: ellipsis; }
