/* The frontier ledger: parchment panels in walnut frames with a brass hairline, iron-gall ink, square corners,
   a period serif (IM Fell English SC, Alegreya; SIL OFL, public/fonts). */
@font-face { font-family: 'Fell'; src: url(fonts/im-fell-english-sc.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url(fonts/alegreya.woff2) format('woff2'); font-weight: 400 800; font-display: swap; }
:root { --ink: #2b1a0e; --muted: #5e4a33; --faint: #8a7658; --bg: rgba(233, 221, 192, 0.95); --paper2: #d8c79f; --on: #f7eedb; --paperOn: #f3e9d0;
  --edge: #3a2414; --brass: #a9853f; --accent: #8b1e1e; --ok: #2f4a2a; --navy: #2c4a6e;
  --display: 'Fell', 'IM Fell English SC', Georgia, serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0b10; /* the studio splash's, so nothing flashes green before it paints */ color: var(--ink);
  font: 15px/1.3 'Alegreya', Georgia, serif; overscroll-behavior: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
svg { width: 18px; height: 18px; vertical-align: -4px; flex: none; }

#top { position: fixed; top: max(6px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right));
  display: flex; gap: 6px; align-items: center; pointer-events: none; flex-wrap: wrap; }
.res { background: var(--bg); border: 2px solid var(--edge); border-radius: 2px; padding: 5px 9px; display: flex; gap: 5px; align-items: center; min-width: 64px; }
.res b { font-variant-numeric: tabular-nums; }
.idle { pointer-events: auto; margin-left: auto; background: var(--accent); color: var(--paperOn); border: 0; border-radius: 2px;
  font: inherit; font-weight: 600; min-height: 36px; padding: 0 14px; }
.idle.none { background: var(--bg); color: var(--faint); border: 2px solid var(--edge); }

#panel { position: fixed; left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom));
  display: flex; gap: 10px; align-items: stretch; pointer-events: none; }
