/* Takeoff Window — situation-room briefing aesthetic */

:root {
  --bg: #090b0f;
  --bg-2: #10131a;
  --surface: #151922;
  --surface-2: #1c212c;
  --surface-3: #242a36;
  --border: #2c3342;
  --border-s: #3a4254;
  --text: #e8e4d8;
  --text-dim: #b7b3a8;
  --muted: #8a8696;
  --faint: #5c5868;
  --amber: #e0b44a;
  --amber-dim: #a8842e;
  --cyan: #4ec4d4;
  --green: #6fc9a0;
  --red: #e05d5d;
  --violet: #9b7dff;
  --pink: #e07aa8;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font-display: "Cormorant Garamond", "Palatino Linotype", Palatino, "Iowan Old Style", Georgia, serif;
  --font-sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-sans);
  background:
    radial-gradient(1000px 560px at 12% -8%, rgba(224, 180, 74, 0.07), transparent 50%),
    radial-gradient(800px 480px at 100% 0%, rgba(78, 196, 212, 0.05), transparent 45%),
    radial-gradient(600px 400px at 80% 110%, rgba(155, 125, 255, 0.04), transparent 50%),
    var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow: hidden;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Title / faction screens ---------- */
.screen-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  padding: 28px 24px 36px;
  overflow: auto;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(48px, 8vw, 92px);
  letter-spacing: 0.06em;
  line-height: 0.9;
  margin: 0;
  text-transform: uppercase;
  background: linear-gradient(180deg, #f3ecd8 20%, #c9a227 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}
.wordmark em { font-style: italic; font-weight: 500; letter-spacing: 0.08em; }
.subtitle {
  margin: 14px 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 22px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.gold-rule {
  width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  margin: 28px 0;
  border: 0;
}
.lede {
  max-width: 540px;
  text-align: center;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1.55;
  margin: 0 0 32px;
}
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn {
  appearance: none;
  border: 1px solid var(--border-s);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--surface-3); border-color: var(--amber-dim); }
.btn-primary {
  background: linear-gradient(180deg, #c9a227, #9a7818);
  border-color: #e0b44a;
  color: #1a1406;
}
.btn-primary:hover { background: linear-gradient(180deg, #e0b44a, #c9a227); }
.btn-ghost { background: transparent; }
.btn-danger { border-color: #7a3030; color: #f0c0c0; }
.btn-danger:hover { background: #3a1818; }
.btn-sm { padding: 6px 12px; font-size: 11px; letter-spacing: 0.06em; }
.btn-kind-control { border-color: #3d6a4a; color: var(--green); }
.btn-kind-control:hover { background: #173024; }
.btn-kind-neutralize { border-color: #8a7040; color: var(--amber); }
.btn-kind-neutralize:hover { background: #2a2414; }
.btn-kind-destroy { border-color: #7a3030; color: var(--red); }
.btn-kind-destroy:hover { background: #3a1818; }
.disclaimer {
  margin-top: 48px;
  max-width: 560px;
  text-align: center;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.5;
}
.years {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin-bottom: 8px;
}

/* Faction select */
.faction-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 300px));
  gap: 16px;
  max-width: 1000px;
  margin: 8px 0 24px;
}
@media (max-width: 900px) and (min-width: 821px) {
  .faction-grid { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
}
.faction-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  text-align: left;
  color: inherit;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.faction-card:hover { transform: translateY(-2px); border-color: var(--border-s); }
.faction-card.selected {
  border-color: var(--fc, var(--amber));
  box-shadow: 0 0 0 1px var(--fc, var(--amber)), var(--shadow);
}
.faction-card .stripe {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--fc, var(--amber));
}
.faction-card h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin: 6px 0 2px;
}
.faction-card .motto {
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 10px;
}
.faction-card .stats {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}
.faction-card .flavor, .faction-card .goal, .faction-card .ability {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-dim);
  margin: 0 0 8px;
}
.faction-card .goal { color: var(--text); }
.faction-card .label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 10px 0 2px;
}
.screen-center h2.choose {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 32px;
  margin: 0 0 4px;
}
.ai-count {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
  display: flex;
  gap: 12px;
  align-items: center;
}
.ai-count label { display: flex; gap: 6px; align-items: center; cursor: pointer; }

/* ---------- Game chrome ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: rgba(16, 19, 26, 0.85);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  min-width: 0;
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0;
  font-weight: 600;
}
.topbar .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 16px;
  letter-spacing: 0.04em;
}
.topbar .meta strong { color: var(--text); font-weight: 500; }
.topbar .spacer { flex: 1; }
.whose {
  font-size: 13px;
  color: var(--cyan);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.whose.rival { color: var(--pink); }
.whose.over { color: var(--amber); }

.board {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) minmax(240px, 340px);
  grid-template-rows: 1fr auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  gap: 0;
}
.col {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
}
.col-right { border-right: 0; border-left: 1px solid var(--border); }
.col-center { background: linear-gradient(180deg, rgba(255,255,255,0.01), transparent 40%); }

.panel-head {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 14px 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

/* Player panel */
.you-card {
  margin: 8px 12px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.you-card .stripe { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--fc); }
.you-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 4px 0 0;
  font-weight: 600;
}
.you-card .motto { font-style: italic; color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.meters { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.meter {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 6px 7px;
  border: 1px solid var(--border);
  min-width: 0;
}
.meter .k {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.meter .v { font-family: var(--font-display); font-size: 26px; font-weight: 600; line-height: 1; }
.meter.money .v { color: var(--amber); }
.meter.compute .v { color: var(--cyan); }
.meter.groups .v { color: var(--text); }
.meter.actions .v { color: var(--green); }
.goal-box {
  background: var(--bg-2);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.goal-box strong { color: var(--violet); font-weight: 600; letter-spacing: 0.08em; font-size: 10px; text-transform: uppercase; font-family: var(--font-mono); display: block; margin-bottom: 4px; }
.progress {
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}
.progress > i { display: block; height: 100%; background: var(--fc, var(--violet)); width: 0%; transition: width 0.4s; }

/* Log */
.log {
  flex: 1;
  overflow: auto;
  padding: 4px 14px 16px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  min-height: 0;
}
.log .entry { margin: 0 0 7px; }
.log .entry .when {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--faint);
  letter-spacing: 0.06em;
  margin-right: 6px;
}
.log .entry.event { color: var(--violet); }
.log .entry.attack.ok { color: var(--green); }
.log .entry.attack.fail { color: var(--red); }
.log .entry.win { color: var(--amber); font-weight: 600; }
.log .entry.time { color: var(--amber-dim); font-style: italic; margin-top: 10px; }

/* Uncontrolled market */
.market {
  display: flex;
  gap: 8px;
  padding: 0 12px 10px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  min-height: 148px;
  min-width: 0;
  max-width: 100%;
  align-items: stretch;
}
.gcard {
  flex: 0 0 168px;
  width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  text-align: left;
  color: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.gcard:hover { border-color: var(--border-s); transform: translateY(-1px); }
.gcard.selected {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber);
}
.gcard.privileged::after {
  content: "PRIV";
  position: absolute;
  top: 18px; right: 6px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  color: var(--cyan);
  border: 1px solid var(--cyan);
  padding: 1px 4px;
  border-radius: 2px;
}
.gcard .typebar {
  height: 4px;
  background: var(--tc, var(--muted));
}
.gcard .body { padding: 8px 10px 9px; flex: 1; display: flex; flex-direction: column; }
.gcard .type {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tc, var(--muted));
}
.gcard .name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
  margin: 1px 0 0;
}
.gcard .title { font-size: 10px; color: var(--muted); font-style: italic; margin: 0 0 6px; }
.gcard .nums {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  gap: 7px;
  margin-top: auto;
}
.gcard .nums b { color: var(--text); font-weight: 500; }
.pills { display: flex; flex-wrap: wrap; gap: 3px; margin: 5px 0 4px; }
.pill {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid var(--pc, var(--border));
  color: var(--pc, var(--muted));
}

/* Tree */
.tree-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 8px 16px;
  position: relative;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 28px 28px;
}
.tree-wrap svg { display: block; margin: 0 auto; overflow: visible; }
.node-g { cursor: pointer; }
.node-g.selected .node-bg { stroke: var(--amber); stroke-width: 2; }
.node-g:hover .node-bg { stroke: var(--border-s); }
.node-bg { fill: var(--surface); stroke: var(--border); stroke-width: 1; }
.node-g.patron .node-bg { fill: #1a1d14; }
.node-title {
  font-family: "Cormorant Garamond", Palatino, Georgia, serif;
  font-size: 13px;
  font-weight: 600;
  fill: var(--text);
}
.node-title.long { font-size: 12px; }
.node-sub { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 8px; fill: var(--muted); }
.node-num { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 9px; fill: var(--text-dim); }
.socket-ghost { fill: none; stroke: var(--faint); stroke-dasharray: 3 3; }
.tree-edge { fill: none; stroke-width: 1.4; opacity: 0.85; }
.priv-tag { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 7px; fill: var(--cyan); letter-spacing: 0.5px; }

/* Rivals */
.rivals { flex: 1; overflow: auto; padding: 0 10px 12px; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.rival {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 10px 8px;
  cursor: pointer;
  transition: border-color 0.12s;
}
.rival:hover, .rival.active { border-color: var(--border-s); }
.rival.current { border-color: var(--pink); }
.rival-head { display: flex; align-items: baseline; gap: 8px; }
.rival-head h3 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0;
  font-weight: 600;
  flex: 1;
}
.rival-head .dots { font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
.rival-meters { display: flex; gap: 10px; font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); margin: 4px 0 6px; }
.rival-meters .m { color: var(--amber); }
.rival-meters .c { color: var(--cyan); }
.rival-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.rchip {
  font-size: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--tc, var(--muted));
  border-radius: 3px;
  padding: 2px 6px;
  color: var(--text);
  cursor: pointer;
}
.rchip.selected { border-color: var(--amber); background: #2a2414; }
.rchip.privileged { opacity: 0.7; }

/* Action dock */
.dock {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  background: rgba(16, 19, 26, 0.95);
  padding: 10px 16px 12px;
  display: flex;
  gap: 16px;
  align-items: stretch;
  min-height: 86px;
  flex-shrink: 0;
}
.dock-info { flex: 1; min-width: 0; }
.dock-info h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 0;
  font-weight: 600;
}
.dock-info .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.dock-info .flavor { font-size: 12.5px; color: var(--text-dim); font-style: italic; margin: 4px 0 0; max-width: 780px; }
.dock-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.hint { color: var(--faint); font-size: 12px; font-style: italic; align-self: center; }

/* Modal */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 9, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-s);
  border-radius: 12px;
  width: min(560px, 100%);
  box-shadow: var(--shadow);
  padding: 22px 24px 20px;
  max-height: 90vh;
  overflow: auto;
}
.modal.wide { width: min(720px, 100%); }
.modal h2 {
  font-family: var(--font-display);
  font-size: 28px;
  margin: 0 0 4px;
  font-weight: 600;
}
.modal .lead { color: var(--muted); margin: 0 0 16px; font-style: italic; }
.formula {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 14px;
}
.formula strong { color: var(--text); }
.formula .good { color: var(--green); }
.formula .bad { color: var(--red); }
.spend-row { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.spend-row input[type=range] { flex: 1; accent-color: var(--amber); }
.odds {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  color: var(--amber);
  line-height: 1;
}
.odds span { font-size: 14px; color: var(--muted); font-family: var(--font-sans); font-weight: 400; display: block; }
.attacker-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.attacker-picks button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
}
.attacker-picks button.on { border-color: var(--amber); background: #2a2414; }

/* Dice */
.dice-row { display: flex; align-items: center; gap: 14px; margin: 12px 0 8px; min-height: 72px; }
.die {
  width: 56px;
  height: 56px;
  background: linear-gradient(180deg, #f3ecd8, #cfc6ae);
  border-radius: 8px;
  box-shadow: 0 4px 0 #8a7e5c, 0 8px 16px rgba(0,0,0,0.4);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  gap: 3px;
  color: #1a1406;
}
.die i { width: 8px; height: 8px; border-radius: 50%; background: #1a1406; justify-self: center; align-self: center; visibility: hidden; }
.die[data-v="1"] i:nth-child(5) { visibility: visible; }
.die[data-v="2"] i:nth-child(1), .die[data-v="2"] i:nth-child(9) { visibility: visible; }
.die[data-v="3"] i:nth-child(1), .die[data-v="3"] i:nth-child(5), .die[data-v="3"] i:nth-child(9) { visibility: visible; }
.die[data-v="4"] i:nth-child(1), .die[data-v="4"] i:nth-child(3), .die[data-v="4"] i:nth-child(7), .die[data-v="4"] i:nth-child(9) { visibility: visible; }
.die[data-v="5"] i:nth-child(1), .die[data-v="5"] i:nth-child(3), .die[data-v="5"] i:nth-child(5), .die[data-v="5"] i:nth-child(7), .die[data-v="5"] i:nth-child(9) { visibility: visible; }
.die[data-v="6"] i:nth-child(1), .die[data-v="6"] i:nth-child(3), .die[data-v="6"] i:nth-child(4), .die[data-v="6"] i:nth-child(6), .die[data-v="6"] i:nth-child(7), .die[data-v="6"] i:nth-child(9) { visibility: visible; }
.die.spin { animation: dspin 0.45s ease-in-out; }
@keyframes dspin {
  0% { transform: rotateX(0) rotateY(0); }
  50% { transform: rotateX(180deg) rotateY(90deg); }
  100% { transform: rotateX(360deg) rotateY(0); }
}
.roll-sum {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 600;
}
.roll-res { font-family: var(--font-mono); letter-spacing: 0.16em; font-size: 14px; font-weight: 600; }
.roll-res.ok { color: var(--green); }
.roll-res.fail { color: var(--red); }

/* Event banner */
.event-banner {
  margin: 6px 12px;
  background: linear-gradient(90deg, rgba(155, 125, 255, 0.15), rgba(155, 125, 255, 0.05));
  border: 1px solid rgba(155, 125, 255, 0.35);
  border-radius: 8px;
  padding: 6px 12px;
  flex-shrink: 0;
}
.event-banner .k {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--violet);
}
.event-banner h3 { font-family: var(--font-display); font-size: 18px; margin: 0; font-weight: 600; }
.event-banner p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tree-wrap { flex: 1; min-height: 140px; min-width: 0; overflow: auto; }

/* Help */
.help-body { font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.help-body h3 {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 20px;
  margin: 18px 0 6px;
  font-weight: 600;
}
.help-body h3:first-child { margin-top: 0; }
.help-body ul { margin: 0; padding-left: 18px; }
.help-body li { margin: 0 0 6px; }
.help-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Victory */
.victory {
  text-align: center;
  padding: 12px 8px 4px;
}
.victory .k {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--amber);
}
.victory h2 { font-size: 40px; margin: 6px 0 10px; }
.victory p { font-size: 16px; color: var(--text-dim); max-width: 480px; margin: 0 auto 18px; line-height: 1.5; }

/* Toast / status */
.status-bar {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--cyan);
  padding: 0 14px 8px;
}

@media (max-width: 1100px) {
  .board { grid-template-columns: 260px 1fr; }
  .col-right { display: none; }
  .board.show-rivals .col-right { display: flex; position: absolute; right: 0; top: 52px; bottom: 90px; width: 320px; background: var(--bg); z-index: 8; }
}

/* ---------- Additions ---------- */
input[type="text"], input[type="number"], select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}
input[type="text"]:focus, input[type="number"]:focus, select:focus {
  border-color: var(--amber-dim);
}
label.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-s); border-radius: 4px; }

.parody-stamp {
  position: absolute;
  top: 22px;
  right: 6px;
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.16em;
  color: #e07a7a;
  border: 1px solid rgba(224, 93, 93, 0.7);
  padding: 1px 5px;
  transform: rotate(-11deg);
  background: rgba(40, 12, 12, 0.7);
  z-index: 2;
  pointer-events: none;
}
.gcard .art, .art-banner {
  height: 44px;
  width: 100%;
  display: block;
  background: var(--surface-2);
  flex-shrink: 0;
}
.gcard .art svg { display: block; width: 100%; height: 100%; }

.flags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 14px 8px;
}
.flag {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--violet);
  color: var(--violet);
  background: rgba(155, 125, 255, 0.08);
}
.flag.warn { border-color: var(--red); color: var(--red); background: rgba(224, 93, 93, 0.08); }
.flag.good { border-color: var(--green); color: var(--green); background: rgba(111, 201, 160, 0.08); }
.flag.amber { border-color: var(--amber); color: var(--amber); background: rgba(224, 180, 74, 0.08); }

