@font-face { font-family: 'Pixelify Sans'; src: url(fonts/pixelify-sans-latin-500-normal.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Pixelify Sans'; src: url(fonts/pixelify-sans-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url(fonts/barlow-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Barlow'; src: url(fonts/barlow-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; }
:root {
  --bg: #18212b;
  --panel: #222e3b;
  --raise: #2c3a4a;
  --line: #3b4c60;
  --text: #edf1f5;
  --muted: #93a4b6;
  --accent: #e2552f;          /* swapped to the active faction's colour in game */
  --danger: #ff6b5b;
  --ok: #4fd18b;
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --cond: 'Pixelify Sans', 'Courier New', monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); overscroll-behavior: none; }
button, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); margin: 0; }

#app { height: 100%; }
.screen { min-height: 100%; padding: calc(20px + var(--safe-t)) 18px calc(24px + var(--safe-b)); max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* Brand: the wordmark leans forward like a stencilled hull number */
.brand h1 { font: 700 clamp(48px, 15vw, 76px)/0.95 var(--cond); margin: 18px 0 10px; color: var(--text); text-shadow: 4px 4px 0 var(--accent), 8px 8px 0 #0c1117; }
.brand p { margin: 0; color: var(--muted); font-size: 17px; }

h2 { font: 700 21px/1.1 var(--cond); margin: 0 0 10px; }
.block { display: flex; flex-direction: column; }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 14px; }
input { background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px; padding: 13px 14px; font-size: 17px; outline: none; width: 100%; }
input:focus { border-color: var(--text); }
#joinCode { text-transform: uppercase; letter-spacing: 0.2em; font-family: var(--font); font-weight: 600; font-size: 20px; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 0 0 auto; }

.btn { border: 0; border-radius: 4px; box-shadow: inset 0 -4px 0 rgba(0,0,0,.28); padding: 13px 18px; font: 700 18px/1 var(--cond); background: var(--raise); cursor: pointer; min-height: 48px; transition: transform .08s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.warn { background: transparent; box-shadow: inset 0 0 0 2px var(--danger); color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 2px var(--line); }
.btn:focus-visible, .iconbtn:focus-visible, .mapcard:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.link { background: none; border: 0; color: var(--muted); padding: 4px 0; align-self: flex-start; cursor: pointer; }
.back::before { content: '‹ '; }

/* Map picker */
.maps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.mapcard { background: var(--panel); border: 2px solid transparent; border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 6px; align-items: center; cursor: pointer; }
.mapcard canvas { width: 100%; height: 118px; object-fit: contain; border-radius: 4px; }
.mapcard b { font: 700 16px/1 var(--cond); }
.mapcard small { color: var(--muted); font-size: 12px; }
.mapcard.on { border-color: var(--text); }
.mapcard[aria-disabled="true"] { cursor: default; }

/* Lobby */
.bigcode { font: 600 56px/1 var(--font); letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: 10px; padding: 12px 14px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.players .who { flex: 1; }
.players .tag { color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.on { background: var(--ok); }

#recentList { display: flex; flex-direction: column; gap: 8px; }
.recent { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border-radius: 10px; padding: 12px 14px; border: 0; text-align: left; cursor: pointer; }
.recent b { font: 700 19px/1 var(--cond); letter-spacing: .08em; }
.recent span { color: var(--muted); font-size: 13px; }

/* Game screen */
#game.screen { padding: 0; max-width: none; height: 100%; height: 100dvh; min-height: 0; gap: 0; }
#hud { display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-t)) 12px 8px; background: var(--panel); border-bottom: 3px solid var(--accent); }
#turnChip { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#turnChip .day { font: 700 13px/1 var(--cond); color: var(--muted); }
#turnChip .who { font: 700 20px/1 var(--cond); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#funds { font: 700 20px/1 var(--cond); }
#funds { text-align: right; line-height: 1.05; }
#funds small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }
.iconbtn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: var(--raise); display: grid; place-items: center; cursor: pointer; }

#boardWrap { flex: 1; overflow: auto; position: relative; background: #0f161e; display: flex; -webkit-overflow-scrolling: touch; }
#board { margin: auto; display: block; touch-action: manipulation; image-rendering: pixelated; image-rendering: crisp-edges; }
.px { image-rendering: pixelated; image-rendering: crisp-edges; }
#banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: var(--accent); color: #fff; font: 700 32px/1 var(--cond); padding: 14px 26px; border-radius: 0; border: 3px solid #0c1117; text-shadow: 3px 3px 0 rgba(0,0,0,.35); pointer-events: none; white-space: nowrap; box-shadow: 6px 6px 0 rgba(0,0,0,.45); animation: bannerIn 1.6s ease forwards; }
@keyframes bannerIn { 0% { opacity: 0; transform: translate(-60%, -50%); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-40%, -50%); } }

#panel { background: var(--panel); padding: 10px 12px calc(10px + var(--safe-b)); height: calc(172px + var(--safe-b)); flex: none; overflow: auto; display: flex; flex-direction: column; gap: 8px; }

.info { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.info canvas { flex: none; background: #1a2430; border-radius: 4px; }
.info .txt { flex: 1; min-width: 0; }
.info b { font: 700 19px/1.1 var(--cond); display: block; }
.info span { color: var(--muted); font-size: 14px; }
#panel .acts { display: flex; gap: 8px; }
#panel .acts .btn { flex: 1; padding: 12px 8px; }
#panel .hint { color: var(--muted); font-size: 15px; margin: 0; }
.stat { display: inline-block; margin-right: 10px; }
.odds { font: 700 22px/1 var(--cond); }
.odds em { font-style: normal; color: var(--muted); font-size: 15px; font-weight: 600; }

/* Bottom sheet */
.sheet { position: fixed; inset: 0; background: rgba(5, 9, 14, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet-body { background: var(--panel); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 16px 14px calc(16px + var(--safe-b)); max-height: 82vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: .4; } }
.sheet h2 { margin-bottom: 4px; }
.buy { display: flex; align-items: center; gap: 12px; background: var(--raise); border: 0; border-radius: 10px; padding: 8px 12px; text-align: left; cursor: pointer; }
.buy:disabled { opacity: .35; }
.buy .txt { flex: 1; }
.buy b { font: 700 19px/1.1 var(--cond); display: block; }
.buy span { color: var(--muted); font-size: 13px; }
.buy .price { font: 700 19px/1 var(--cond); }
.log { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--muted); }
.log li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.log li i { font-style: normal; color: var(--text); margin-right: 6px; }
.scores { display: flex; flex-direction: column; gap: 6px; }

#toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); background: #0d1218; color: var(--text); padding: 10px 16px; border-radius: 10px; z-index: 30; font-size: 15px; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
#conn { position: fixed; top: calc(8px + var(--safe-t)); left: 50%; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 6px 12px; border-radius: 20px; font-size: 13px; z-index: 40; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Numbers stay in a clear face: the pixel font's 2/5/8 blur together at small sizes. */
#funds, .buy .price, .odds { font-family: var(--font); font-weight: 600; font-variant-numeric: tabular-nums; }

.row.two .btn { flex: 1; }
.addcpu { margin-top: 8px; }
.players .x { background: none; border: 0; color: var(--muted); width: 36px; height: 36px; margin: -8px -8px -8px 0; cursor: pointer; font-size: 18px; }

/* Commanders */
.cos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.co { background: var(--panel); border: 2px solid transparent; border-radius: 6px; padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.co.on { border-color: var(--text); }
.co canvas { width: 40px; height: 40px; }
.co b { font: 700 13px/1.1 var(--cond); text-align: center; }
.coinfo { background: var(--panel); border-radius: 6px; padding: 12px 14px; margin-top: 8px; font-size: 14px; color: var(--muted); }
.coinfo b { color: var(--text); font: 700 17px/1.2 var(--cond); }
.coinfo p { margin: 6px 0 0; }
.coinfo .pw { color: var(--text); }
#meter { display: flex; align-items: center; gap: 4px; background: none; border: 0; padding: 4px; cursor: pointer; }
#meter canvas { width: 26px; height: 26px; }
.stars { display: flex; gap: 2px; }
.star { width: 10px; height: 10px; transform: rotate(45deg); background: #0c1117; box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; position: relative; }
.star i { position: absolute; left: 0; bottom: 0; width: 100%; background: var(--ok); }
#meter.ready .star i { background: #ffd23f; animation: glow .8s steps(2) infinite; }
#meter.active .star i { background: #fff; }
@keyframes glow { 50% { background: #fff6c4; } }
.btn.power { background: #ffd23f; color: #1b1422; }
.tagline { color: #ffd23f; font: 700 15px/1.2 var(--cond); margin: 0; }

.toggles { gap: 8px; flex-wrap: wrap; }
.toggle { background: var(--panel); border: 0; border-radius: 4px; padding: 8px 12px; font: 700 14px/1 var(--cond); color: var(--muted); cursor: pointer; }
.toggle.on { color: var(--text); box-shadow: inset 0 -3px 0 var(--accent); }

.pushhint { font-size: 14px; background: var(--raise); border-radius: 6px; padding: 10px 12px; margin: 0; color: var(--text); }