#panel:empty { display: none; }
#panel > * { pointer-events: auto; }
.info { background: var(--bg); border: 2px solid var(--edge); border-radius: 2px; padding: 8px 12px; min-width: 170px; max-width: 300px; }
.info h3 { margin: 0 0 2px; font-size: 15px; }
.info p { margin: 0; color: var(--muted); font-size: 12px; }
.info p.hint { color: var(--accent); margin-top: 3px; }
.info .hp { font-size: 11px; font-weight: 400; color: var(--faint); }
.act small { font-size: 11px; color: var(--ok); }
.acts { display: flex; gap: 6px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.act { background: var(--bg); color: var(--ink); border: 2px solid var(--edge); border-radius: 2px; font: inherit;
  min-width: 84px; min-height: 56px; padding: 6px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; flex: none; }
.act:active:not(:disabled) { background: var(--on); }
.act:disabled { color: var(--faint); } .act:disabled svg { opacity: 0.5; }
.act.ok { background: var(--ok); border-color: #2e7d32; font-weight: 600; }
.act span { white-space: nowrap; }
.cost { font-size: 12px; color: var(--muted); display: inline-flex; gap: 2px; align-items: center; }
.cost svg { width: 14px; height: 14px; }
.close { background: var(--bg); color: var(--ink); border: 2px solid var(--edge); border-radius: 2px; width: 48px; font-size: 18px; flex: none; }
.bar { height: 6px; background: #00000066; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); }

#box { position: fixed; display: none; border: 2px solid #7dff8a; background: #7dff8a22; pointer-events: none; }
#toast { position: fixed; top: 54px; left: 50%; transform: translateX(-50%); background: var(--bg); border: 1px solid var(--accent);
  padding: 8px 14px; border-radius: 2px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

/* Gamepad: a cursor, and a ring on the panel button the d-pad picked. */
#cursor { position: fixed; left: -14px; top: -14px; width: 28px; height: 28px; display: none; pointer-events: none;
  border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px #0008; }
#cursor::after { content: ""; position: absolute; left: 11px; top: 11px; width: 2px; height: 2px; background: #fff; }
.pad .act.focus, .pad .close.focus { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Keyboard hints on devices with a mouse: the number that presses each button. */
@media (pointer: fine) {
  .acts { counter-reset: key; }
  .act { position: relative; }
  .act::before { counter-increment: key; content: counter(key); position: absolute; top: 3px; left: 6px; font-size: 11px; color: var(--faint); }
}

/* The minimap, turned 45° to match the camera. */
#minimap { position: fixed; top: calc(max(6px, env(safe-area-inset-top)) + 46px); right: max(10px, env(safe-area-inset-right));
  width: 132px; height: 132px; display: grid; place-items: center; touch-action: none; }
#minimap canvas { width: 94px; height: 94px; image-rendering: pixelated;
  border: 2px solid var(--edge); background: #000; box-shadow: 0 2px 8px #0008; }
#turn { position: fixed; right: max(10px, env(safe-area-inset-right)); top: calc(max(6px, env(safe-area-inset-top)) + 182px); display: flex; gap: 6px; }
#turn button { width: 46px; height: 40px; border-radius: 2px; background: var(--bg); color: var(--ink); border: 2px solid var(--edge); font-size: 20px; line-height: 1; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: #0a0d09cc; z-index: 10; }
.overlay[hidden] { display: none; }
.card { background: var(--bg); border: 2px solid var(--edge); border-radius: 2px; padding: 22px 28px; text-align: center; max-width: 420px; }
.card h1, .card h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: 0.5px; }
.card p { color: var(--muted); margin: 0 0 16px; }
.card .row { display: flex; gap: 10px; justify-content: center; }
.card button, .overlay.scan button { background: var(--accent); color: var(--paperOn); border: 0; border-radius: 2px; font: inherit; font-weight: 700; min-width: 120px; min-height: 48px; }
.card button[data-level="normal"] { background: #8a5a1a; color: var(--paperOn); }
.card button[data-level="hard"] { background: #5e1010; color: var(--paperOn); }
.card .row { flex-wrap: wrap; }

.res.era { font-size: 12px; color: var(--accent); min-width: 0; }
.act.tech, .act.era { max-width: 150px; }
.act.tech span, .act.era span { white-space: normal; text-align: center; } /* long names (and French) wrap */
.act.tech small, .act.era small { white-space: normal; text-align: center; color: var(--muted); line-height: 1.15; }
.act.era { border-color: var(--accent); }
.act small.lock { color: var(--accent); }
.info p.hint.fire { color: #b0401a; font-weight: 600; }
.act.bell { border-color: #c8372d; }

.card .maps { margin-bottom: 12px; }
.card .maps button { background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 8px; font-weight: 400; }
.card .maps button.on { border-color: var(--accent); background: var(--on); }
.card .maps small { font-size: 11px; color: var(--muted); }
.card { max-width: 560px; }

.act.on { border-color: var(--accent); background: var(--on); }
.act.ability { border-color: var(--navy); }
.act.ability small { white-space: normal; text-align: center; color: var(--muted); line-height: 1.15; }
.idle.army { margin-left: auto; background: var(--navy); color: #fff; }
.idle.army + .idle { margin-left: 0; }
#groups { position: fixed; left: max(8px, env(safe-area-inset-left)); top: calc(max(6px, env(safe-area-inset-top)) + 52px); display: flex; flex-direction: column; gap: 6px; }
#groups button { width: 44px; height: 38px; border-radius: 2px; background: var(--bg); color: var(--ink); border: 2px solid var(--edge); font: inherit; font-weight: 700; touch-action: none; }
#groups button.set { border-color: var(--navy); }
#groups button small { display: block; font-size: 11px; font-weight: 400; color: var(--faint); }
#speed { position: fixed; right: max(10px, env(safe-area-inset-right)); top: calc(max(6px, env(safe-area-inset-top)) + 228px); display: flex; gap: 6px; }
#speed button { min-width: 46px; height: 38px; border-radius: 2px; background: var(--bg); color: var(--ink); border: 2px solid var(--edge); font: inherit; font-weight: 700; }
#paused { position: fixed; top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 28px; font-weight: 800; color: #fff; text-shadow: 0 2px 8px #000; pointer-events: none; }
.card .row.small { margin-bottom: 10px; }
.card button.opt { background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); min-height: 34px; min-width: 130px; font-weight: 400; }
#credcard ul { text-align: left; padding-left: 18px; max-height: 55vh; overflow-y: auto; } #credcard li { margin: 6px 0; } #credcard a { color: var(--accent); }

/* Start menu chips: map, players, mode. The card scrolls on short phone screens. */
.overlay .card { max-height: calc((100vh - 16px) / var(--ui, 1)); max-width: min(560px, calc((100vw - 16px) / var(--ui, 1))); overflow-y: auto; }
.card .chips { margin-bottom: 8px; gap: 6px; }
.card .chips button { background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); min-width: 0; min-height: 36px; padding: 4px 10px; font-weight: 400; font-size: 13px; }
.card .chips button.on { border-color: var(--accent); background: var(--on); font-weight: 700; }
.card p.desc { font-size: 12px; margin-bottom: 10px; min-height: 2.4em; }
#objective { position: fixed; top: calc(max(6px, env(safe-area-inset-top)) + 52px); left: 50%; transform: translateX(-50%); background: var(--bg); border: 2px solid var(--edge); border-radius: 2px; padding: 4px 12px; font-size: 13px; pointer-events: none; }
#report table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 10px; }
#report td, #report th { padding: 3px 6px; text-align: right; }
#report td:first-child, #report th:first-child { text-align: left; }
#report svg { width: 100%; height: 110px; margin-bottom: 10px; }
#team { position: fixed; right: max(10px, env(safe-area-inset-right)); top: calc(max(6px, env(safe-area-inset-top)) + 272px); display: flex; gap: 6px; }
#team button { height: 38px; padding: 0 10px; border-radius: 2px; background: var(--bg); color: var(--ink); border: 2px solid var(--edge); font: inherit; font-size: 13px; font-weight: 700; }
#report ul.moments { text-align: left; font-size: 12px; margin: 0 0 10px; padding-left: 18px; color: var(--muted); }
/* Short screens (a phone on its side): drop the intro line so the difficulty buttons fit. */
@media (max-height: 500px) {
  #menu .card > h1 + p { display: none; } /* the start menu's blurb only, not a campaign or briefing line */
  .card h1 { font-size: 20px; margin-bottom: 8px; }
  .card { padding: 12px 18px; }
  .card .chips button { min-height: 32px; font-size: 12px; }
  .card button[data-level] { min-height: 40px; }
}

/* Charters and the Capital */
.idle.charter { margin-left: 0; background: #7a5a22; color: #fff; }
.idle.charter.none { background: var(--bg); color: var(--faint); }
.act.card.sent { opacity: 0.55; }
.card.wide { max-width: 760px; width: calc((100vw - 32px) / var(--ui, 1)); }
.cap-town { width: 100%; height: 90px; display: block; margin: 4px 0 8px; }
.cap-town3d { width: 100%; height: min(42vh, 300px); display: block; margin: 4px 0 8px; border-radius: 6px; background: linear-gradient(#9fc0dc, #dfe8ec); }
.xpbar { height: 8px; background: var(--paper2); border-radius: 2px; overflow: hidden; margin: 4px 0 10px; }
.xpbar i { display: block; height: 100%; background: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin: 8px 0 12px; text-align: left; }
.card .cards button { background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); min-width: 0; min-height: 52px; padding: 6px; font-weight: 400; font-size: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.card .cards button.in { border-color: var(--accent); background: var(--on); font-weight: 700; }
.card .cards button:disabled { opacity: 0.45; }
.card .cards small { font-size: 11px; color: var(--muted); font-weight: 400; }
.cards h4 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 13px; color: var(--accent); }

/* Settings, and the text and button size (zoom on the HUD's pieces) */
#top, #panel, #groups, #speed, #team, #turn, #objective, .overlay .card { zoom: var(--ui, 1); }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0; text-align: left; }
.setrow > span { font-size: 13px; color: var(--muted); min-width: 110px; }
.setrow .row.chips { margin: 0; justify-content: flex-end; }
.setrow input[type=range] { flex: 1; max-width: 320px; accent-color: var(--accent); min-height: 32px; }
.card h3 { margin: 12px 0 4px; font-size: 15px; color: var(--accent); text-align: left; }
.binds { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 8px; }
.card .binds button { background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); min-width: 0; min-height: 46px; padding: 4px 8px; font-weight: 400; display: flex; flex-direction: column; align-items: flex-start; }
.card .binds button.on { border-color: var(--accent); background: var(--on); }
.card .binds small { font-size: 11px; color: var(--muted); }

/* In the tutorial, toasts go below the guide box instead of under it. */
body:has(#tutor:not([hidden])) #toast { top: calc(max(6px, env(safe-area-inset-top)) + 140px); }
#tutor { position: fixed; top: calc(max(6px, env(safe-area-inset-top)) + 52px); left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 140px)); background: var(--bg); border: 2px solid var(--accent); border-radius: 2px; padding: 8px 12px; font-size: 15px; line-height: 1.3; zoom: var(--ui, 1); z-index: 5; }
#tutor small { display: block; color: var(--accent); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
#tutor button { margin-left: 8px; background: var(--accent); color: var(--paperOn); border: 0; border-radius: 2px; padding: 6px 12px; font: inherit; font-weight: 700; min-height: 40px; }

.card button.locked { opacity: 0.6; }
#unlock { margin-top: 10px; border-color: var(--accent); }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 2px; vertical-align: middle; } .tag.foe { background: #c8372d; color: #fff; } .tag.ally { background: #2e7d32; color: #fff; }
[hidden] { display: none !important; }
#menu .card p { margin-bottom: 8px; }
#menu .row { margin-bottom: 8px; }
#adinstall { position: fixed; right: 10px; bottom: 10px; z-index: 6; background: var(--accent); color: var(--paperOn); border: 0; border-radius: 2px; font: inherit; font-weight: 800; padding: 10px 18px; min-height: 44px; }

/* The map editor: its tool bar along the bottom; the match HUD hidden. */
body.editing #top, body.editing #panel, body.editing #groups, body.editing #speed, body.editing #find, body.editing #gear, body.editing #save, body.editing #pause, body.editing #team, body.editing #objective, body.editing #tutor { display: none !important; }
#editor { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); background: #3a2414f0; border-top: 1px solid var(--edge); }
#editor .tools { display: flex; gap: 6px; overflow-x: auto; padding: 3px 0; scrollbar-width: none; }
#editor button { flex: none; min-height: 40px; padding: 6px 12px; border-radius: 2px; border: 1px solid var(--edge); background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; }
#editor button.on { background: var(--accent); color: var(--paperOn); border-color: var(--accent); font-weight: 700; }

/* The Wi-Fi lobby. */
#lobby .qr { background: #fff; width: min(320px, 80vw); margin: 8px auto; border-radius: 2px; }
#lobby .qr svg { display: block; width: 100%; height: auto; }
#lobby textarea { width: 100%; box-sizing: border-box; font: 12px/1.3 monospace; background: var(--on); color: var(--ink); border: 1px solid var(--edge); border-radius: 2px; padding: 8px; }
#lobby .seats { list-style: none; padding: 0; margin: 8px 0; }
#lobby .seats li { padding: 4px 0; border-bottom: 1px solid var(--faint); }
/* The camera view for scanning a code. */
.overlay.scan { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: #000; z-index: 60; }
.overlay.scan video { width: min(92vw, 520px); max-height: 70vh; object-fit: cover; border-radius: 2px; }
.overlay.scan p { color: #f4ead2; margin: 0; }
/* The editor's triggers panel. */
#editor .rules { background: var(--bg); border: 2px solid var(--edge); border-radius: 2px; padding: 8px 12px; margin-top: 6px; max-height: 45vh; overflow: auto; pointer-events: auto; }
#editor .rules ul { list-style: none; padding: 0; margin: 0 0 6px; }
#editor .rules li { padding: 3px 0; }
#editor .rules p { margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
#editor .tools select, #editor .rules select, #editor .rules input { background: var(--on); color: var(--ink); border: 2px solid var(--edge); border-radius: 2px; padding: 4px 6px; font: inherit; max-width: 100%; }
#editor .rules input[type="number"] { width: 70px; }
/* The campaign's mission list. */
#menu .missions { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 12px; }
#menu .missions button { text-align: left; background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); font-weight: 400; }
#menu .missions button b { color: var(--accent); margin-right: 6px; }
#menu .missions button:disabled { opacity: 0.55; }
#menu .card > [hidden] { display: none !important; } /* the start menu under a mission briefing */
#menu .card { max-height: calc(100dvh - 24px); overflow-y: auto; } /* a long list (the campaign) scrolls on a landscape phone */

/* The custom match: a row per player, its colour, side and civilization. */
.card .custom { margin: 0 0 10px; }
.card .custom .slot { display: flex; align-items: center; gap: 8px; margin: 4px 0; flex-wrap: wrap; font-size: 13px; }
.card .custom .swatch { width: 14px; height: 14px; border-radius: 2px; border: 1px solid #0006; flex: none; }
.card .custom select { background: var(--paper2); color: var(--ink); border: 2px solid var(--edge); border-radius: 2px; min-height: 32px; padding: 2px 6px; font-size: 13px; }
.card .custom .hint { margin: 2px 0 6px; font-size: 12px; opacity: 0.8; }

/* Ledger finish: frames get a brass hairline inside and a drop shadow onto the map; titles in the period face. */
.res, .info, .act, .close, .idle, #turn button, #groups button, #speed button, #team button, #objective, #toast, #tutor, .card, #minimap canvas, #editor .rules {
  box-shadow: inset 0 0 0 1px var(--brass), 0 2px 6px #0007; }
.idle { border: 2px solid var(--edge); }
.idle.none { color: var(--faint); }
.act.ok, .card button[data-level="easy"] { background: var(--ok); color: var(--paperOn); border-color: var(--edge); }
.card h1, .card h2, .card h3, .info h3, .cards h4, #tutor small, #paused { font-family: var(--display); font-weight: 400; letter-spacing: 0.3px; }
.idle, #groups button, #speed button, #team button { font-variant: small-caps lining-nums tabular-nums; font-weight: 700; letter-spacing: 0.3px; }
.card h1, .card h2 { font-size: 30px; color: var(--accent); }
.res b { font-variant-numeric: lining-nums tabular-nums; }
.res b { font-size: 16px; }
.act:active:not(:disabled) { background: var(--paper2); }
.bar, .xpbar { background: #3a241433; }
/* Civilization and map: a filter box and a dropdown on one line. */
.card .picker { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: nowrap; }
.card .picker label { font-family: var(--display); min-width: 92px; text-align: left; color: var(--muted); }
.card .picker input, .card .picker select { font: inherit; color: var(--ink); background: var(--on); border: 2px solid var(--edge); border-radius: 2px;
  box-shadow: inset 0 0 0 1px var(--brass); min-height: 40px; padding: 4px 8px; }
.card .picker input { width: 120px; flex: none; user-select: text; -webkit-user-select: text; }
.card .picker select { flex: 1; min-width: 0; }
@media (max-height: 500px) { .card .picker input, .card .picker select { min-height: 34px; } }
#groups label { font-family: var(--display); font-size: 12px; text-align: center; color: var(--paperOn); text-shadow: 0 1px 3px #000, 0 0 2px #000; }
/* A shorter bottom panel: costs side by side, descriptions held to two lines, upgrade buttons wider instead of taller. */
.costs { display: flex; gap: 8px; }
/* A fixed width: sized to its text, the card grew as a queue's hint lengthened and slid every button beside it under the finger. */
.info { width: 300px; max-width: none; flex: none; box-sizing: border-box; }
.info p.hint { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.info p:not(.hint) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.act.tech, .act.era { max-width: 230px; }
.act.tech small, .act.era small { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
/* Panel text: Compact (the default) sets the bottom panel in smaller type and tighter buttons, so it takes less of the map; Large is the original. */
body.compact #panel { font-size: 13px; }
body.compact .info { padding: 6px 10px; }
body.compact .info h3 { font-size: 13px; }
body.compact .info p { font-size: 11px; }
body.compact .info .hp, body.compact .act small { font-size: 11px; }
body.compact .cost { font-size: 11px; }
body.compact .cost svg { width: 12px; height: 12px; }
body.compact .act { min-width: 72px; min-height: 46px; padding: 4px 6px; gap: 2px; }
body.compact .act.tech, body.compact .act.era { max-width: 200px; }
/* The controls tab: slides the turn and speed rows off the right edge and back. */
#tools { position: fixed; right: 0; top: calc(max(6px, env(safe-area-inset-top)) + 182px); width: 24px; height: 86px; zoom: var(--ui, 1);
  background: var(--bg); color: var(--ink); border: 2px solid var(--edge); border-right: 0; border-radius: 2px 0 0 2px; font: inherit; font-size: 20px; font-weight: 700; padding: 0;
  box-shadow: inset 0 0 0 1px var(--brass), 0 2px 6px #0007; }
#turn, #speed { right: calc(max(10px, env(safe-area-inset-right)) + 22px); transition: transform 0.25s ease, opacity 0.25s ease; }
body.tools-hidden #turn, body.tools-hidden #speed { transform: translateX(120%); opacity: 0; pointer-events: none; }
body.editing #tools { display: none; }

/* Gamepad buttons in Settings drawn as buttons, not plain text. */
.card .binds b.padkey { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px; background: var(--bg); border: 2px solid var(--edge); font-size: 13px; }
#editor .tools .hint { align-self: center; white-space: nowrap; font-size: 14px; color: var(--paperOn); }
/* A mission's opening scene: black bars above and below, the title in the lower one. */
#intro { position: fixed; inset: 0; z-index: 100; pointer-events: auto; }
#intro::before, #intro::after { content: ''; position: absolute; left: 0; right: 0; height: 14vh; background: #000; animation: introBars 0.6s ease-out; }
#intro::before { top: 0; } #intro::after { bottom: 0; height: 30vh; }
#intro .cap { position: absolute; left: 0; right: 0; bottom: 2vh; z-index: 1; text-align: center; color: #f3e6c8; text-shadow: 0 1px 3px #000; animation: introCap 1.6s ease-out; }
#intro h2 { margin: 0; font-size: 28px; letter-spacing: 0.04em; }
#intro p { margin: 2px 0; } #intro .obj { font-weight: 700; } #intro .hint { opacity: 0.6; font-size: 13px; }
@keyframes introBars { from { transform: scaleY(0); } }
@keyframes introCap { from { opacity: 0; } 40% { opacity: 0; } }
body.intro-on > *:not(#intro):not(#game) { visibility: hidden; }
/* The replay list: one match a row, its buttons to the right. */
#repcard ul.replays { list-style: none; padding: 0; margin: 8px 0; max-height: 55vh; overflow-y: auto; text-align: left; }
#repcard ul.replays li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--edge); }
#repcard ul.replays li span:last-child { display: flex; gap: 6px; flex: none; }
#repcard ul.replays small { opacity: 0.7; margin-left: 6px; }
#repcard [data-del] { min-width: 0; width: 44px; padding: 0; }

/* The web demo's statistics (src/ui/stats.ts): the one-time question, and the feedback card after a match. */
#feedback { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); }
#feedback .card { max-width: min(480px, 94vw); max-height: 94vh; overflow-y: auto; text-align: center; padding-top: 10px; padding-bottom: 10px; }
#feedback h2 { margin-bottom: 4px; }
#feedback .rate { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0; text-align: left; }
#feedback .rate .row { gap: 6px; }
#feedback .rate .row button { padding: 4px 12px; min-width: 0; }
#feedback .stars { display: flex; gap: 0; }
#feedback .rate { margin: 0; }
#feedback .stars button { padding: 0 3px !important; line-height: 1.1; min-height: 0; margin: 0; }
#feedback .card { background: #e9dcb8; }
#feedback .stars button { background: none; color: var(--muted); font-size: 26px; padding: 0 4px; border: 0; min-width: 0; width: auto; box-shadow: none; }
#feedback .stars button.on { color: #e3a92b; }
#feedback [data-p].on { outline: 3px solid #e3a92b; }
#feedback textarea { width: 100%; min-height: 56px; margin: 6px 0; font: inherit; font-size: 16px; border-radius: 6px; padding: 8px; box-sizing: border-box; }

#signup { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); }
#signup .card { max-width: min(460px, 94vw); max-height: 94vh; overflow-y: auto; background: #e9dcb8; text-align: center; }
#signup input[type=email], #signup input[inputmode] { width: 100%; font: inherit; font-size: 16px; padding: 9px; border-radius: 6px; border: 2px solid var(--edge); box-sizing: border-box; margin: 4px 0 8px; }
#signup .tick { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 14px; color: var(--muted); margin: 0 0 10px; }
#signup .tick input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
#signup .err { color: #9b1c1c; margin: 8px 0 0; } #signup .small { font-size: 12px; margin: 10px 0 0; } #signup a { color: #8a5a1a; }

#agree { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(10, 13, 9, 0.82); }
#agree .card { max-width: min(520px, 94vw); max-height: 94vh; overflow-y: auto; background: #e9dcb8; text-align: center; }
#agree a { color: #8a5a1a; } #agree .tick { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 14px; color: var(--muted); margin: 0 0 12px; }
#agree .tick input { margin-top: 3px; width: 18px; height: 18px; flex: none; }

#signup .names button, #namepick .names button { font-size: 14px; padding: 6px 10px; }
#signup .names button.on, #namepick .names button.on { outline: 3px solid #e3a92b; }
#signup .pick p { margin: 8px 0 4px; }
/* The gamer-tag chooser: the four tags, then "Show me 4 more" on its own line with room above it. */
#signup .pick .names, #namepick .pick .names { gap: 8px; flex-wrap: wrap; justify-content: center; }
#signup .pick .row + .row, #namepick .pick .row + .row { margin-top: 12px; }
#signup .pick, #namepick .pick { margin-bottom: 14px; }
/* What's in the full game (src/ui/fullgame.ts). */
#fullgame { z-index: 75; }
#fullgame .card { max-width: min(600px, 94vw); max-height: 94vh; overflow-y: auto; text-align: left; background: #e9dcb8; }
#fullgame h2, #fullgame .price, #fullgame .row, #fullgame .hint { text-align: center; }
#fullgame h3 { margin: 14px 0 4px; font-size: 17px; color: #8a2b1a; }
#fullgame ul { margin: 0; padding-left: 20px; } #fullgame li { margin: 4px 0; }
#fullgame p { margin: 4px 0; color: var(--ink, #2b1a0e); } #fullgame .hint { font-size: 12px; margin-top: 10px; color: var(--muted); }
#signup .danger { color: #9b1c1c; border-color: #9b1c1c; }
#signup .who { margin-bottom: 4px; }
/* The leaderboard (src/ui/board.ts): the chosen tab, the player's own row, even columns. */
#fullgame .board { min-width: min(460px, 94vw); }
#fullgame .board [data-t] { opacity: 0.6; } #fullgame .board [data-t].on { opacity: 1; outline: 3px solid #e3a92b; }
#fullgame .board table { width: 100%; border-collapse: collapse; margin: 6px 0 10px; }
#fullgame .board td { padding: 4px 8px; border-bottom: 1px solid #cdb98a; } #fullgame .board td:nth-child(3) { text-align: right; font-weight: 600; }
#fullgame .board tr.me td { background: #f2d98d; font-weight: 700; } #fullgame .board tr.gap td { text-align: center; color: var(--muted); border: 0; }
/* The map marketplace (src/ui/market.ts): one compact row per map, its buttons small at the right. */
#fullgame .market { min-width: min(560px, 94vw); }
#fullgame .market [data-s] { opacity: 0.6; } #fullgame .market [data-s].on { opacity: 1; outline: 3px solid #e3a92b; }
#fullgame .market input[type=search] { width: 100%; box-sizing: border-box; margin: 8px 0; padding: 6px 8px; font: inherit; }
#fullgame .market .map { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid #cdb98a; text-align: left; }
#fullgame .market .map .acts { display: flex; gap: 4px; flex-shrink: 0; }
#fullgame .market .map button { min-width: 0; width: auto; padding: 6px 12px; margin: 0; }
#fullgame .market .muted { color: var(--muted); font-size: 0.9em; }
#fullgame .market .map > div:first-child { flex: 1; }
/* Map previews in the marketplace: a small picture on each row, and the large one on its own card. */
.pvthumb, #fullgame .market .map .pv canvas { display: block; width: 72px; height: 72px; border: 1px solid #5a4630; border-radius: 3px; cursor: zoom-in; image-rendering: pixelated; }
.pvbig { z-index: 80; } .pvbig .card { background: #e9dcb8; text-align: center; } .pvbig canvas { display: block; margin: 6px auto; width: min(300px, 62vh); height: min(300px, 62vh); border: 2px solid #5a4630; image-rendering: pixelated; }
#maps .pvthumb { width: 44px; height: 44px; flex-shrink: 0; margin-left: 6px; }

/* Phones held upright: ask for landscape (the HUD, cards and map need the width). */
#sideways { display: none; }
@media (orientation: portrait) and (pointer: coarse) and (max-width: 900px) {
  #sideways { display: flex; position: fixed; inset: 0; z-index: 10000; align-items: center; justify-content: center; text-align: center; background: #14110c; color: #f1e7cf; font-size: 1.3rem; padding: 24px; }
  #sideways svg { width: 72px; height: 72px; display: block; margin: 0 auto; }
  #sideways p { margin-top: 12px; }
}

/* What a row of choices is for (Difficulty, Map size, Town colour...). */
.card p.lbl { font-family: var(--display); color: var(--muted); font-size: 0.95rem; margin: 12px 0 4px; text-align: center; }
#sideways button { margin-top: 18px; font: inherit; font-size: 1.1rem; padding: 12px 22px; background: #8b1e1e; color: #f6efdd; border: 2px solid #5c1010; border-radius: 4px; }
/* The selection panel on a phone: the card gives the buttons more room (its text kept to two lines), and the button
   row fades at its right edge, which says it scrolls (the last button looked cut off). */
.acts { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); padding-right: 36px; }
@media (pointer: coarse) and (max-height: 500px) {
  .info { width: 30vw; min-width: 0; }
  .info p:not(.hint) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
/* A short screen (a phone with the browser bar showing): with something selected, the groups column and the right-hand
   controls slide away, since they covered the selection panel's card and buttons. They come back when it closes. */
@media (max-height: 380px) {
  body:has(#panel:not(:empty)) #groups { transform: translateX(-130%); opacity: 0; pointer-events: none; }
  body:has(#panel:not(:empty)) #turn, body:has(#panel:not(:empty)) #speed, body:has(#panel:not(:empty)) #tools { transform: translateX(130%); opacity: 0; pointer-events: none; }
  #groups, #tools { transition: transform 0.25s ease, opacity 0.25s ease; }
}

/* ?aidebug=1: what the AI is thinking (a test view) */
#aidebug:empty { display: none; }
#aidebug { position: fixed; left: 170px; top: 64px; z-index: 50; margin: 0; padding: 6px 8px; font: 11px/1.35 ui-monospace, monospace; color: #e8f4e8; background: rgba(0,0,0,.72); pointer-events: none; white-space: pre; max-width: 60vw; }