.timeline {
  display: flex;
  gap: 3px;
  align-items: center;
}
.timeline .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 1px solid var(--border);
}
.timeline .dot.done { background: var(--amber-dim); border-color: var(--amber-dim); }
.timeline .dot.now { background: var(--amber); border-color: var(--amber); box-shadow: 0 0 0 2px rgba(224, 180, 74, 0.3); }
.timeline .yr {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--faint);
  margin: 0 4px 0 2px;
  letter-spacing: 0.04em;
}

.reveal-card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-s);
  border-radius: 12px;
  padding: 28px 32px 26px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.reveal-card .stripe { position: absolute; top: 0; left: 0; right: 0; height: 4px; }
.reveal-card .k {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin-bottom: 8px;
}
.reveal-card h1 {
  font-family: var(--font-display);
  font-size: 48px;
  margin: 0;
  font-weight: 600;
  line-height: 0.95;
}
.reveal-card .motto {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  color: var(--text-dim);
  margin: 8px 0 16px;
}
.reveal-card .flavor { color: var(--text-dim); font-size: 15px; line-height: 1.5; margin: 0 0 16px; }
.reveal-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.reveal-stats .meter { flex: 1; }

.viewing-banner {
  background: rgba(224, 122, 168, 0.1);
  border-bottom: 1px solid rgba(224, 122, 168, 0.3);
  padding: 6px 14px;
  font-size: 12px;
  color: var(--pink);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.busy-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink);
  display: inline-block;
  margin-right: 6px;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.empty-tree {
  color: var(--faint);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 32px 16px;
}

