/* Terraforming Mars web client */

:root {
  --bg: #121418;
  --bg2: #181b20;
  --panel: #1d2127;
  --panel2: #252a31;
  --line: #333943;
  --line2: #444b57;
  --text: #e6e3dc;
  --muted: #959ba5;
  --rust: #c4552a;
  --rust2: #df7a45;
  --brass: #d6a940;
  --good: #6cb86f;
  --bad: #dc5a4a;

  --hex-land: #b45a2e;
  --hex-ocean-area: #3c6688;
  --hex-space: #24283a;
  --tile-ocean: #2f78bd;
  --tile-greenery: #3f8e3f;
  --tile-city: #6a6c74;
  --tile-special: #7d5434;

  --card-automated: #3f8a3c;
  --card-active: #2e67a8;
  --card-event: #b2402f;
  --card-corp: #4b4f5a;
  --card-paper: #f1eadc;
  --card-ink: #27211c;

  --radius: 5px;
  --font: 'Barlow', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-c: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  font-family: var(--font);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; font-size: 15px; line-height: 1.35; }
h1, h2, h3 { margin: 0 0 .5rem; font-family: var(--font-c); font-weight: 600; letter-spacing: .02em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
button, input, select { font: inherit; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.spacer { flex: 1; }
.center { justify-content: center; text-align: center; }
.row-gap { display: flex; gap: .5rem; flex-wrap: wrap; }
.warn { color: var(--bad); }
.ok { color: var(--good); }
.ico { display: inline-block; vertical-align: -0.2em; flex: none; width: 1.15em; height: 1.15em; }

/* ---------- controls */
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 4px;
  padding: .38rem .75rem; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--font-c); font-weight: 600; font-size: .95rem; letter-spacing: .02em;
}
.btn:hover:not(:disabled) { background: #2f353e; border-color: #5a6270; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--rust); border-color: #9c4220; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #d2622f; border-color: #9c4220; }
.btn-danger { color: #f0b1a6; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--panel2); }
.btn-small { padding: .18rem .5rem; font-size: .85rem; }
.btn-big { padding: .6rem 1.4rem; font-size: 1.1rem; }
.btn-option { display: flex; width: 100%; text-align: left; padding: .6rem .9rem; white-space: normal; font-family: var(--font); font-weight: 500; font-size: .95rem; }
.btn-action { width: 100%; justify-content: center; white-space: normal; font-size: .82rem; padding: .25rem .4rem; background: #24476f; border-color: #2e67a8; color: #fff; }
.btn-action:hover:not(:disabled) { background: #2e5a8c; border-color: #4b84c4; }
.btn-play { width: 100%; justify-content: center; font-size: .88rem; padding: .25rem .4rem; background: var(--brass); border-color: #9c7a22; color: #2a1d00; }
.btn-play:hover:not(:disabled) { background: #e4ba55; border-color: #9c7a22; }
input, select { background: var(--bg2); color: var(--text); border: 1px solid var(--line2); border-radius: 4px; padding: .38rem .5rem; }
input:focus, select:focus, .btn:focus-visible, .std-btn:focus-visible, .card.clickable:focus-visible, .dock-tab:focus-visible, .side-tab:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
.chk { display: flex; align-items: center; gap: .45rem; cursor: pointer; }
.chk input { accent-color: var(--rust); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }

/* ---------- start screen */
.start { max-width: 1080px; margin: 0 auto; padding: 2.5rem 1rem 4rem; }
.start-head { border-bottom: 3px solid var(--rust); margin-bottom: 1.4rem; padding-bottom: .8rem; }
.start-head h1 { font-size: clamp(2.2rem, 6vw, 3.6rem); text-transform: uppercase; letter-spacing: .06em; line-height: 1; font-weight: 700; }
.subtitle { color: var(--muted); margin: .4rem 0 0; }
.start-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 1rem; align-items: start; }
.continue { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; border-left: 4px solid var(--rust); }
.players-form { display: flex; flex-direction: column; gap: .45rem; margin-bottom: .7rem; }
.player-row { display: flex; gap: .45rem; align-items: center; flex-wrap: wrap; }
.player-row input[data-field="name"] { flex: 1; min-width: 120px; }
.color-select { width: 92px; color: #fff; font-weight: 600; }
.options { display: flex; flex-direction: column; gap: .5rem; margin: 1.1rem 0 .6rem; }
.start ol, .rules ol { padding-left: 1.2rem; }
.start li, .start .panel p, .rules p, .rules li { line-height: 1.5; }

/* ---------- game frame */
.game { padding: 0 .8rem 3rem; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 1.1rem; padding: .5rem 0; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: .5rem; }
.brand { font-family: var(--font-c); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; line-height: .95; font-size: .95rem; color: var(--rust2); border-left: 3px solid var(--rust); padding-left: .5rem; }
.gen-num { font-family: var(--font-c); font-weight: 600; font-size: 1.15rem; }
.gauges { display: flex; gap: 1rem; flex: 1; min-width: 300px; }
.gauge { flex: 1; min-width: 110px; }
.gauge-label { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--font-c); text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; color: var(--muted); }
.gauge-label b { color: var(--text); font-size: 1rem; letter-spacing: 0; }
.gauge.done .gauge-label b { color: var(--good); }
.gauge-track { display: flex; gap: 2px; margin-top: 3px; }
.seg { flex: 1; height: 9px; background: #2a2f37; border-radius: 1px; position: relative; }
.seg.mark::after { content: ''; position: absolute; left: 50%; top: -4px; width: 4px; height: 4px; margin-left: -2px; background: var(--brass); border-radius: 50%; }
.g-temp .seg.on { background: #d9662f; }
.g-temp .seg.on:nth-child(-n+6) { background: #8a6bbf; }
.g-temp .seg.on:nth-child(n+7):nth-child(-n+12) { background: #c9874a; }
.g-oxy .seg.on { background: #58a86a; }
.g-ocean .seg.on { background: #3d86cf; }
.top-actions { display: flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.speed { display: flex; align-items: center; gap: .35rem; color: var(--muted); font-family: var(--font-c); text-transform: uppercase; letter-spacing: .05em; }
.speed select { padding: .25rem .3rem; }

.promptbar {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line2);
  border-radius: var(--radius); padding: .5rem .8rem; margin-bottom: .6rem;
}
.promptbar.mine { border-left-color: var(--rust); }
.promptbar.attention { border-color: var(--rust); }
.promptbar.ai { border-left-color: #7e86a0; }
.promptbar.ended { border-left-color: var(--brass); }
.pb-title { font-size: 1.05rem; font-family: var(--font-c); font-weight: 500; }
.pb-title b { font-weight: 700; }
.pb-hint { flex: 1; min-width: 160px; }
.pb-recent { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.promptbar.ai .pb-recent { flex: 1; min-width: 0; }
.pb-buttons { display: flex; gap: .35rem; flex-wrap: wrap; margin-left: auto; }
.dots::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

.main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px); gap: .7rem; align-items: start; }
.col-board, .col-side { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.board-wrap { background: #171a24; border: 1px solid var(--line); border-radius: var(--radius); padding: .3rem; }
.board-svg { width: 100%; height: auto; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; justify-content: center; padding: .25rem .4rem .1rem; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: .3rem; }
.lg-ocean { display: inline-block; width: .85rem; height: .85rem; background: var(--hex-ocean-area); border-radius: 2px; }

/* ---------- board */
.hex-shape { stroke: #24120a; stroke-width: 1.4; }
.hex-ocean .hex-shape { stroke: #1d3a52; }
.hex-offboard .hex-shape { stroke: #5c6390; stroke-dasharray: 3 3; }
.hex-name { font: 600 7px var(--font-c); fill: #f6dcc5; text-anchor: middle; letter-spacing: .06em; pointer-events: none; opacity: .9; }
.hex-offname { font: 600 8.5px var(--font-c); fill: #aab0d8; text-anchor: middle; letter-spacing: .08em; pointer-events: none; }
.hex-special { font: 700 7.2px var(--font-c); fill: #fbe8d2; text-anchor: middle; dominant-baseline: middle; letter-spacing: .04em; pointer-events: none; }
.hex.hl { cursor: pointer; }
.hex.hl .hex-shape { stroke: #f4e3a0; stroke-width: 2.6; animation: hlpulse 1.4s ease-in-out infinite; }
.hex.hl:hover .hex-shape { stroke: #fff; stroke-width: 3.2; filter: brightness(1.18); }
@keyframes hlpulse { 50% { stroke: var(--brass); } }
.hex.flash .hex-shape { animation: tileflash 3.5s ease-out both; animation-delay: var(--fd, 0s); }
@keyframes tileflash {
  0% { stroke: #fff; stroke-width: 5; }
  60% { stroke: var(--brass); stroke-width: 3.5; }
  100% { stroke: #24120a; stroke-width: 1.4; }
}
.hex-preview rect { fill: #1b1a14; stroke: var(--brass); stroke-width: .8; }
.hex-preview text { font: 700 7.5px var(--font-c); fill: var(--brass); text-anchor: middle; }

/* ---------- players */
.players { display: grid; grid-template-columns: 1fr; gap: .45rem; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--pc); border-radius: var(--radius); padding: .45rem .6rem; }
.pcard.active { border-color: var(--pc); background: #21262e; }
.pcard.passed { opacity: .65; }
.phead { display: flex; align-items: center; gap: .4rem; }
.pname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-c); font-size: 1.05rem; }
.tr { margin-left: auto; font-family: var(--font-c); font-weight: 700; border: 1px solid var(--line2); border-radius: 3px; padding: 0 .4rem; }
.tr.up { animation: pulseup 1.8s ease-out both; }
.badge { font-family: var(--font-c); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; border: 1px solid var(--line2); color: var(--muted); border-radius: 3px; padding: 0 .3rem; }
.badge-turn { background: var(--rust); border-color: var(--rust); color: #fff; }
.badge-win { background: var(--brass); border-color: var(--brass); color: #2a1d00; }
.pcorp { display: flex; align-items: center; gap: .7rem; margin: .15rem 0 .35rem; }
.pcorp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.inhand { display: inline-flex; align-items: center; gap: .2rem; }
.pres { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.res-cell { position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: 3px; text-align: center; padding: .15rem 0 0; }
.res-top { display: flex; align-items: center; justify-content: center; gap: .25rem; }
.res-amt { font-family: var(--font-c); font-weight: 700; font-size: 1.05rem; }
.res-prod { font-family: var(--font-c); font-size: .8rem; color: #e1c27a; border-top: 1px solid var(--line); margin-top: .1rem; }
.res-prod.neg { color: var(--bad); }
.res-cell.up { animation: pulseup 1.8s ease-out both; }
.res-cell.down { animation: pulsedown 1.8s ease-out both; }
.res-prod.up { animation: pulseup 1.8s ease-out both; }
.res-prod.down { animation: pulsedown 1.8s ease-out both; }
@keyframes pulseup { 0% { background: #3e6b3f; } 100% { background: transparent; } }
@keyframes pulsedown { 0% { background: #7a3328; } 100% { background: transparent; } }
.delta { position: absolute; top: -9px; right: 2px; font: 700 .75rem var(--font-c); color: var(--text); background: var(--panel2); border: 1px solid var(--line2); border-radius: 3px; padding: 0 .2rem; animation: deltafade 1.8s ease-out both; pointer-events: none; }
@keyframes deltafade { 0% { opacity: 1; transform: translateY(0); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-4px); } }
.ptags { display: flex; flex-wrap: wrap; gap: .25rem .5rem; margin-top: .35rem; }
.tagcount { display: inline-flex; align-items: center; gap: .15rem; font: 600 .85rem var(--font-c); }
.pdot { display: inline-block; width: .75rem; height: .75rem; border-radius: 2px; border: 1px solid #000a; vertical-align: middle; margin-right: .25rem; flex: none; }

/* ---------- side panel */
.side-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.side-tabs { display: flex; gap: .1rem; padding: .3rem .3rem 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.side-tab { background: transparent; color: var(--muted); border: 1px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0; padding: .35rem .6rem; cursor: pointer; display: flex; align-items: center; gap: .35rem; font: 600 .92rem var(--font-c); text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.side-tab:hover { color: var(--text); }
.side-tab.on { color: var(--text); background: var(--panel2); border-color: var(--line); }
.side-body { padding: .6rem .7rem; overflow-y: auto; min-height: 0; }
.side-note { margin: 0 0 .4rem; }
.count { background: #ffffff14; border-radius: 3px; padding: 0 .35rem; font-size: .78rem; letter-spacing: 0; text-transform: none; }
.count.hot { background: var(--brass); color: #2a1d00; font-weight: 700; }
.ma-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.side-note + .ma-row { border-top: none; }
.ma-row.taken { opacity: .7; }
.ma-row b { font-family: var(--font-c); font-size: 1.02rem; }
.claimed { font-size: .82rem; display: flex; align-items: center; gap: .25rem; white-space: nowrap; }
.award-val { white-space: nowrap; margin-right: .5rem; font-family: var(--font-c); }
.std-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .4rem; }
.std-btn { display: grid; grid-template-columns: auto 1fr; column-gap: .5rem; align-items: center; text-align: left; background: var(--panel2); color: var(--text); border: 1px solid var(--line2); border-radius: 4px; padding: .4rem .5rem; cursor: pointer; }
.std-btn:hover:not(:disabled) { border-color: #5a6270; background: #2f353e; }
.std-btn:disabled { opacity: .45; cursor: not-allowed; }
.std-cost { grid-row: span 2; background: var(--brass); color: #2a1d00; font: 700 .9rem var(--font-c); border-radius: 3px; padding: .05rem .35rem; min-width: 2rem; text-align: center; }
.std-name { font: 600 .95rem var(--font-c); }
.std-desc { font-size: .72rem; color: var(--muted); }
.solo-info { background: var(--panel2); border-left: 3px solid var(--rust); border-radius: 3px; padding: .5rem .6rem; margin-bottom: .6rem; line-height: 1.4; }
ul.log { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
ul.log li { padding: .2rem 0; border-bottom: 1px solid #ffffff0c; }
ul.log li.log-head { color: var(--rust2); font: 600 .85rem var(--font-c); text-transform: uppercase; letter-spacing: .06em; padding-top: .45rem; }

/* ---------- dock (hand, tableau, events) */
.game.dock-open { padding-bottom: calc(min(330px, 46vh) + 1.5rem); }
.game.dock-closed { padding-bottom: 4rem; }
.dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #15181d; border-top: 1px solid var(--line2); box-shadow: 0 -6px 18px #0008; max-height: min(330px, 46vh); display: flex; flex-direction: column; }
.dock.closed { max-height: none; }
.dock-head { display: flex; align-items: center; gap: .6rem; padding: .35rem .9rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.dock-owner { font: 600 1rem var(--font-c); display: flex; align-items: center; }
.dock-tabs { display: flex; gap: .2rem; }
.dock-tab { background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 4px; padding: .28rem .6rem; cursor: pointer; display: flex; align-items: center; gap: .35rem; font: 600 .95rem var(--font-c); text-transform: uppercase; letter-spacing: .05em; }
.dock-tab:hover { color: var(--text); }
.dock-tab.on { color: var(--text); background: var(--panel2); border-color: var(--line2); }
.dock .card-row { padding: .55rem .9rem .7rem; overflow-x: auto; overflow-y: hidden; flex: 1; align-items: flex-start; }
.dock-sort { display: flex; align-items: center; gap: .3rem; }
.dock-sort select { padding: .15rem .3rem; }
.mods { background: #3a2f17; border: 1px solid #7a6020; border-radius: 3px; padding: .1rem .5rem; font-size: .82rem; }
.empty { padding: .5rem; }

/* ---------- cards (laid out like the printed cards) */
.card-row { display: flex; gap: .55rem; overflow-x: auto; padding: .3rem .1rem .6rem; }
.card-row.wrap { flex-wrap: wrap; overflow: visible; }
.card {
  position: relative; flex: none; width: 176px; background: var(--card-paper); color: var(--card-ink);
  border-radius: 6px; border: 2px solid #1a1612; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 1px 0 #000, 0 3px 8px #0006;
}
.card.clickable { cursor: pointer; }
.card.clickable:hover { transform: translateY(-2px); }
.card.playable { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass), 0 3px 8px #0006; }
.card.unplayable .card-art-wrap, .card.unplayable .card-name { filter: saturate(.45) brightness(.85); }
.card.selected { border-color: var(--rust); box-shadow: 0 0 0 2px var(--rust), 0 3px 8px #0006; transform: translateY(-2px); }
.card.selected::after { content: 'Selected'; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); background: var(--rust); color: #fff; font: 700 .7rem var(--font-c); text-transform: uppercase; letter-spacing: .08em; padding: .05rem .4rem; border-radius: 2px; }
.card-head { display: flex; align-items: center; padding: 4px 5px 3px; min-height: 30px; background: #e6dcc8; }
.cost { background: var(--brass); color: #2a1d00; font: 700 1.05rem var(--font-c); border-radius: 3px; min-width: 26px; text-align: center; padding: 0 5px; border: 1px solid #8e6c1c; }
.cost.discounted { background: #9fd38f; border-color: #4e8a3e; }
.tags { display: flex; gap: 2px; margin-left: auto; }
.tag { display: inline-flex; }
.tag .ico { width: 21px; height: 21px; }
.card-name { display: flex; justify-content: space-between; align-items: center; gap: 4px; padding: 3px 7px; color: #fff; font: 700 .9rem var(--font-c); letter-spacing: .02em; text-transform: uppercase; background: var(--card-automated); }
.card-active .card-name { background: var(--card-active); }
.card-event .card-name { background: var(--card-event); }
.card-corp .card-name { background: var(--card-corp); }
.card-num { font-weight: 500; opacity: .75; font-size: .7rem; }
.card-art-wrap { height: 44px; overflow: hidden; border-bottom: 1px solid #00000033; background: #222; }
.card-art { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-req { font-size: .74rem; padding: 3px 7px; background: #ecdcc4; color: #5d3714; font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.card-req .ico { width: 13px; height: 13px; }
.card-req.met { background: #d9ead0; color: #2c5a22; }
.card-req.unmet { background: #f2d3cb; color: #8b2b1c; }
.corp-start { font: 600 .9rem var(--font-c); padding: 4px 7px; background: #e1dccf; display: flex; align-items: center; flex-wrap: wrap; gap: 3px; }
.corp-start .sep { width: 8px; }
.card-text { font-size: .76rem; line-height: 1.32; padding: 5px 7px; flex: 1; }
.card-foot { display: flex; align-items: center; gap: 5px; padding: 0 6px 5px; min-height: 24px; }
.vp { margin-left: auto; min-width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; background: #8a4a22; color: #fff; font: 700 .9rem var(--font-c); border: 1px solid #5a2e12; padding: 0 3px; }
.vp.neg { background: #6b1f18; }
.vp.vp-text { border-radius: 12px; font-size: .74rem; padding: 0 7px; }
.card-res { display: inline-flex; align-items: center; gap: 3px; font: 700 .85rem var(--font-c); background: #e2d6bf; border-radius: 10px; padding: 1px 7px 1px 3px; }
.used-mark { font: 700 .72rem var(--font-c); text-transform: uppercase; letter-spacing: .06em; color: #2e67a8; }
.card-reason { font-size: .7rem; background: #3a302a; color: #f2d2c0; padding: 3px 7px; }
.card-actions { display: flex; flex-direction: column; gap: 3px; padding: 0 5px 5px; }
.card-corp { width: 210px; }
.card.big { width: 290px; }
.card.big .card-art-wrap { height: 72px; }
.card.big .card-name { font-size: 1.15rem; padding: 6px 9px; }
.card.big .card-text { font-size: .95rem; padding: 8px 9px; }
.card.big .card-req, .card.big .corp-start { font-size: .88rem; padding: 4px 9px; }
.card.big .tag .ico { width: 28px; height: 28px; }
.card.big .cost { font-size: 1.35rem; min-width: 34px; }
.events { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.event-chip { background: #3a201b; border: 1px solid var(--card-event); border-radius: 3px; padding: .05rem .45rem; font-size: .8rem; }
.drafted { margin-bottom: .6rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.peek-hand { margin-top: .8rem; }
.peek-hand summary { cursor: pointer; color: var(--muted); }

/* ---------- dialogs */
.modal-backdrop { position: fixed; inset: 0; background: #08090bcc; z-index: 50; display: grid; place-items: center; padding: 1rem; overflow-y: auto; }
.modal-backdrop.overlay { z-index: 60; }
.modal { background: var(--bg2); border: 1px solid var(--line2); border-top: 3px solid var(--rust); border-radius: var(--radius); width: min(520px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: 0 16px 40px #000c; }
.modal.wide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; gap: .5rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: .5rem; padding: .65rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.option-list { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; }
.amount { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: .6rem; }
.amount-val { font: 700 2.2rem var(--font-c); min-width: 3rem; }
input[type=range] { width: 100%; accent-color: var(--rust); }
.pay-rows { display: flex; flex-direction: column; gap: .4rem; }
.pay-row { display: grid; grid-template-columns: 1fr auto 2.5rem auto 4rem; align-items: center; gap: .5rem; }
.pay-res { display: flex; align-items: center; gap: .4rem; }
.pay-val { text-align: center; font: 700 1.2rem var(--font-c); }
table.scores { width: 100%; border-collapse: collapse; }
table.scores th { font: 600 .85rem var(--font-c); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
table.scores th, table.scores td { padding: .45rem .5rem; text-align: center; border-bottom: 1px solid var(--line); }
table.scores th:first-child, table.scores td:first-child { text-align: left; }
table.scores .total { font: 700 1.25rem var(--font-c); color: var(--brass); }
table.scores tr.winner { background: #d6a94012; }
.inspect { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.inspect-info { flex: 1; min-width: 220px; line-height: 1.5; }
.inspect-info .btn-primary { margin-top: .5rem; }
.tag-line { display: inline-flex; align-items: center; gap: .25rem; margin-right: .6rem; }

.handoff { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: grid; place-items: center; padding: 1rem; }
.handoff-box { text-align: center; border-top: 4px solid var(--pc); padding-top: 1.5rem; }
.handoff-dot { display: none; }
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line2); border-left: 4px solid var(--bad); padding: .55rem .9rem; border-radius: var(--radius); z-index: 80; box-shadow: 0 8px 24px #000a; max-width: 90vw; }
.notes { position: fixed; left: .8rem; bottom: calc(min(330px, 46vh) + .8rem); z-index: 40; display: flex; flex-direction: column; gap: .4rem; max-width: min(420px, 90vw); }
.game.dock-closed .notes { bottom: 3.5rem; }
.note { display: flex; align-items: center; gap: .6rem; background: var(--panel2); border: 1px solid var(--line2); border-left: 4px solid var(--pc); border-radius: var(--radius); padding: .45rem .5rem .45rem .7rem; box-shadow: 0 6px 18px #0009; font-size: .88rem; animation: notein .25s ease-out; }
.note-attack { border-left-color: var(--bad); }
.note-kind { font: 700 .72rem var(--font-c); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); white-space: nowrap; }
.note-attack .note-kind { color: #f0a090; }
@keyframes notein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- layout: desktop shows everything on one screen */
@media (min-width: 1051px) {
  body.in-game { height: 100vh; overflow: hidden; }
  .game { height: 100vh; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
  .game.dock-open, .game.dock-closed { padding-bottom: 0; }
  .main { min-height: 0; grid-template-columns: minmax(0, 1fr) clamp(340px, 30vw, 460px); padding-bottom: .5rem; align-items: stretch; }
  .col-board { min-height: 0; }
  .board-wrap { height: 100%; display: flex; flex-direction: column; min-height: 0; }
  .board-svg { flex: 1; min-height: 0; height: 100%; }
  .col-side { min-height: 0; gap: .5rem; }
  .players { flex: 0 1 auto; overflow-y: auto; max-height: 60%; min-height: 0; }
  .side-panel { flex: 1 1 auto; }
  .dock { position: static; max-height: min(272px, 34vh); margin: 0 -.8rem; }
  .dock.closed { max-height: none; }
  .dock .card-text { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
  .notes { bottom: calc(min(272px, 34vh) + .8rem); }
  .side-body .std-grid { grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .side-body .std-btn { grid-template-columns: 1fr; text-align: center; row-gap: .2rem; padding: .4rem .3rem; }
  .side-body .std-cost { grid-row: auto; justify-self: center; }
  .side-body .std-desc { display: none; }
}
@media (min-width: 1051px) and (max-height: 760px) {
  .dock { max-height: 34vh; }
  .legend { display: none; }
  .dock .card-art-wrap { height: 30px; }
}
@media (max-width: 1050px) {
  .main { grid-template-columns: 1fr; }
  .start-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .game { padding: 0 .5rem 3rem; }
  .topbar { gap: .5rem; }
  .gauges { flex: 1 1 100%; min-width: 0; order: 3; gap: .6rem; }
  .gauge { flex: 1 1 0; min-width: 0; }
  .top-actions .btn { padding: .28rem .5rem; font-size: .85rem; }
  .speed, .dock-owner, .dock-sort, .dock .mods, .brand { display: none; }
  .std-grid { grid-template-columns: repeat(2, 1fr); }
  .card { width: 156px; }
  .pres { grid-template-columns: repeat(3, 1fr); }
  .pay-row { grid-template-columns: 1fr auto 2rem auto; }
  .pay-row .muted { display: none; }
  .dock { max-height: 42vh; }
  .dock-head { flex-wrap: nowrap; padding: .3rem .5rem; gap: .3rem; }
  .dock-tab { padding: .25rem .4rem; font-size: .85rem; }
  .dock-tab .count.hot { display: none; }
  .dock .card-row { padding: .5rem; }
  .game.dock-open { padding-bottom: calc(42vh + 1rem); }
  .notes { bottom: calc(42vh + .6rem); }
}

/* round: hand filter, option shortcuts */
.hand-filter { display: flex; gap: 2px; }
.filter-chip { background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 2px 3px; cursor: pointer; opacity: .65; display: inline-flex; }
.filter-chip:hover { opacity: 1; border-color: var(--line2); }
.filter-chip.on { opacity: 1; border-color: var(--brass); background: #3a2f17; }
kbd { font: 600 .75rem var(--font-c); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 3px; padding: 0 .35rem; margin-right: .6rem; color: var(--muted); background: var(--bg); }
@media (max-width: 640px) { .hand-filter { display: none; } }

/* results: score bars and history chart */
.score-bars { margin-bottom: 1rem; }
.bar-row { display: grid; grid-template-columns: 9rem 1fr 3rem; align-items: center; gap: .6rem; margin-bottom: .35rem; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-c); font-size: 1.02rem; }
.bar-track { display: flex; height: 20px; background: var(--bg); border: 1px solid var(--line); border-radius: 3px; overflow: hidden; }
.bar-seg { display: grid; place-items: center; font: 700 .75rem var(--font-c); color: #fff; border-right: 1px solid #0005; }
.bar-total { font: 700 1.2rem var(--font-c); color: var(--brass); text-align: right; }
.bar-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .4rem; }
.bar-legend i { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.history { margin: 0 0 1rem; }
.history-svg { width: 100%; height: auto; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
.history-svg .grid { stroke: #ffffff12; }
.history-svg .axis { font: 500 10px var(--font-c); fill: var(--muted); }
@media (max-width: 640px) { .bar-row { grid-template-columns: 6rem 1fr 2.5rem; } }

/* online play */
.invite-link { display: flex; gap: .5rem; margin: .8rem 0 1rem; }
.invite-link input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
.join { max-width: 560px; }
.join-name { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; font-family: var(--font-c); font-size: 1.05rem; }
.join-name input { flex: 1; }

/* tips and icon guide */
.tipbar { display: flex; align-items: center; gap: .6rem; margin: -.3rem 0 .6rem; padding: .3rem .6rem; background: #1f2a22; border: 1px solid #2f4a36; border-radius: var(--radius); color: #cfe3d2; }
.tip-label { font: 700 .72rem var(--font-c); text-transform: uppercase; letter-spacing: .08em; color: #8fd19a; }
.tipbar .btn { margin-left: auto; color: var(--muted); }
.guide { margin-bottom: 1rem; }
.guide-row { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin-bottom: .8rem; }
.guide-item { display: inline-flex; align-items: center; gap: .4rem; font-family: var(--font-c); font-size: 1rem; }
@media (min-width: 1051px) { .tipbar { margin-top: -.2rem; } }

/* keyboard focus and reduced motion */
.hex:focus { outline: none; }
.hex:focus-visible .hex-shape { stroke: #fff; stroke-width: 3.6; }
.card.clickable:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
  .card.clickable:hover, .card.selected { transform: none; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* log card links, presence */
.log-card { background: none; border: none; padding: 0; font: inherit; color: #e8c97a; cursor: pointer; text-decoration: underline; text-decoration-color: #e8c97a55; text-underline-offset: 2px; }
.log-card:hover { color: #f4dc9c; text-decoration-color: currentColor; }
.badge-off { color: #e3a196; border-color: #7a3a30; }

/* compact player cards for 3+ players */
.compact-only { display: none; }
.players.compact .compact-only { display: inline-flex; }
.players.compact .phead .compact-only.muted { margin-left: auto; }
.players.compact .phead .tr { margin-left: .3rem; }
.players.compact .pcorp { display: none; }
.players.compact .pcard { padding: .35rem .5rem; }
.players.compact .res-cell { display: flex; align-items: center; justify-content: center; gap: .15rem; padding: .1rem 0; }
.players.compact .res-prod { border-top: none; margin: 0; font-size: .75rem; }
.players.compact .res-amt { font-size: .95rem; }
.players.compact .res-cell .ico { width: 14px; height: 14px; }
.players.compact .ptags { margin-top: .25rem; }
.players.compact .tagcount .ico { width: 13px; height: 13px; }

/* chat */
ul.chat { list-style: none; margin: 0 0 .5rem; padding: 0; font-size: .88rem; max-height: 100%; overflow-y: auto; }
ul.chat li { padding: .22rem 0; border-bottom: 1px solid #ffffff0c; overflow-wrap: anywhere; }
.chat-form { display: flex; gap: .4rem; position: sticky; bottom: 0; background: var(--panel); padding-top: .3rem; }
.chat-form input { flex: 1; min-width: 0; }
.note-chat { border-left-color: #6f8fd0; }

/* settings, library, final generation */
.settings { display: flex; flex-direction: column; gap: .7rem; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-family: var(--font-c); font-size: 1.05rem; }
.lib-filters { display: flex; flex-direction: column; gap: .5rem; padding: .7rem 1rem 0; }
.lib-filters input { width: 100%; }
.lib-tags { flex-wrap: wrap; }
.badge-final { background: var(--brass); border-color: var(--brass); color: #2a1d00; font-size: .8rem; padding: .1rem .45rem; }
.hex-owner { font: 700 7.5px var(--font-c); text-anchor: middle; pointer-events: none; }
.planet-disc { fill: #1d1a1c; stroke: #3a2a24; stroke-width: 1.5; }

/* official card art */
.card-art.official { object-fit: cover; }
.card-art.official-project { object-position: 50% 34%; }
.card-art.official-corporation { object-position: 50% 18%; }
.printed-large { width: min(340px, 100%); height: auto; border-radius: 12px; box-shadow: 0 6px 20px #000a; flex: none; }
.printed-large-corporation { width: min(460px, 100%); }
.card.printed { width: 180px; background: transparent; border: none; box-shadow: none; overflow: visible; border-radius: 9px; }
.card.printed.printed-corporation { width: 300px; }
.card.printed .printed-img { display: block; width: 100%; height: auto; border-radius: 9px; box-shadow: 0 2px 8px #000a; }
.card.printed.playable .printed-img { outline: 3px solid var(--brass); outline-offset: 1px; }
.card.printed.selected .printed-img { outline: 3px solid var(--rust); outline-offset: 1px; }
.card.printed.unplayable .printed-img { filter: saturate(.5) brightness(.8); }
.card.printed.playable, .card.printed.selected { box-shadow: none; }
.printed-cost { position: absolute; top: 3px; left: 3px; background: #9fd38f; color: #183a10; border: 1px solid #4e8a3e; font: 700 1rem var(--font-c); border-radius: 4px; padding: 0 6px; }
.printed-req { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: #8b2b1cee; color: #fff; font: 700 .7rem var(--font-c); text-transform: uppercase; letter-spacing: .05em; border-radius: 3px; padding: .05rem .35rem; }
.printed-info { position: absolute; left: 6px; right: 6px; bottom: 8px; display: flex; gap: 4px; justify-content: flex-end; align-items: center; }
.printed-info .card-res, .printed-info .used-mark, .printed-vp { background: #1b1d22ee; color: #fff; border-radius: 10px; padding: 1px 7px; font: 700 .8rem var(--font-c); }
.card.printed .card-actions { padding: 5px 0 0; }
.card.printed .card-reason { border-radius: 4px; margin-top: 4px; }
.dock .card.printed { width: 150px; }
.dock .card.printed.printed-corporation { width: 260px; }
.ico-img { object-fit: contain; border-radius: 50%; }
.ico-img.ico-card, .ico-img.ico-steel, .ico-img.ico-titanium, .ico-img.ico-plants, .ico-img.ico-energy, .ico-img.ico-heat { border-radius: 3px; }
.art-box { border-top: 1px solid var(--line); padding-top: .7rem; display: flex; flex-direction: column; gap: .5rem; }
.art-box h3 { margin: 0; }
/* printed board mode */
.board-wrap.art { background: #0c0b14; }
.board-svg.art .hex-shape { stroke: none; }
.board-svg.art .hex.hl .hex-shape { stroke: #f4e3a0; stroke-width: 2.6; fill: rgba(255, 240, 180, 0.12); }
.board-svg.art .hex.hl:hover .hex-shape { fill: rgba(255, 240, 180, 0.28); }
.board-svg.art .hex.flash .hex-shape { stroke: #fff; }

/* ======================================================================
   Phones: app-style layout (header, prompt, board, tabbed panel)
   ====================================================================== */
.lbl-short { display: none; }
@media (max-width: 700px), (max-height: 500px) {
  body.in-game { height: 100vh; height: 100dvh; overflow: hidden; }
  .game.mobile { height: 100vh; height: 100dvh; display: flex; flex-direction: column; padding: 0 !important; overflow: hidden; }
  .lbl-long { display: none; }
  .lbl-short { display: inline; }

  .m-top { display: flex; align-items: center; gap: .4rem; padding: .35rem .5rem; border-bottom: 1px solid var(--line); background: var(--bg2); flex: none; }
  .m-gen { display: flex; flex-direction: column; line-height: 1.05; font-family: var(--font-c); min-width: 3.4rem; }
  .m-gen b { font-size: 1rem; }
  .m-gen span { font-size: .72rem; color: var(--muted); white-space: nowrap; }
  .m-final { color: var(--brass) !important; font-weight: 700; text-transform: uppercase; }
  .m-gauges { flex: 1; display: flex; gap: .4rem; min-width: 0; }
  .mg { flex: 1; min-width: 0; display: grid; grid-template-columns: 1fr auto; align-items: baseline; font-family: var(--font-c); }
  .mg-l { font-size: .62rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); overflow: hidden; }
  .mg b { font-size: .8rem; }
  .mg.done b { color: var(--good); }
  .mg i { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: #2a2f37; position: relative; overflow: hidden; }
  .mg i::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--p); border-radius: 2px; background: #d9662f; }
  .mg.g-oxy i::after { background: #58a86a; }
  .mg.g-ocean i::after { background: #3d86cf; }
  .m-top .btn-small { padding: .3rem .5rem; }

  .game.mobile .prompt-area { padding: .35rem .5rem 0; flex: none; }
  .game.mobile .promptbar { margin: 0 0 .35rem; padding: .35rem .5rem; gap: .35rem .5rem; flex-wrap: wrap; }
  .game.mobile .pb-title { font-size: .95rem; flex: 1 1 auto; min-width: 0; }
  .game.mobile .pb-hint { display: none; }
  .game.mobile .promptbar.ai .pb-recent { display: none; }
  .game.mobile .pb-buttons { margin-left: 0; flex-wrap: nowrap; overflow-x: auto; width: 100%; }
  .game.mobile .promptbar.mine .pb-buttons { width: auto; margin-left: auto; }
  .game.mobile .pb-buttons .btn { padding: .35rem .6rem; font-size: .9rem; }
  .game.mobile .tipbar { margin: 0 0 .35rem; padding: .25rem .5rem; font-size: .74rem; gap: .4rem; }
  .game.mobile .tipbar > span:nth-child(2) { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .game.mobile .tipbar .btn { padding: .1rem .35rem; font-size: .75rem; }

  .board-wrap.m-board { flex: 1 1 auto; min-height: 0; margin: 0 .4rem .35rem; padding: 2px; display: flex; align-items: center; justify-content: center; }
  .m-board .board-svg { width: 100%; height: 100%; }

  .game.mobile .dock { position: static; flex: none; max-height: min(46dvh, 292px); margin: 0; box-shadow: 0 -4px 12px #0008; }
  .game.mobile .dock.closed { max-height: none; }
  .game.mobile .dock-head { flex-wrap: nowrap; padding: .25rem .4rem; gap: .25rem; }
  .game.mobile .dock-tabs { overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
  .game.mobile .dock-tab { padding: .3rem .45rem; font-size: .82rem; white-space: nowrap; }
  .game.mobile .dock-tab .count.hot { display: inline; }
  .game.mobile .dock-sort, .game.mobile .hand-filter, .game.mobile .dock-owner, .game.mobile .dock .mods { display: none; }
  .game.mobile .dock-head > .btn { padding: .25rem .45rem; font-size: .8rem; }
  .game.mobile .dock .card-row { padding: .45rem .5rem .55rem; gap: .45rem; }
  .game.mobile .dock .card { width: 142px; }
  .game.mobile .dock .card.printed { width: 140px; }
  .game.mobile .dock .card-text { font-size: .7rem; -webkit-line-clamp: 4; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
  .game.mobile .dock .card-name { font-size: .8rem; }
  .game.mobile .dock .card-art-wrap { height: 34px; }
  .m-panel { overflow-y: auto; padding: .5rem .6rem .8rem; min-height: 0; }
  .m-panel h3 { margin: .6rem 0 .35rem; }
  .m-panel h3:first-child { margin-top: 0; }
  .m-panel .std-grid { grid-template-columns: repeat(3, 1fr); gap: .35rem; }
  .m-panel .std-btn { grid-template-columns: 1fr; text-align: center; padding: .4rem .25rem; row-gap: .15rem; }
  .m-panel .std-cost { grid-row: auto; justify-self: center; }
  .m-panel .std-desc { display: none; }
  .m-panel .players { gap: .4rem; }
  .m-events { flex: none; width: 128px; display: flex; flex-direction: column; gap: .3rem; overflow-y: auto; align-self: stretch; }
  .m-events-h { font-family: var(--font-c); font-weight: 700; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .m-events .event-chip { color: var(--text); font: inherit; font-size: .78rem; cursor: pointer; text-align: left; min-height: 32px; }
  .game.mobile .notes { left: .5rem; right: .5rem; max-width: none; bottom: calc(min(46dvh, 292px) + .5rem); }

  /* dialogs become sheets: big ones fill the screen, small ones rise from the bottom */
  .modal-backdrop { padding: 0; align-items: end; justify-items: stretch; }
  .modal { width: 100%; max-height: 92dvh; border-radius: 12px 12px 0 0; border-left: none; border-right: none; border-bottom: none; }
  .modal.wide { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .modal-head { padding: .5rem .7rem; flex-wrap: nowrap; gap: .4rem; }
  .modal-head h2 { font-size: 1.05rem; flex: 1; min-width: 0; line-height: 1.2; }
  .modal-head .spacer { display: none; }
  .modal-head .btn { padding: .3rem .5rem; font-size: .85rem; }
  .modal-body { padding: .6rem; }
  .modal-foot { padding: .5rem .7rem calc(.5rem + env(safe-area-inset-bottom)); }
  .modal .card-row.wrap { gap: .5rem; }
  .modal .card-row.wrap > .card { width: calc(50% - .25rem); }
  .modal .card-row.wrap > .card.card-corp, .modal .card-row.wrap > .card.printed-corporation { width: 100%; }
  .modal .card-text { font-size: .74rem; }
  .inspect { gap: .8rem; }
  .card.big { width: 100%; }
  .printed-large { width: 100%; }

  /* stop iOS zooming into form fields */
  input, select, textarea { font-size: 16px; }
}
/* blue cards print their action box over the top of the painting: crop lower */
.card-active .card-art.official-project { object-position: 50% 56%; }
@media (max-width: 700px), (max-height: 500px) {
  .game.mobile .dock-tab { text-transform: none; letter-spacing: 0; font-size: .9rem; padding: .3rem .4rem; gap: .25rem; }
  .game.mobile .dock-tabs { gap: 0; }
  .game.mobile .dock-head > [data-act="dockToggle"], .game.mobile .dock-head > .spacer { display: none; }
}
.inspect-rules { display: none; }
@media (max-width: 700px), (max-height: 500px) {
  /* with the printed card shown, the game's own card would be a duplicate: show its rules text instead */
  .inspect-card.has-printed { display: none; }
  .inspect-card.has-printed ~ .inspect-info .inspect-rules { display: block; }
  .inspect-info { min-width: 0; }
  .inspect-foot { flex-wrap: wrap; }
}
@media (max-width: 700px), (max-height: 500px) {
  .m-panel .pres { grid-template-columns: repeat(6, 1fr); gap: 2px; }
  .m-panel .res-cell { flex-direction: column; gap: 0; padding: .1rem 0; }
  .m-panel .res-amt { font-size: .9rem; }
  .m-panel .res-prod { font-size: .7rem; }
  .m-panel .pcard { padding: .35rem .45rem; }
}
@media (max-width: 700px), (max-height: 500px) {
  .modal.wide .modal-body { flex: 1 1 auto; }
}
@media (max-width: 700px), (max-height: 500px) {
  .m-panel .phead { flex-wrap: wrap; row-gap: .15rem; }
  .m-panel .pname { flex: 0 1 auto; min-width: 2.5rem; }
  .m-panel .phead .compact-only.muted { order: 10; flex-basis: 100%; margin-left: 0; }
  .m-panel .phead .tr { margin-left: auto; }
}
/* touch targets */
@media (max-width: 700px), (max-height: 500px), (pointer: coarse) {
  .btn { min-height: 36px; }
  .btn-small { min-height: 32px; }
  .pay-row .btn, .amount .btn { min-width: 42px; min-height: 42px; justify-content: center; font-size: 1.15rem; }
  .pay-row { grid-template-columns: 1fr auto 2.6rem auto; }
  .pay-row .muted { display: none; }
  .btn-option { min-height: 44px; }
  .btn-action, .btn-play { min-height: 34px; }
  .side-tab, .dock-tab { min-height: 34px; }
  .std-btn { min-height: 44px; }
}
/* short phones: give the map the room */
@media (max-width: 700px) and (max-height: 700px), (max-height: 500px) {
  .game.mobile .tipbar { display: none; }
  .game.mobile .dock { max-height: min(40dvh, 236px); }
  .game.mobile .dock .card-text { display: none; }
  .game.mobile .dock .card-reason { display: none; }
  .game.mobile .dock .card { width: 128px; }
  .game.mobile .dock .card-name { font-size: .74rem; }
}
@media (max-width: 360px) {
  .game.mobile .lbl-short { display: none; }
  .game.mobile .promptbar.mine .pb-buttons .btn { padding: .35rem .5rem; }
  .m-gen { min-width: 2.8rem; }
  .mg-l { display: none; }
  .mg { grid-template-columns: 1fr; text-align: center; }
}

/* landscape phones: dialog sizes (the page layout is in the phone page block below) */
@media (max-height: 500px) and (min-width: 560px) {
  .modal .card-row.wrap > .card { width: 150px; }
  .modal .card-row.wrap > .card.card-corp, .modal .card-row.wrap > .card.printed-corporation { width: 260px; }
  .modal.wide { height: 100dvh; max-height: 100dvh; }
}
.table-wrap { overflow-x: auto; }
@media (max-width: 700px), (max-height: 500px) {
  .modal-backdrop { grid-template-columns: minmax(0, 1fr); }
  .modal { min-width: 0; max-width: 100vw; }
  table.scores { font-size: .85rem; }
  table.scores th { letter-spacing: 0; font-size: .75rem; }
  table.scores th, table.scores td { padding: .35rem .25rem; }
  table.scores .total { font-size: 1.05rem; }
  .bar-row { grid-template-columns: 4.5rem 1fr 2.2rem; gap: .4rem; }
}
@media (max-width: 700px) {
  .start { padding: 1.4rem .8rem 3rem; }
  .start .btn-big { width: 100%; justify-content: center; }
  .player-row { display: grid; grid-template-columns: 92px 1fr; gap: .4rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
  .player-row input[data-field="name"] { min-width: 0; }
  .player-row select[data-field="ai"] { grid-column: 1 / 2; }
  .player-row .chk { grid-column: 2; }
  .player-row [data-act="removePlayer"] { grid-column: 1 / -1; justify-self: end; }
}
@media (pointer: coarse) {
  .ma-row .btn-small, .join .btn { min-height: 40px; }
}
/* phones: a card with action buttons drops its rules text (the buttons say it) so it fits the dock */
@media (max-width: 700px), (max-height: 500px) {
  .game.mobile .dock .card:has(.btn-action) .card-text,
  .game.mobile .dock .card:has(.btn-action) .card-art-wrap { display: none; }
  .game.mobile .dock .btn-action { font-size: .72rem; line-height: 1.15; padding: .25rem .35rem; min-height: 32px; text-align: left; }
  .game.mobile .dock .btn-action:disabled { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
@media (max-width: 700px), (max-height: 500px) {
  .game.mobile .dock .card.printed:has(.btn-action) { position: relative; }
  .game.mobile .dock .card.printed .card-actions:has(.btn-action) { position: absolute; left: 4px; right: 4px; bottom: 4px; margin: 0; display: grid; gap: 3px; }
  .game.mobile .dock .card.printed .btn-action { box-shadow: 0 2px 6px #000a; }
  .game.mobile .dock .card.printed .btn-action:disabled { display: none; }
}

/* ---------------------------------------------------------------- phone page (after BGA's mobile layout) */
@media (max-width: 700px), (max-height: 500px) {
  .m-page { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-bottom: 5rem; }
  .m-board-sec { padding: 0 .3rem .3rem; }
  .board-wrap.m-board { margin: 0; padding: 2px; display: block; }
  .m-board .board-svg { width: 100%; height: auto; display: block; max-height: 78dvh; }
  .m-sections { display: flex; flex-direction: column; gap: .5rem; padding: 0 .35rem; }

  .m-sec { border: 1px solid var(--line); border-radius: 8px; background: var(--bg2); overflow: hidden; --sec: #6d7480; }
  .m-sec-head { display: flex; align-items: center; gap: .45rem; width: 100%; padding: .4rem .55rem; border: 0; color: var(--text); text-align: left; cursor: pointer;
    background: color-mix(in srgb, var(--sec) 32%, var(--bg2)); font-family: var(--font-c); font-size: .95rem; font-weight: 700; min-height: 40px; }
  .m-sec-n { display: inline-grid; place-items: center; min-width: 1.6rem; height: 1.6rem; padding: 0 .3rem; border-radius: 5px; background: var(--sec); color: #fff; font-size: .9rem; }
  .m-sec-t { flex: 1 1 auto; min-width: 0; text-transform: uppercase; letter-spacing: .04em; }
  .m-sec-head .count { margin-left: auto; }
  .m-sec-chev { width: .55rem; height: .55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translate(-2px, -2px); opacity: .7; flex: none; margin-left: .2rem; }
  .m-sec.collapsed .m-sec-chev { transform: rotate(-45deg); }
  .m-sec-body { padding: .45rem; }
  .m-sec-body > .muted.empty { margin: .2rem; }
  .m-hand { --sec: #c46b2b; }
  .m-proj { --sec: #5c6b80; }
  .m-corp { --sec: #8a8f99; }
  .m-blue { --sec: #2f72c4; }
  .m-green { --sec: #3f8b3c; }
  .m-red { --sec: #b4483a; }
  .m-proj .m-panel { padding: 0; overflow: visible; }

  /* three cards to a row, as on BGA */
  .m-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; align-items: start; }
  .m-grid > .card, .m-grid > .card.printed { width: auto; min-width: 0; margin: 0; }
  .m-grid-corp > .card { grid-column: span 2; }
  .m-page .card-name { font-size: .72rem; }
  .m-page .card-text { font-size: .66rem; line-height: 1.25; }
  .m-page .card-art-wrap { height: 30px; }
  .m-page .card .btn-play { width: 100%; justify-content: center; }
  .m-page .card:has(.btn-action) .card-text, .m-page .card:has(.btn-action) .card-art-wrap { display: none; }
  .m-page .btn-action { font-size: .7rem; line-height: 1.15; padding: .25rem .35rem; min-height: 34px; text-align: left; width: 100%; }
  .m-page .btn-action:disabled { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .m-page .card.printed:has(.btn-action) { position: relative; }
  .m-page .card.printed .card-actions:has(.btn-action) { position: absolute; left: 3px; right: 3px; bottom: 3px; margin: 0; display: grid; gap: 3px; }
  .m-page .card.printed .btn-action { box-shadow: 0 2px 6px #000a; }
  .m-page .card.printed .btn-action:disabled { display: none; }

  /* effect cards fan downwards so each one's title and effect stay visible */
  .m-stack { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; align-items: start; }
  .m-stack-col { display: flex; flex-direction: column; min-width: 0; }
  .m-stack-item { position: relative; }
  .m-stack-item:not(.last) { height: 4.6rem; overflow: hidden; border-bottom: 1px solid #0006; }
  .m-stack-item:not(.last):has(.card.printed) { height: auto; aspect-ratio: 1 / .62; }
  .m-stack-item > .card, .m-stack-item > .card.printed { width: 100%; margin: 0; }

  /* each player's area opens with their board: resources, production and tags */
  .m-player { display: flex; flex-direction: column; gap: .4rem; padding-top: .3rem; }
  .m-player + .m-player, .m-proj + .m-player { margin-top: .5rem; border-top: 2px solid var(--pc); padding-top: .6rem; }
  .m-player .pcard { margin: 0; }
  .m-player .pcorp .btn, .m-player .phead .compact-only { display: none; }

  /* round buttons in the corner, like BGA's log and chat */
  .m-fab { position: fixed; right: .75rem; bottom: calc(.75rem + env(safe-area-inset-bottom)); display: flex; gap: .5rem; z-index: 40; }
  .fab { position: relative; width: 52px; height: 52px; border-radius: 50%; border: 1px solid #0006; background: #f3efe6; color: #1b1b1f; font-family: var(--font-c); font-weight: 700; font-size: .9rem;
    box-shadow: 0 3px 10px #000a; cursor: pointer; }
  .fab-n { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--accent, #d9662f); color: #fff; font-size: .72rem; display: grid; place-items: center; padding: 0 4px; }
  .game.mobile .notes { left: .5rem; right: .5rem; max-width: none; bottom: calc(4.4rem + env(safe-area-inset-bottom)); }
  .m-log, .m-chat { min-height: 0; }
}
@media (max-width: 360px) {
  .m-grid, .m-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* landscape phones: the map stays put on the left while the cards scroll on the right */
@media (max-height: 500px) and (min-width: 560px) {
  .m-page { display: grid; grid-template-columns: minmax(0, 44%) minmax(0, 1fr); align-items: start; padding-bottom: 4rem; }
  .m-board-sec { position: sticky; top: 0; padding: .3rem; }
  .m-board .board-svg { max-height: calc(100dvh - 6rem); }
  .m-sections { padding: .3rem .35rem 0 0; }
  .game.mobile .notes { left: auto; right: .5rem; width: 50%; }
}
@media (max-width: 700px), (max-height: 500px) {
  /* BGA-style player strip: all six resources in one row, production underneath */
  .m-player .pres { grid-template-columns: repeat(6, 1fr); gap: 2px; }
  .m-player .res-cell { flex-direction: column; gap: 0; padding: .15rem 0; }
  .m-player .res-amt { font-size: .95rem; }
  .m-player .res-prod { font-size: .72rem; }
  .m-player .pcard { padding: .4rem .5rem; }
  /* on small cards the requirement flag sits low, clear of the title */
  .m-page .printed-req { top: auto; bottom: 30%; font-size: .56rem; letter-spacing: .02em; padding: .05rem .25rem; }
}
@media (max-width: 700px), (max-height: 500px) {
  .m-page { position: relative; }
  .m-lead { display: flex; flex-direction: column; gap: .5rem; padding: .1rem .35rem .5rem; }
  .m-grid.m-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .m-grid-2 .card-name { font-size: .8rem; }
  .m-grid-2 .card-text { font-size: .72rem; }

  /* all players at a glance */
  .m-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .35rem; }
  .mo-p { display: flex; flex-direction: column; gap: .25rem; min-width: 0; padding: .35rem .4rem; text-align: left; cursor: pointer; color: var(--text); font: inherit;
    background: var(--bg2); border: 1px solid var(--line); border-top: 3px solid var(--pc); border-radius: 7px; }
  .mo-p.active { box-shadow: 0 0 0 2px var(--pc) inset; }
  .mo-p.passed { opacity: .72; }
  .mo-head { display: flex; align-items: center; gap: .3rem; min-width: 0; }
  .mo-name { color: var(--pc); font-family: var(--font-c); font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 0 1 auto; min-width: 0; filter: brightness(1.25); }
  .mo-head .badge { font-size: .62rem; padding: 0 .25rem; }
  .mo-vp { margin-left: auto; flex: none; display: grid; place-items: center; min-width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #3a3220; border: 1px solid #a8893e; color: #f2d58a; font: 700 .8rem var(--font-c); }
  .mo-sub { display: flex; align-items: center; gap: .4rem; font-size: .72rem; color: var(--muted); min-width: 0; }
  .mo-tr { background: #c4612b; color: #fff; font: 700 .72rem var(--font-c); padding: 0 .3rem; border-radius: 3px; flex: none; }
  .mo-hand { display: inline-flex; align-items: center; gap: 2px; flex: none; }
  .mo-corp { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .mo-resrow { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
  .mo-res { display: flex; flex-direction: column; align-items: center; background: #ffffff0d; border-radius: 3px; padding: 1px 0; line-height: 1.1; min-width: 0; }
  .mo-res .ico { width: 13px; height: 13px; }
  .mo-res b { font-size: .78rem; }
  .mo-prod { font-size: .62rem; color: var(--muted); }
  .mo-prod.neg { color: #e0705c; }
  .mo-tags { display: flex; flex-wrap: wrap; gap: 2px 6px; font-size: .7rem; }
  .mo-tag { display: inline-flex; align-items: center; gap: 2px; }
  .mo-tag .ico { width: 13px; height: 13px; }
}
@media (max-height: 500px) and (min-width: 560px) {
  .m-page { grid-template-rows: auto 1fr; }
  .m-board-sec { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
  .m-lead { grid-column: 2; grid-row: 1; padding: .3rem .35rem .5rem 0; }
  .m-sections { grid-column: 2; grid-row: 2; }
}
@media (max-height: 500px) and (min-width: 560px) {
  .m-board .board-svg { max-height: calc(100dvh - 8.4rem); }
}
@media (max-width: 700px), (max-height: 500px) {
  .m-player .card-req { display: none; }
}
@media (max-width: 700px), (max-height: 500px) {
  /* the prompt keeps one height whoever's turn it is, so the page below never shifts */
  .game.mobile .tipbar { display: none; }
  .game.mobile .promptbar { min-height: 78px; align-content: center; }
  /* printed cards: a short Use button over the art instead of the action text */
  .m-page .btn-use, .btn-use { justify-content: center; text-align: center; font-size: .85rem; font-weight: 700; }
  .m-page .card.printed .btn-use { min-height: 36px; }
}
.card.printed .btn-use { width: 100%; justify-content: center; }

/* ---------- card panel: printed cards are sized from the panel's height, so card and button always fit */
.dock { --dock-h: min(330px, 46vh); max-height: var(--dock-h); }
@media (min-width: 1051px) { .dock { --dock-h: min(272px, 34vh); } }
@media (min-width: 1051px) and (max-height: 760px) { .dock { --dock-h: 34vh; } }
@media (max-width: 640px) { .dock { --dock-h: 42vh; } }
.dock.closed { max-height: none; }
/* panel header (~44px) and row padding (~22px) come off the top; printed project cards are 320x448 */
.dock .card.printed:not(.printed-corporation) { width: clamp(90px, calc((var(--dock-h) - 68px) / 1.4), 160px); }
.dock .card.printed.printed-corporation { width: clamp(150px, calc((var(--dock-h) - 68px) / 0.716), 260px); }
/* Play / Use and the reason a card can't be played sit over the bottom of the art instead of under it */
.dock .card.printed { position: relative; }
.dock .card.printed .card-actions, .dock .card.printed .card-reason { position: absolute; left: 5px; right: 5px; bottom: 5px; margin: 0; padding: 0; }
.dock .card.printed .card-actions { display: grid; gap: 3px; }
.dock .card.printed .card-actions .btn { width: 100%; justify-content: center; box-shadow: 0 2px 8px #000c; }
.dock .card.printed .card-reason { font-size: .72rem; box-shadow: 0 2px 8px #000c; }
/* the requirement flag sits low on the card, clear of the title */
.printed-req { top: auto; bottom: 30%; }
/* card inspector: with the printed card shown, our text version would only repeat it; the rules text
   moves to the info column and the action buttons are in the footer */
.inspect-card.has-printed { display: none; }
.inspect-card.has-printed ~ .inspect-info .inspect-rules { display: block; }