.setup-bar {
  display: flex;
  gap: 24px;
  align-items: flex-end;
  flex-wrap: wrap;
  justify-content: center;
  margin: 18px 0 8px;
}
.seed-row { display: flex; gap: 6px; align-items: center; }
.seed-row input { width: 140px; font-family: var(--font-mono); }

.tree-node-money {
  fill: var(--amber);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
}
.parent-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.parent-picks button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
}
.parent-picks button.on { border-color: var(--cyan); background: #142428; }

.scoreboard { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0 16px; }
.scoreboard th {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.scoreboard td { padding: 6px 8px; border-bottom: 1px solid var(--border); color: var(--text-dim); }
.scoreboard tr.winner td { color: var(--amber); }
.scoreboard .fn { font-family: var(--font-display); font-size: 16px; color: var(--text); font-weight: 600; }

.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 28px; }
@media (max-width: 700px) { .help-cols { grid-template-columns: 1fr; } }

#results { display: none; }

.gcard.destroyed { opacity: 0.45; }
.socket-label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 7px;
  fill: var(--faint);
  letter-spacing: 0.4px;
}

.topbar .brand { cursor: default; user-select: none; }
.brand-click { cursor: pointer; }

.dock-actions .btn { white-space: nowrap; }

.col-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.market-head { flex-shrink: 0; }

.you-card .ability {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 0;
  line-height: 1.4;
}

.event-modal-art {
  height: 100px;
  margin: 0 -24px 16px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.event-modal-art svg { display: block; width: 100%; height: 100%; }

.kind-tabs { display: flex; gap: 6px; margin-bottom: 12px; }

.log .entry.new { animation: fadein 0.4s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.faction-card .goal { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

body.modal-open { overflow: hidden; }

.skip-ai {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.goal-detail { font-family: var(--font-sans); font-size: 13px; line-height: 1.45; color: var(--text-dim); margin-top: 6px; }
.goal-detail.race { color: var(--cyan); font-family: var(--font-mono); font-size: 12px; }
.attack-note { font-size: 12px; color: var(--amber); margin: 0 0 6px; line-height: 1.4; }

.screen-center .setup-note { color: var(--faint); font-size: 12px; margin-top: 8px; }

/* Make faction grid comfortable at 1280x800 and 1400x900 */
@media (max-height: 960px) and (min-width: 821px) {
  .faction-card .flavor { display: none; }
  .faction-card { padding: 12px 14px 11px; }
  .faction-card h3 { font-size: 21px; margin: 4px 0 0; }
  .faction-card .motto { margin-bottom: 6px; }
  .faction-card .stats { margin-bottom: 6px; }
  .faction-card .flavor, .faction-card .goal, .faction-card .ability { margin: 0 0 4px; font-size: 12px; }
  .faction-grid { gap: 10px; margin: 6px 0 12px; }
  .screen-center { padding-top: 20px; padding-bottom: 20px; }
  .screen-center h2.choose { font-size: 26px; margin-bottom: 2px; }
  .wordmark { font-size: clamp(40px, 7vw, 72px); }
}

/* ============================================================================
   Mobile UX — phones in portrait and landscape.
   Activated by body.phone (set in JS) and as a CSS fallback via media query.
   ============================================================================ */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; }

/* Shared phone tokens. Applied when JS sets body.phone, and also by MQ so
   a first paint before JS is not broken. */
@media (max-width: 820px), ((max-height: 520px) and (orientation: landscape)) {
  body { --phone: 1; }
}

body.phone,
body.phone #app {
  overflow-x: hidden;
  max-width: 100%;
}

body.phone {
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 56px;
  --dock-phone: 62px;
}

body.phone button,
body.phone a,
body.phone input,
body.phone select,
body.phone .gcard,
body.phone .rchip,
body.phone .faction-card,
body.phone .rival,
body.phone .node-g,
body.phone .tabbar button,
body.phone .tree-row {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(224, 180, 74, 0.15);
}

body.phone .btn,
body.phone .btn-sm {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  font-size: 14px;
  letter-spacing: 0.06em;
}

body.phone input[type="text"],
body.phone input[type="number"],
body.phone input[type="search"],
body.phone select,
body.phone textarea {
  font-size: 16px; /* iOS will zoom if this is < 16 */
  min-height: 44px;
  padding: 10px 12px;
}
body.phone input[type="range"] {
  height: 44px;
  width: 100%;
}

/* ----- Title / faction / reveal ----- */
body.phone .screen-center {
  justify-content: flex-start;
  padding: calc(24px + var(--safe-t)) 20px calc(28px + var(--safe-b));
  overflow-x: hidden;
  overflow-y: auto;
  width: 100%;
  max-width: 100%;
}
body.phone .wordmark { font-size: clamp(44px, 14vw, 72px); }
body.phone .subtitle { font-size: 20px; padding: 0 8px; text-align: center; }
body.phone .lede { font-size: 16px; line-height: 1.55; margin-bottom: 24px; max-width: 36em; }
body.phone .disclaimer { font-size: 12px; line-height: 1.5; margin-top: 28px; padding: 0 4px; }
body.phone .btn-row { width: 100%; max-width: 420px; }
body.phone .btn-row .btn { flex: 1; min-height: 48px; }
body.phone .title-decor { overflow: hidden; max-width: 100%; }
body.phone .screen-center h2.choose { font-size: 26px; text-align: center; padding: 0 8px; line-height: 1.2; }
body.phone .years { margin-top: 8px; }

body.phone .faction-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  margin: 8px 0 16px;
  padding: 0;
  grid-template-columns: none;
}
body.phone .faction-card {
  width: 100%;
  max-width: 100%;
  padding: 14px 16px 14px;
  min-height: 44px;
}
body.phone .faction-card:hover { transform: none; }
body.phone .faction-card h3 { font-size: 22px; }
body.phone .faction-card .flavor {
  display: none;
}
body.phone .faction-card.selected .flavor {
  display: block;
  -webkit-line-clamp: unset;
}
body.phone .faction-card .goal,
body.phone .faction-card .ability { font-size: 14px; line-height: 1.45; }
body.phone .screen-center:has(.faction-footer) {
  padding-bottom: 0;
  padding-left: 16px;
  padding-right: 16px;
}
body.phone .faction-grid {
  padding-bottom: 12px;
}
body.phone .faction-footer {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 10px 0 calc(10px + var(--safe-b));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 4;
  border-top: 1px solid var(--border);
  box-shadow: 0 -16px 28px var(--bg);
}
body.phone .faction-footer .setup-bar {
  margin: 0;
  gap: 8px;
  width: 100%;
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: flex-start;
}
body.phone .faction-footer .ai-count { margin: 0; flex-wrap: wrap; gap: 8px; width: 100%; }
body.phone .faction-footer .ai-count label { min-height: 44px; padding: 8px 4px; }
body.phone .faction-footer .field {
  margin: 0;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  font-size: 0; /* hide "Seed" label; placeholder is enough */
}
body.phone .faction-footer .seed-row { width: 100%; font-size: 16px; }
body.phone .faction-footer .seed-row input { flex: 1 1 auto; min-width: 0; width: auto; font-size: 16px; }
body.phone .faction-footer .seed-row .btn { font-size: 13px; flex: 0 0 auto; }
body.phone .faction-footer .btn-row { width: 100%; margin: 0; }
body.phone .faction-footer .setup-note { display: none; }
body.phone .setup-note { margin-bottom: 0; }

body.phone .reveal-card {
  width: 100%;
  max-width: 100%;
  border-radius: 16px 16px 0 0;
  margin-top: auto;
  padding: 24px 20px calc(20px + var(--safe-b));
  min-height: min(92dvh, 100%);
  display: flex;
  flex-direction: column;
}
body.phone .reveal-card h1 { font-size: 36px; }
body.phone .reveal-card .btn { min-height: 52px; width: 100%; margin-top: auto; }
body.phone .screen-center:has(.reveal-card) {
  justify-content: flex-end;
  padding: calc(8px + var(--safe-t)) 0 0;
}

/* ----- Play chrome ----- */
body.phone .timeline { display: none; }
body.phone .topbar {
  height: auto;
  min-height: 48px;
  padding: calc(6px + var(--safe-t)) 12px 8px;
  gap: 8px;
  flex-wrap: nowrap;
  overflow: hidden;
}
body.phone .topbar .brand {
  font-size: 16px;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
body.phone .topbar .meta {
  font-size: 11px;
  gap: 8px;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}
body.phone .topbar .meta span:nth-child(3) { display: none; } /* seed, shown in rules */
body.phone .whose { font-size: 12px; flex-shrink: 0; max-width: 42%; text-align: right; }
body.phone .event-banner {
  margin: 0;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  padding: 8px 12px;
  cursor: pointer;
}
body.phone .event-banner h3 { font-size: 16px; margin: 0; }
body.phone .event-banner p { font-size: 12px; margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Hide the desktop 3-col board; phone uses .phone-play */
body.phone .board { display: none; }
body.phone .phone-play {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

body.phone .phone-stage {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding-bottom: 4px;
}
body.phone .phone-stage .panel-head { padding: 10px 14px 6px; font-size: 11px; }

/* Compact status on Tree tab */
body.phone .you-card-compact {
  margin: 8px 12px 6px;
  padding: 8px 12px 8px;
  flex-shrink: 0;
}
body.phone .you-card-compact h2 { font-size: 18px; margin: 0 0 6px; }
body.phone .you-card-compact .motto { display: none; }
body.phone .you-card-compact .ability { display: none; }
body.phone .you-compact-head { min-width: 0; }
body.phone .you-inline-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 8px;
}
body.phone .you-inline-stats .meter {
  display: flex;
  flex-direction: column;
  padding: 4px 6px 5px;
  background: var(--surface-2);
  border-radius: 6px;
  min-width: 0;
}
body.phone .you-inline-stats .meter .k {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1;
}
body.phone .you-inline-stats .meter .v {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.15;
  margin-top: 2px;
}
body.phone .you-card-compact .goal-box { font-size: 12px; padding: 6px 8px; margin: 0; }
body.phone .you-card-compact .goal-box .goal-detail { line-height: 1.35; }
body.phone .you-card-compact .progress { margin-top: 6px; }

/* Tree: pannable diagram + tappable list */
body.phone .tree-mobile { display: flex; flex-direction: column; flex: 0 0 auto; min-height: 0; }
body.phone .tree-scroller {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  max-width: 100%;
  min-height: 0;
  flex: 0 0 auto;
  position: relative;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 28px 28px;
  border-bottom: 1px solid var(--border);
}
body.phone .tree-scroller svg { display: block; max-width: none; margin: 0; }
body.phone .tree-scroller.has-overflow::after {
  content: "Swipe to pan the tree";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: block;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 0 4px;
  background: linear-gradient(180deg, transparent, var(--bg) 70%);
  pointer-events: none;
}
body.phone .tree-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 16px;
}
body.phone .tree-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: inherit;
  min-height: 56px;
  padding: 8px 12px;
  position: relative;
  overflow: hidden;
}
body.phone .tree-row.selected { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
body.phone .tree-row.patron { background: #1a1d14; }
body.phone .tree-row .tr-stripe {
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tc, var(--amber));
}
body.phone .tree-row .tr-body { flex: 1; min-width: 0; }
body.phone .tree-row .tr-type {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tc, var(--muted));
}
body.phone .tree-row .tr-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.15;
}
body.phone .tree-row .tr-nums {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}
body.phone .tree-row .tr-nums b { color: var(--text); font-weight: 500; }
body.phone .tree-row .tr-tags {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: var(--cyan);
  flex-shrink: 0;
}
body.phone .tree-row.socket-row {
  border-style: dashed;
  background: transparent;
  color: var(--faint);
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  justify-content: flex-start;
}
body.phone .tree-indent { flex-shrink: 0; width: 0; }

/* Open-field cards: vertical stack, full width, easy to tap */
body.phone .market {
  display: flex;
  flex-direction: column;
  overflow: visible;
  padding: 8px 12px 20px;
  min-height: 0;
  gap: 10px;
}
body.phone .market .gcard {
  flex: none;
  width: 100%;
  max-width: 100%;
  min-height: 44px;
}
body.phone .market .gcard .name { font-size: 20px; }
body.phone .market .gcard .title { font-size: 13px; }
body.phone .market .gcard .nums { font-size: 12px; }
body.phone .market .gcard .art { height: 64px; }
body.phone .market .gcard .body { padding: 10px 12px 12px; }
body.phone .gcard:hover { transform: none; }

/* Rivals */
body.phone .rivals {
  padding: 8px 12px 20px;
  gap: 10px;
  overflow: visible;
}
body.phone .rival { padding: 14px; min-height: 44px; }
body.phone .rival-head h3 { font-size: 22px; }
body.phone .rival-meters { font-size: 13px; gap: 14px; }
body.phone .rchip {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 14px;
}

/* Log */
body.phone .log-phone { padding: 8px 16px 24px; flex: 1; }
body.phone .log {
  font-size: 15px;
  line-height: 1.55;
  overflow: visible;
  padding: 8px 0 24px;
  flex: none;
  color: var(--text-dim);
}
body.phone .log .entry { margin: 0 0 10px; }
body.phone .log .entry .when { font-size: 11px; display: inline; }

/* Rules tab */
body.phone .rules-phone {
  padding: 8px 16px calc(24px + var(--safe-b));
}
body.phone .rules-phone .help-body { font-size: 16px; line-height: 1.55; }
body.phone .help-cols { grid-template-columns: 1fr; }

/* Dock — sticky above the tab bar */
body.phone .dock {
  grid-column: auto;
  position: relative;
  flex-shrink: 0;
  min-height: var(--dock-phone);
  padding: 8px 12px 8px;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid var(--border);
  background: rgba(16, 19, 26, 0.97);
  z-index: 6;
}
body.phone .dock-info { flex: 1 1 120px; min-width: 0; }
body.phone .dock-info h3 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.phone .dock-info .flavor { display: none; }
body.phone .dock-info .meta {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.phone .dock-money {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--amber);
  flex-shrink: 0;
  line-height: 1;
  padding: 0 6px;
}
body.phone .dock-money span {
  display: block;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 400;
}
body.phone .dock-actions {
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 6px;
}
body.phone .dock-actions .btn { flex: 1 0 auto; min-width: 72px; }

/* Tab bar */
body.phone .tabbar {
  display: flex;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: #0c0e14;
  padding: 2px 2px calc(4px + var(--safe-b));
  z-index: 8;
}
body.phone .tabbar button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 2px 4px;
  border-radius: 0;
}
body.phone .tabbar button.on { color: var(--amber); }
body.phone .tabbar button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
body.phone .tabbar button .badge {
  position: absolute;
  /* unused */
}

/* Bottom sheets */
body.phone .modal-back,
body.phone .modal-back.sheet-back {
  align-items: flex-end;
  padding: 0;
  background: rgba(5, 6, 9, 0.72);
}
body.phone .modal-back,
body.phone .modal-back.sheet-back {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}
body.phone .modal,
body.phone .modal.wide,
body.phone .modal.sheet {
  width: 100%;
  max-width: 100%;
  border-radius: 16px 16px 0 0;
  max-height: 90dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 20px 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  box-sizing: border-box;
}
body.phone .modal::before {
  content: "";
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-s);
  margin: 2px auto 12px;
}
body.phone .modal h2 { font-size: 26px; }
body.phone .modal .lead { font-size: 15px; }
body.phone .modal .btn-row {
  position: sticky;
  bottom: 0;
  background: var(--bg-2);
  box-shadow: 0 -12px 20px var(--bg-2);
  padding: 10px 0 calc(12px + var(--safe-b));
  margin: 8px 0 0;
  width: 100%;
  justify-content: stretch;
  z-index: 3;
  flex-shrink: 0;
}
body.phone .modal .btn-row .btn { flex: 1; min-height: 52px; }
body.phone .formula { font-size: 13px; }
body.phone .odds { font-size: 32px; }
body.phone .attacker-picks button,
body.phone .parent-picks button { min-height: 44px; font-size: 14px; }
body.phone .event-modal-art { height: 80px; margin: 0 -20px 12px; overflow: hidden; }
body.phone .card-sheet .nums { display: flex; flex-wrap: wrap; gap: 6px 14px; }
body.phone .defender-note { font-size: 11px; color: var(--faint); margin: 0 0 8px; }
body.phone .help-body { font-size: 16px; }
body.phone .victory h2 { font-size: 28px; margin: 0 0 6px; }
body.phone .victory p { font-size: 14px; margin: 0 0 10px; line-height: 1.4; }
body.phone .scoreboard { font-size: 13px; display: block; padding-bottom: 4px; }
body.phone .scoreboard thead { display: none; }
body.phone .scoreboard tbody { display: block; }
body.phone .scoreboard tr { display: block; padding: 8px 0; border-bottom: 1px solid var(--border); }
body.phone .scoreboard td { display: block; padding: 1px 0; border: 0; }
body.phone .scoreboard td.fn { font-size: 18px; margin-bottom: 2px; }
body.phone .scoreboard td[data-k] { display: inline-block; margin-right: 12px; font-size: 13px; }
body.phone .scoreboard td[data-k="Secret"] { display: block; margin: 4px 0 0; font-size: 12px; line-height: 1.35; color: var(--text-dim); }
body.phone .scoreboard td[data-k]::before {
  content: attr(data-k) "  ";
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}

/* Card detail sheet */
body.phone .card-sheet .cs-art { height: 100px; margin: 0 -20px 12px; overflow: hidden; }
body.phone .card-sheet .cs-art svg { width: 100%; height: 100%; display: block; }
body.phone .card-sheet .cs-type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--tc, var(--muted));
}
body.phone .card-sheet .nums { font-size: 13px; gap: 10px; margin: 8px 0; }
body.phone .card-sheet .flavor { font-size: 15px; font-style: italic; color: var(--text-dim); margin: 8px 0 16px; line-height: 1.5; }

/* Landscape phones: very tight vertical space */
body.phone.landscape-phone .topbar { padding-top: 4px; padding-bottom: 4px; min-height: 36px; }
body.phone.landscape-phone .event-banner p { display: none; }
body.phone.landscape-phone .event-banner { padding: 3px 12px; }
body.phone.landscape-phone .event-banner h3 { font-size: 14px; }
body.phone.landscape-phone .you-card-compact .goal-box { display: none; }
body.phone.landscape-phone .you-card-compact {
  margin: 2px 8px;
  padding: 4px 10px;
}
body.phone.landscape-phone .you-compact-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
body.phone.landscape-phone .you-card-compact h2 {
  font-size: 16px;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}
body.phone.landscape-phone .you-inline-stats {
  display: flex;
  flex: 1;
  margin: 0;
  gap: 6px;
  justify-content: flex-end;
}
body.phone.landscape-phone .you-inline-stats .meter {
  flex-direction: row;
  align-items: baseline;
  gap: 6px;
  padding: 2px 10px;
  flex: 0 0 auto;
}
body.phone.landscape-phone .you-inline-stats .meter .v { font-size: 16px; margin: 0; }
body.phone.landscape-phone .tree-list { display: none; } /* SVG has horizontal room */
body.phone.landscape-phone .tree-scroller { flex: 1; min-height: 0; }
body.phone.landscape-phone .tree-mobile { flex: 1; min-height: 0; }
body.phone.landscape-phone .phone-stage[data-tab="tree"] { overflow: hidden; }
body.phone.landscape-phone .tabbar button { min-height: 44px; padding: 2px; }
body.phone.landscape-phone .tabbar { padding-bottom: 2px; }
body.phone.landscape-phone .dock { padding: 4px 10px; min-height: 48px; }
body.phone.landscape-phone .dock-info h3 { font-size: 16px; }
body.phone.landscape-phone .modal,
body.phone.landscape-phone .modal.sheet {
  max-height: 100dvh;
  padding: 6px 16px 0;
  border-radius: 12px 12px 0 0;
}
body.phone.landscape-phone .modal h2 { font-size: 22px; margin: 0 0 2px; }
body.phone.landscape-phone .modal > .lead,
body.phone.landscape-phone .modal .lead {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 6px;
  font-size: 13px;
}
body.phone.landscape-phone .defender-note { display: none; }
body.phone.landscape-phone .event-modal-art { height: 48px; margin: 0 -16px 8px; }
body.phone.landscape-phone .formula {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 16px;
  font-size: 12px;
  padding: 6px 10px;
  margin: 0 0 6px;
}
body.phone.landscape-phone .formula > div:last-child { grid-column: 1 / -1; }
body.phone.landscape-phone .spend-row { margin: 2px 0 6px; }
body.phone.landscape-phone .odds { font-size: 24px; }
body.phone.landscape-phone .attacker-picks { margin-bottom: 6px; }
body.phone.landscape-phone .modal .btn-row { padding: 8px 0 calc(8px + var(--safe-b)); margin-top: 4px; }
body.phone.landscape-phone .modal::before { margin: 0 auto 6px; }

/* Landscape title: keep New Game in view without scrolling */
body.phone.landscape-phone .screen-center {
  justify-content: center;
  padding: 8px 28px 12px;
}
body.phone.landscape-phone .wordmark { font-size: clamp(36px, 12vh, 52px); }
body.phone.landscape-phone .subtitle { font-size: 16px; margin-top: 6px; }
body.phone.landscape-phone .gold-rule { margin: 10px 0; }
body.phone.landscape-phone .lede {
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: none;
}
body.phone.landscape-phone .disclaimer { margin-top: 10px; font-size: 11px; }
body.phone.landscape-phone .years { margin-top: 0; }
body.phone.landscape-phone .title-decor { opacity: 0.08; }

/* Short portrait phones (Pixel-ish 740) */
@media (max-height: 760px) {
  body.phone:not(.landscape-phone) .event-banner p { -webkit-line-clamp: 1; }
  body.phone:not(.landscape-phone) .you-card-compact { margin: 6px 10px 4px; padding: 6px 10px; }
  body.phone:not(.landscape-phone) .you-inline-stats .meter .v { font-size: 18px; }
}

/* Hide tabbar on desktop */
.tabbar, .phone-play { display: none; }
body.phone .tabbar, body.phone .phone-play { display: flex; }

/* Prevent 100vw overflow gotchas */
body.phone .play-root,
body.phone .phone-play,
body.phone .phone-stage,
body.phone .topbar,
body.phone .dock,
body.phone .tabbar,
body.phone .event-banner {
  max-width: 100%;
  box-sizing: border-box;
}

body.phone .tree-scroller.tree-centered .tree-wrap {
  display: flex;
  justify-content: center;
}
body.phone .tree-scroller .tree-wrap {
  overflow: visible;
  flex: none;
  min-height: 0;
  padding: 12px 12px 8px;
  background: none;
  background-image: none;
}
body.phone .tree-scroller .empty-tree { padding: 16px; }

/* Desktop: faction-footer is just a block wrapper, no sticky */
.faction-footer { display: contents; }
body.phone .faction-footer { display: flex; }

/* Make sure desktop board is untouched when not .phone */
body:not(.phone) .phone-play,
body:not(.phone) .tabbar { display: none !important; }

/* Playtest layout: scroll the patron list clear of the sticky footer,
   and keep open-field cards inside the center column. */
@media (min-width: 821px) {
  .market {
    flex-wrap: wrap;
    overflow: visible;
    min-height: 0;
    align-content: flex-start;
  }
  .gcard {
    flex: 1 1 150px;
    width: auto;
    min-width: 150px;
    max-width: 188px;
  }
}

body.phone .faction-card { overflow: visible; height: auto; }
body.phone .faction-card .motto {
  display: block;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}
body.phone .faction-grid {
  flex-shrink: 0;
  width: 100%;
  padding-bottom: calc(260px + env(safe-area-inset-bottom, 0px));
}
body.phone .screen-center { min-height: 0; }
body.phone .modal .victory-actions { position: sticky; }
