:root {
  --bg: #13151b;
  --panel: #1d2029;
  --panel2: #262a35;
  --line: #343948;
  --text: #e9ecf2;
  --muted: #9aa1b2;
  --red: #e5533f;
  --blue: #3f7be5;
  --me: var(--red);         /* your team's color in game; set when a match starts */
  --foe: var(--blue);
  --accent: #f2c14e;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(ellipse at top, #1e2230, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
.hidden { display: none !important; }
.screen { position: absolute; inset: 0; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; color: var(--text); background: var(--panel2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 16px;
  cursor: pointer; transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover { background: #303544; border-color: #4a5165; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(90deg, var(--red), var(--blue)); border: none; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 6px 12px; font-size: 13px; }

/* ---------- menu ---------- */
#menu, #waiting, #hostScreen { display: flex; justify-content: center; padding: 16px; overflow-y: auto; }
#menu > .menu-card, #waiting > .menu-card, #hostScreen > .menu-card { margin: auto 0; }
#waiting > .menu-card { width: min(600px, 100%); }
.menu-card {
  width: min(480px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.menu-card.center { text-align: center; }
h1 { margin: 0; font-size: 46px; letter-spacing: 4px; font-weight: 900; }
h1 .r { color: var(--red); }
h1 .b { color: var(--blue); }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 26px 0 10px; }
.tag { color: var(--muted); margin: 4px 0 20px; }
.field { display: block; color: var(--muted); font-size: 13px; }
.field select {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none; cursor: pointer;
}
.field select:focus { border-color: var(--accent); }
.bot-field { text-align: left; margin: 14px 0 4px; }
.ballot-title { margin: 4px 0 10px; }
.ballot { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.mapcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px 8px; font: inherit; color: var(--text); cursor: pointer;
  background: var(--panel2); border: 2px solid var(--line); border-radius: 12px;
  transition: border-color .12s, transform .12s, background .12s;
}
.mapcard:hover { border-color: #59617a; transform: translateY(-2px); }
.mapcard.mine { border-color: var(--accent); background: #2f2c22; box-shadow: 0 6px 20px rgba(242,193,78,.18); }
.mapcard canvas { display: block; border-radius: 4px; box-shadow: 0 0 0 1px #0a0b0e; }
.mapname { font-weight: 800; font-size: 13px; text-align: center; }
.mapcard .votes {
  position: absolute; top: -9px; right: -9px; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px;
  display: grid; place-items: center; font-weight: 900; font-size: 16px; color: #1d2029;
  background: var(--accent); border: 2px solid #1d2029; box-shadow: 0 2px 6px rgba(0,0,0,.5); z-index: 1;
}
.mapcard .votes.zero { background: #4a5065; color: #d6dae4; }
#mapTally { margin: 0 0 16px; font-size: 13px; }
.field input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.actions { display: grid; gap: 12px; margin-top: 18px; }
.actions > .btn { padding: 14px; font-size: 16px; }
.bot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bot > span { color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg .btn { padding: 9px 14px; }
.seg .btn[data-level="1"]:hover { border-color: #5bd17a; }
.seg .btn[data-level="2"]:hover { border-color: var(--accent); }
.seg .btn[data-level="3"]:hover { border-color: #ff5a5a; }
#rooms { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
#rooms li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--panel2); border-radius: 8px; margin-bottom: 6px;
}
#rooms li.empty { color: var(--muted); justify-content: center; background: transparent; border: 1px dashed var(--line); }
#conn {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: #3a2a14; color: var(--accent); padding: 6px 14px; border-radius: 20px; font-size: 13px;
}
/* ---------- deck ---------- */
.deck-row { margin-top: 18px; }
.deck-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.deck-head h2 { margin: 0; }
.deck-preview { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.deck-preview .empty { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }
.chip {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0;
  padding: 5px 3px 4px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
}
.chip.instant { border-style: dashed; border-color: #4f6a8a; }
.chip canvas { flex: none; }
.chip .cost { width: 17px; height: 17px; font-size: 10px; top: -5px; left: -5px; border-width: 1px; }
.chip-name { max-width: 100%; font-size: 10px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#deckScreen { display: flex; justify-content: center; padding: 16px; overflow-y: auto; }
.deck-card {
  width: min(980px, 100%); margin: auto 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
}
.deck-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.deck-top h2 { margin: 0; }
.deck-top .tag { margin-bottom: 14px; }
.deck-count { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.deck-count.full { color: #8dffa8; }
.deck-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.dcard {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center;
  padding: 10px 10px 12px; font: inherit; color: var(--text); cursor: pointer;
  background: var(--panel2); border: 2px solid var(--line); border-radius: 12px;
  transition: border-color .12s, transform .12s, background .12s;
}
.dcard:hover { border-color: #59617a; transform: translateY(-2px); }
.dcard.instant { border-style: dashed; border-color: #4f6a8a; }
.dcard.instant .cstats { color: #9fd0ff; }
.dcard.selected { border-style: solid; border-color: var(--accent); background: #2f2c22; box-shadow: 0 6px 20px rgba(242,193,78,.18); }
.dcard canvas { margin-bottom: 4px; }
.dcard .check {
  position: absolute; top: 6px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
  color: #1d2029; background: var(--accent); opacity: 0; transition: opacity .12s;
}
.dcard.selected .check { opacity: 1; }
.deck-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.deck-actions .spacer { flex: 1; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.size-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.size-pick .btn { display: grid; align-content: start; gap: 4px; padding: 16px 10px; }
.size-pick .btn b { font-size: 17px; }
.size-pick .btn span { color: var(--muted); font-size: 13px; }
.size-pick .btn:hover { border-color: var(--accent); }
.seats { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 6px; }
.seat { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--panel2); border-radius: 8px; }
.seat.open { background: transparent; border: 1px dashed var(--line); color: var(--muted); }
.seat-team { flex: none; width: 46px; text-align: center; font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .5px; color: #fff; border-radius: 4px; padding: 2px 0; }
.seat-name { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .muted { margin-left: auto; font-size: 12px; }
.muted { color: var(--muted); }
.lobby-actions { display: flex; align-items: center; gap: 10px; }
.lobby-actions #startBtn { flex: 1; padding: 12px; font-size: 16px; }
.lobby-wait { flex: 1; text-align: right; color: var(--muted); font-size: 13px; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 10px; border-radius: 50%;
  border: 5px solid var(--panel2); border-top-color: var(--red); border-right-color: var(--blue);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- game ---------- */
#gameScreen { display: flex; flex-direction: column; }
#hud {
  display: grid; grid-template-columns: 1fr minmax(200px, 420px) 1fr auto; align-items: center; gap: 14px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.side { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.side.foe { justify-content: flex-end; }
.pname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side.me .pname, .side.me .pct { color: var(--me); }
.side.foe .pname, .side.foe .pct { color: var(--foe); }
.pct { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; }
.mid { text-align: center; }
#timer { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
#timer.urgent { color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }
.bar { position: relative; height: 10px; border-radius: 5px; background: var(--foe); overflow: hidden; margin-top: 3px; }
.bar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(0,0,0,.45); }
#barSegs { display: none; position: absolute; inset: 0; }
#hud.ffa .bar { height: 14px; border-radius: 7px; }
#hud.ffa #barMe { display: none; }
#hud.ffa #barSegs { display: flex; }
#hud.ffa .bar::after { z-index: 1; width: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.5); }
.seg {
  height: 100%; min-width: 0; overflow: hidden; transition: width .2s;
  display: flex; align-items: center; justify-content: center;
  font: 700 9px/1 system-ui; color: #fff; text-shadow: 0 1px 1px rgba(0,0,0,.6); white-space: nowrap;
}
.seg.me { box-shadow: inset 0 0 0 1.5px #fff; }
.barscale { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; }
#barMe { height: 100%; width: 50%; background: var(--me); transition: width .2s; box-shadow: 2px 0 0 #fff; }

#stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 8px; }
#board { display: block; border-radius: 4px; box-shadow: 0 0 0 2px #0a0b0e, 0 10px 40px rgba(0,0,0,.5); }
#board.camera-dragging { cursor: grabbing; }
#buildingMenu { position: fixed; display: flex; gap: 3px; padding: 4px; border: 1px solid #84918d; border-radius: 6px; background: #e4e9e6; box-shadow: 0 3px 12px rgba(0,0,0,.35); z-index: 40; }
#buildingMenu[hidden] { display: none; }
#buildingMenu button { display: grid; place-items: center; width: 34px; height: 32px; padding: 4px; border: none; border-radius: 3px; background: transparent; color: #000; font: 26px/1 system-ui; cursor: pointer; }
#buildingMenu button:hover { background: #cbd3cf; }
#buildingMenu #deleteBuilding:hover { background: #f3cbc4; }
#buildingMenu button:focus-visible { outline: 2px solid var(--accent); }
#buildingMenu #closeBuildingMenu { color: #d5362e; }
#buildingMenu #closeBuildingMenu:focus-visible { outline: none; background: #f3cbc4; }
#buildingMenu svg { width: 22px; height: 22px; fill: none; stroke: #000; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#tray {
  display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: center;
  padding: 10px 16px; background: var(--panel); border-top: 1px solid var(--line);
}
#energyBox .label { font-size: 13px; color: var(--muted); }
#energyBox .rate { font-variant-numeric: tabular-nums; color: #8dffa8; font-weight: 700; }
#energyBox .rate.taxed { color: #d8e86a; cursor: help; }
.energy-status { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-top: 4px; font-size: 11px; }
.building-count { color: var(--muted); font-size: 11px; }
#energyBox .label b { color: #8dffa8; font-size: 18px; font-variant-numeric: tabular-nums; }
#energyBar {
  position: relative; height: 16px; margin: 6px 0 10px; border-radius: 8px; overflow: hidden;
  background: #11241a; border: 1px solid #2c5a3a;
}
#energyFill {
  height: 100%; width: 0; background: linear-gradient(180deg, #8dffa8, #1faa4a);
  box-shadow: 0 0 10px rgba(80,255,130,.55);
}
#energyTicks {
  position: absolute; inset: 0;
  background-image: linear-gradient(90deg, transparent calc(100% - 2px), rgba(0,0,0,.45) calc(100% - 2px));
  background-size: 10% 100%;
}
#nextCard { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
#nextCard canvas { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; opacity: .8; }
#nextCard .cost { position: static; }
#nextCost:empty { display: none; }
.cost {
  position: absolute; top: -8px; left: -8px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 900; font-size: 13px; color: #fff;
  background: radial-gradient(circle at 35% 30%, #c4ffd0, #1faa4a 60%, #0d6428);
  border: 2px solid #0a1d10; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.card .charge {
  position: absolute; left: 8px; bottom: 4px; height: 3px; width: 0; max-width: calc(100% - 16px);
  border-radius: 2px; background: #5dff8a; opacity: 0; transition: opacity .15s;
}
.card.poor { opacity: .55; filter: saturate(.5); }
.card.instant { border-style: dashed; border-color: #4f6a8a; }
.card.instant .cstats { color: #9fd0ff; }
.card.instant.selected { border-style: solid; border-color: var(--accent); }
.card.poor .charge { opacity: 1; }
#cards { display: flex; gap: 10px; justify-content: center; min-height: 92px; }
#cards .empty { align-self: center; color: var(--muted); }
.card {
  position: relative; display: flex; gap: 10px; align-items: center; text-align: left;
  width: 260px; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
  transition: border-color .12s, transform .12s, background .12s;
}
.card:hover { border-color: #59617a; transform: translateY(-2px); }
.card.selected { border-color: var(--accent); background: #2f2c22; transform: translateY(-3px); box-shadow: 0 6px 20px rgba(242,193,78,.18); }
.card canvas { flex: none; }
.card .key {
  position: absolute; top: 6px; right: 8px; font-size: 11px; font-weight: 700; color: var(--muted);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
}
.cname { font-weight: 800; }
.cstats { font-size: 12px; color: var(--accent); }
.cdesc { font-size: 12px; color: var(--muted); line-height: 1.3; margin-top: 2px; }
#help { font-size: 12px; color: var(--muted); display: grid; gap: 3px; }
kbd, .camera-key {
  display: inline-block; min-width: 18px; text-align: center; font: 600 11px/16px system-ui;
  background: var(--panel2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; margin-right: 2px;
}

#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8,9,12,.6); backdrop-filter: blur(3px); }
#overlay .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 30px 40px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#resultTitle { font-size: 44px; margin: 0 0 6px; color: var(--text); text-transform: none; letter-spacing: 1px; font-weight: 900; }
#resultSub { color: var(--muted); margin: 0 0 20px; }

#toast {
  position: fixed; left: 50%; bottom: 140px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(20,22,28,.95); border: 1px solid var(--line); padding: 9px 16px; border-radius: 10px;
  transition: opacity .2s, transform .2s; z-index: 10; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Tall maps: cards move to a side panel so the board gets the full height. */
#gameScreen.vertical { display: grid; grid-template-columns: 1fr 340px; grid-template-rows: auto 1fr; }
#gameScreen.vertical #hud { grid-column: 1 / -1; }
#gameScreen.vertical #tray {
  grid-template-columns: 1fr; align-content: center; gap: 18px;
  border-top: none; border-left: 1px solid var(--line); overflow-y: auto;
}
#gameScreen.vertical #cards { flex-direction: column; align-items: stretch; }
#gameScreen.vertical .card { width: auto; }

#touchBar, #rotateHint { display: none; }

/* ---------- phones and tablets (body.mobile is set on load from the device type) ---------- */
body.mobile { height: 100dvh; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.mobile input { -webkit-user-select: text; user-select: text; }
body.mobile .btn { touch-action: manipulation; }
body.mobile h1 { font-size: 38px; }
body.mobile .menu-card { padding: 22px 18px; }
body.mobile #gameScreen, body.mobile #gameScreen.vertical { display: flex; flex-direction: column; }
body.mobile #hud {
  grid-template-columns: 1fr 1fr auto; grid-template-areas: "red blue leave" "mid mid mid";
  row-gap: 0; gap: 6px; padding: calc(4px + env(safe-area-inset-top)) 10px 6px;
}
body.mobile .side.me { grid-area: red; }
body.mobile .side.foe { grid-area: blue; }
body.mobile .mid { grid-area: mid; }
body.mobile #leaveBtn { grid-area: leave; }
body.mobile .pname { font-size: 13px; }
body.mobile .pct { font-size: 15px; }
body.mobile #timer { font-size: 16px; line-height: 1.1; }
body.mobile .barscale { display: none; }
body.mobile #stage { padding: 4px; overflow: hidden; }
body.mobile #board { touch-action: none; }
body.mobile #tray, body.mobile #gameScreen.vertical #tray {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; overflow: visible;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-left: none; border-top: 1px solid var(--line);
}
body.mobile #energyBox { display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: center; }
body.mobile #energyBox .label { grid-column: 1; font-size: 12px; }
body.mobile #energyBox .label b { font-size: 15px; }
body.mobile #energyBox .energy-status { grid-column: 1; grid-row: 2; margin-top: 0; }
body.mobile #energyBar { grid-column: 1; grid-row: 3; height: 12px; margin: 2px 0 0; }
body.mobile #nextCard { grid-column: 2; grid-row: 1 / span 3; font-size: 11px; gap: 4px; }
body.mobile #nextCard .cost { width: 18px; height: 18px; font-size: 10px; }
body.mobile #cards, body.mobile #gameScreen.vertical #cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; min-height: 0; padding-top: 6px;
}
body.mobile .card, body.mobile #gameScreen.vertical .card {
  flex-direction: column; gap: 2px; width: auto; min-width: 0; padding: 6px 2px 5px; text-align: center; border-radius: 10px;
}
body.mobile .card:hover { transform: none; border-color: var(--line); }
body.mobile .card.selected { transform: translateY(-3px); border-color: var(--accent); }
body.mobile .card .info { width: 100%; }
body.mobile .card .cname { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.mobile .card .cstats, body.mobile .card .cdesc, body.mobile .card .key { display: none; }
body.mobile .card .charge { left: 6px; bottom: 2px; max-width: calc(100% - 12px); }
body.mobile .cost { width: 20px; height: 20px; font-size: 11px; top: -6px; left: -6px; }
body.mobile #touchBar { display: flex; align-items: center; gap: 6px; min-height: 38px; }
body.mobile #touchHint { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); line-height: 1.25; }
body.mobile #touchBar .btn { padding: 9px 12px; font-size: 14px; white-space: nowrap; }
body.mobile #touchBar .btn:disabled { opacity: .45; }
body.mobile #help { display: none; }
body.mobile #toast { bottom: calc(200px + env(safe-area-inset-bottom)); }
body.mobile #overlay .panel { padding: 24px 20px; margin: 16px; }
body.mobile #deckScreen { height: 100dvh; }
body.mobile .deck-card { padding: 16px 12px; }
body.mobile .deck-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
body.mobile .dcard { padding: 8px 6px 10px; }
body.mobile .dcard:hover { transform: none; }
body.mobile .dcard .cdesc { font-size: 11px; }
body.mobile .deck-preview { gap: 4px; }
body.mobile .size-pick { grid-template-columns: 1fr; }
@media (orientation: landscape) and (max-height: 520px) {
  body.mobile #rotateHint {
    position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; gap: 8px;
    align-items: center; justify-content: center; background: rgba(13,15,20,.96); font-size: 18px; font-weight: 700;
  }
  body.mobile #rotateHint div { font-size: 46px; }
}

/* Narrow screens: names and percentages get their own row above the bar. */
@media (max-width: 760px) {
  #hud { grid-template-columns: 1fr 1fr auto; grid-template-areas: "red blue leave" "mid mid mid"; row-gap: 2px; }
  .side.me { grid-area: red; }
  .side.foe { grid-area: blue; }
  .mid { grid-area: mid; }
  #leaveBtn { grid-area: leave; }
}

@media (max-width: 1100px) {
  #gameScreen.vertical { grid-template-columns: 1fr 240px; }
  #tray { grid-template-columns: 1fr; gap: 8px; }
  #help { display: none; }
  .card { width: auto; flex: 1; }
  .card .cdesc { display: none; }
}

/* ---------- Borderlines contest UI prototype ---------- */
:root {
  --bg: #10131a;
  --panel: #1b2029;
  --panel2: #252b36;
  --line: rgba(198, 211, 233, .16);
  --text: #f0eee5;
  --muted: #a4b2ad;
  --red: #ef7059;
  --blue: #4f83e8;
  --me: var(--red);
  --foe: var(--blue);
  --accent: #f0c977;
  --cream: #f0eee5;
}
body {
  background-color: var(--bg);
  background-image: linear-gradient(rgba(155, 174, 207, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(155, 174, 207, .025) 1px, transparent 1px),
    radial-gradient(ellipse at 18% 46%, rgba(196, 65, 58, .15), transparent 40%),
    radial-gradient(ellipse at 84% 54%, rgba(61, 111, 204, .17), transparent 42%);
  background-size: 36px 36px, 36px 36px, auto, auto;
}
.btn {
  color: var(--text); background: #1c2d30; border: 1px solid rgba(202,220,209,.18);
  border-radius: 5px; padding: 10px 15px; font-weight: 650; letter-spacing: .015em;
  transition: .18s ease;
}
.btn:hover { background: #263a3d; border-color: rgba(240,201,119,.65); transform: translateY(-1px); }
.btn.primary { color: #142022; background: var(--accent); border: 1px solid var(--accent); box-shadow: 0 5px 18px rgba(240,201,119,.13); }
.btn.primary:hover { background: #ffda8b; filter: none; }
.btn.small { padding: 7px 10px; }
#menu, #waiting, #hostScreen, #deckScreen { align-items: center; justify-content: center; padding: clamp(14px, 3vw, 42px); }
#menu { overflow-x: hidden; overflow-y: auto; }
#menu > .menu-shell { margin: auto; }
.menu-shell {
  position: relative; isolation: isolate; display: grid; grid-template-columns: minmax(300px, 1.08fr) minmax(410px, .92fr);
  width: min(1120px, 100%); min-height: min(690px, calc(100dvh - 48px)); overflow: hidden;
  padding: 0; border: 1px solid rgba(195,218,202,.2); border-radius: 10px;
  background: rgba(16, 29, 32, .94); box-shadow: 0 32px 100px rgba(0,0,0,.46), 0 1px 0 rgba(255,255,255,.04) inset;
}
.menu-shell::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(var(--red), var(--accent), var(--blue)); z-index: 2; }
.menu-hero { display: flex; flex-direction: column; justify-content: space-between; min-width: 0; padding: clamp(30px, 5vw, 60px) clamp(26px, 4.5vw, 56px) 28px; background: linear-gradient(145deg, rgba(35,67,67,.46), rgba(18,34,37,.35) 57%, rgba(17,28,30,.78)); border-right: 1px solid var(--line); }
.brand-lockup { position: relative; z-index: 1; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: #a9bab2; font-size: 10px; font-weight: 800; letter-spacing: .2em; }
.eyebrow i, .build-chip i, .console-foot i, .live-indicator::before, .bot-signal { width: 7px; height: 7px; border-radius: 50%; background: #84d1ae; box-shadow: 0 0 12px rgba(132,209,174,.6); }
h1 { margin: 20px 0 4px; font-size: clamp(48px, 6.1vw, 76px); line-height: .9; letter-spacing: -.07em; font-weight: 950; }
h1 .r { color: #f2eee3; }
h1 .b { display: block; margin: 8px 0 0 44px; color: var(--blue); }
.menu-hero > .brand-lockup .tag { color: #b1c1b8; margin: 20px 0 0 48px; font-size: 15px; letter-spacing: .04em; }
.arena-art { position: relative; width: min(100%, 520px); margin: 32px auto 22px; transform: rotate(-2deg); filter: drop-shadow(0 18px 26px rgba(0,0,0,.25)); }
.arena-art svg { display: block; width: 100%; overflow: visible; border-radius: 10px; }
.art-coordinate { position: absolute; z-index: 1; color: #c0ccc3; font: 700 8px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .15em; }
.coord-a { left: 7%; top: 7%; }.coord-b { right: 5%; bottom: 12%; }
.coord-b b { color: var(--accent); margin-left: 5px; }
.art-legend { position: absolute; left: 7%; bottom: 12%; display: flex; gap: 15px; color: #d5ded5; font: 700 8px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .1em; }
.art-legend span { display: flex; align-items: center; gap: 5px; }
.art-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; }
.legend-red { background: var(--red); }.legend-teal { background: var(--blue); }
.hero-foot, .console-foot { display: flex; justify-content: space-between; gap: 12px; color: #84968f; font: 750 9px ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .14em; }
.hero-foot b { color: var(--accent); font-size: 14px; margin-left: 6px; }
.menu-console { display: flex; flex-direction: column; min-width: 0; padding: clamp(24px, 3.3vw, 42px); background: linear-gradient(180deg, rgba(19,35,38,.5), rgba(12,22,25,.64)); }
.console-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.build-chip { display: flex; align-items: center; gap: 7px; padding: 6px 8px; color: #b4c4b8; border: 1px solid var(--line); border-radius: 3px; font-size: 8px; font-weight: 800; letter-spacing: .12em; }
.build-chip i { width: 5px; height: 5px; }
.field { color: #b4c1ba; font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.field input, .field select { background: #0d1a1d; border: 1px solid rgba(187,211,196,.2); border-radius: 4px; padding: 13px 14px; color: var(--text); }
.field input::placeholder { color: #61736e; }
.field input:focus, .field select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(76,200,178,.1); }
.deck-row { margin-top: 23px; padding: 15px; border: 1px solid var(--line); border-radius: 6px; background: rgba(28,45,48,.48); }
.deck-head { margin-bottom: 12px; }
.deck-head h2, .room-heading h2 { margin: 0; color: #dce2d7; font-size: 11px; letter-spacing: .12em; }
.section-count { margin-left: 7px; color: var(--accent); font: 700 9px ui-monospace, monospace; }
.deck-head .btn { color: var(--accent); background: transparent; border-color: rgba(240,201,119,.34); font-size: 10px; }
.deck-preview { gap: 5px; }
.chip { padding: 5px 2px; border-color: rgba(205,224,207,.12); border-radius: 4px; background: rgba(10,20,23,.55); }
.chip-name { color: #c8d1c7; font: 750 8px ui-monospace, SFMono-Regular, Consolas, monospace; }
.chip .cost { background: var(--accent); color: #162123; border: 1px solid #253b3b; }
.actions { margin-top: 18px; gap: 9px; }
.actions > #hostBtn { display: flex; justify-content: space-between; align-items: center; min-height: 50px; padding: 0 17px; font-size: 14px; text-transform: uppercase; letter-spacing: .1em; }
.actions > #hostBtn b { font-size: 20px; }
.bot { padding: 4px 0; }
.bot > span { display: grid; grid-template-columns: 9px auto; column-gap: 8px; color: #d7dfd6; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.bot > span small { grid-column: 2; color: #7e908a; font-size: 8px; letter-spacing: .16em; }
.bot-signal { grid-row: span 2; align-self: center; background: var(--accent); box-shadow: 0 0 10px rgba(240,201,119,.5); }
.bot .seg { gap: 3px; }
.bot .seg .btn { padding: 6px 9px; color: #aebbb2; border: 1px solid transparent; background: transparent; font-size: 10px; }
.bot .seg .btn:hover { color: var(--accent); border-color: rgba(240,201,119,.35); }
.room-section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.room-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; }
.live-indicator { display: inline-flex; align-items: center; gap: 6px; color: var(--blue); font: 800 8px ui-monospace, monospace; letter-spacing: .13em; }
.live-indicator::before { content: ""; width: 5px; height: 5px; }
#rooms { max-height: 115px; }
#rooms li { padding: 10px; border: 1px solid rgba(202,220,209,.08); border-radius: 4px; background: rgba(29,47,49,.5); font-size: 11px; }
#rooms li .btn { padding: 5px 11px; color: var(--accent); border-color: rgba(240,201,119,.3); font-size: 10px; }
#rooms li.empty { border: 1px dashed rgba(202,220,209,.13); color: #7d9088; font-size: 10px; }
.console-foot { margin-top: auto; padding-top: 17px; font-size: 8px; }
.console-foot i { display: inline-block; width: 5px; height: 5px; margin-left: 4px; }
#conn { top: 18px; right: 20px; left: auto; transform: none; z-index: 5; background: #1c2d30; border: 1px solid var(--line); border-radius: 4px; color: var(--accent); font: 800 9px ui-monospace, monospace; letter-spacing: .12em; }

/* Shared command-panel treatment for the host, lobby and deck screens. */
#hostScreen .menu-card, #waiting .menu-card, .deck-card {
  position: relative; width: min(720px, 100%); padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(195,218,202,.2); border-radius: 8px;
  background: linear-gradient(145deg, rgba(25,44,46,.98), rgba(14,26,29,.98));
  box-shadow: 0 28px 90px rgba(0,0,0,.42);
}
#hostScreen .menu-card::before, #waiting .menu-card::before, .deck-card::before {
  content: ""; position: absolute; left: 0; top: 28px; bottom: 28px; width: 3px; background: var(--accent);
}
#hostScreen h2, #waiting h2, .deck-card h2 { color: var(--text); font-size: 22px; letter-spacing: -.02em; text-transform: none; }
#hostScreen .tag, #waiting .tag, .deck-card .tag { color: #94a79f; }
#hostScreen .size-pick .btn { min-height: 100px; text-align: left; padding: 17px; border-radius: 5px; background: rgba(8,19,22,.55); }
#hostScreen .size-pick .btn b { color: var(--cream); font-size: 15px; letter-spacing: .04em; }
#hostScreen .size-pick .btn span { margin-top: 5px; font-size: 11px; }
#hostScreen .size-pick .btn:hover { border-color: var(--accent); background: rgba(240,201,119,.07); }
#waiting .seats { grid-template-columns: repeat(2, 1fr); }
#waiting .seat { min-height: 55px; border: 1px solid var(--line); border-radius: 4px; background: rgba(8,19,22,.42); }
#waiting .seat-choice { width: 100%; color: var(--muted); font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
#waiting .seat-choice:hover, #waiting .seat-choice:focus-visible { border-color: var(--blue); background: rgba(94,141,230,.12); outline: none; }
#waiting .lobby-actions { padding-top: 14px; border-top: 1px solid var(--line); }
#waiting #startBtn { text-transform: uppercase; letter-spacing: .1em; }
#ballot { gap: 12px; }
.mapcard { background: rgba(8,19,22,.55); border-color: var(--line); border-radius: 5px; }
.mapcard.mine { border-color: var(--accent); background: rgba(240,201,119,.08); }
.mapcard .votes { color: #152326; background: var(--accent); border-color: #152326; }
.deck-count { color: var(--blue); font: 800 16px ui-monospace, monospace; }
.dcard { border-radius: 5px; background: rgba(22,39,41,.8); }
.dcard.selected { border-color: var(--accent); background: rgba(240,201,119,.08); }
#deckSave { text-transform: uppercase; letter-spacing: .08em; }

/* Match HUD: glassy command strip, clean territory readouts, tactile card dock. */
#hud { padding: 11px 20px; background: rgba(14,25,28,.97); border-bottom-color: rgba(210,229,216,.15); box-shadow: 0 5px 25px rgba(0,0,0,.2); }
.side { padding: 4px 0; }
.side.me .pname, .side.me .pct { color: var(--me); }
.side.foe .pname, .side.foe .pct { color: var(--foe); }
.pct { font: 800 20px ui-monospace, SFMono-Regular, Consolas, monospace; }
.pname { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
#timer { color: var(--cream); font: 800 20px ui-monospace, SFMono-Regular, Consolas, monospace; }
.bar { height: 12px; border: 1px solid rgba(235,238,223,.2); background: var(--foe); }
#barMe { background: var(--me); }
#stage { background: radial-gradient(ellipse, rgba(60,86,130,.14), transparent 70%); }
#board { box-shadow: 0 0 0 2px #0b1618, 0 12px 48px rgba(0,0,0,.55); }
#tray { background: rgba(16,20,29,.98); border-top-color: rgba(198,211,233,.15); }
#energyBox .label { color: #a6b5ad; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
#energyBox .label b { color: #a2e6bd; font: 800 18px ui-monospace, monospace; }
#energyBar { border-color: rgba(130,207,160,.24); background: #10231e; }
#cards .card { background: linear-gradient(145deg, #252c37, #1a202a); border-color: rgba(198,211,233,.15); border-radius: 5px; }
#cards .card.selected { border-color: var(--accent); background: linear-gradient(145deg, #3c3b30, #27332f); }
#cards .card.instant { border-color: rgba(116,193,190,.48); }
#cards .card.instant .cstats { color: #7bd4c2; }
#help { color: #869992; font-size: 10px; }
kbd, .camera-key { color: #c4d0c7; background: #1c3032; border-color: rgba(200,220,208,.18); }
#overlay { background: rgba(6,14,16,.76); }
#overlay .panel { border: 1px solid rgba(240,201,119,.3); border-radius: 8px; background: #142326; }
#toast { color: var(--text); background: rgba(16,30,32,.98); border-color: rgba(200,220,208,.2); }

@media (max-width: 900px) {
  .menu-shell { grid-template-columns: minmax(250px, .86fr) minmax(380px, 1.14fr); }
  .menu-hero { padding: 34px 25px 22px; }
  .menu-console { padding: 25px 23px; }
  h1 { font-size: 54px; }
}
@media (max-width: 700px) {
  #menu, #waiting, #hostScreen, #deckScreen { align-items: flex-start; padding: 12px; }
  .menu-shell { display: block; width: 100%; min-height: 0; margin: auto 0; overflow: hidden; }
  .menu-hero { min-height: 265px; padding: 25px 22px 18px; border-right: 0; border-bottom: 1px solid var(--line); }
  h1 { margin-top: 14px; font-size: 47px; }
  .menu-hero > .brand-lockup .tag { margin: 14px 0 0 18px; font-size: 13px; }
  .arena-art { position: absolute; right: 6px; bottom: 36px; width: 46%; margin: 0; opacity: .75; transform: none; }
  .art-coordinate, .art-legend { display: none; }
  .hero-foot { position: relative; z-index: 1; font-size: 7px; }
  .menu-console { padding: 21px 17px 17px; }
  .console-top { margin-bottom: 18px; }
  .deck-row { padding: 11px 8px; }
  .chip-name { font-size: 7px; }
  .bot { align-items: flex-start; flex-direction: column; }
  .bot .seg { width: 100%; }
  .bot .seg .btn { flex: 1; }
  #waiting .menu-card, #hostScreen .menu-card, .deck-card { padding: 24px 18px; }
  #waiting .seats { grid-template-columns: 1fr; }
  #ballot { gap: 6px; }
  .mapcard { padding: 6px 3px; }
  .mapname { font-size: 10px; }
  .mapcard .votes { top: -6px; right: -5px; min-width: 23px; height: 23px; font-size: 12px; }
  .size-pick { grid-template-columns: 1fr; }
  #sizePick .btn { min-height: 0; display: flex; align-items: center; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* Compact, mobile-first main menu with a quiet, slow-moving battlefront. */
#menu { overflow-x: hidden; overflow-y: auto; padding: 16px; }
.battlefield-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0;
  background-image: linear-gradient(rgba(155,174,207,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(155,174,207,.035) 1px, transparent 1px);
  background-size: 38px 38px; }
.battlefield-bg::before { content: ""; position: absolute; inset: -15% -20%; opacity: .46;
  background: linear-gradient(105deg, transparent 5%, rgba(210,76,63,.2) 20%, rgba(210,76,63,.1) 39%, transparent 49%, rgba(63,123,229,.1) 60%, rgba(63,123,229,.2) 79%, transparent 95%);
  animation: front-advance 88s ease-in-out infinite alternate; }
.battlefield-bg::after { content: ""; position: absolute; top: 10%; bottom: 10%; left: 50%; width: 2px; opacity: .25; z-index: 0;
  background: linear-gradient(transparent, #e8bd77 32%, #e8bd77 68%, transparent); filter: blur(1px);
  animation: line-shift 88s ease-in-out infinite alternate; }
@keyframes front-advance { from { transform: translateX(-1.5vw); } to { transform: translateX(1.5vw); } }
@keyframes line-shift { from { transform: translateX(-5vw) skewX(-12deg); } to { transform: translateX(5vw) skewX(12deg); } }
#menuBattle { position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; }
.menu-shell { z-index: 1; display: block; width: min(420px, 100%); min-height: 0; margin: auto; overflow: hidden;
  border-radius: 9px; background: rgba(15,25,27,.94); box-shadow: 0 18px 60px rgba(0,0,0,.3); }
.menu-shell::before { opacity: .72; }
.menu-console { padding: 22px 24px 16px; background: transparent; }
.menu-brand { text-align: center; margin: 0 0 18px; }
.menu-brand h1 { margin: 0; color: var(--text); font-size: 32px; line-height: 1.1; letter-spacing: -.045em; font-weight: 800; }
.menu-brand .brand-border { color: var(--blue); }
.menu-brand .brand-line { color: var(--red); }
.menu-brand .tag { margin: 5px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .02em; }
.console-top { justify-content: center; margin-bottom: 11px; }
.console-top .eyebrow { color: #a9b6ae; font-size: 9px; letter-spacing: .16em; }
.console-top .eyebrow { text-decoration: underline; text-decoration-color: rgba(240,201,119,.65); text-decoration-thickness: 1px; text-underline-offset: 5px; }
.live-indicator::before { background: var(--blue); box-shadow: 0 0 7px rgba(79,131,232,.6); }
.btn.primary { color: var(--text); background: rgba(240,201,119,.1); border: 1px solid rgba(240,201,119,.42); box-shadow: none; }
.btn.primary:hover { background: rgba(240,201,119,.18); }
.bot .seg .btn { color: #c1cbc4; border-color: rgba(202,220,209,.14); background: rgba(28,45,48,.48); }
.bot .seg .btn:hover { color: var(--accent); border-color: rgba(240,201,119,.42); background: rgba(240,201,119,.07); }
.name-field { display: block; }
.field input { width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-size: 14px; letter-spacing: normal; text-transform: none; }
.deck-row { margin-top: 14px; padding: 12px; }
.deck-head { margin-bottom: 9px; }
.chip { min-width: 0; }
.chip .cost, .cost { background: #70cf83; color: #102516; border: 1px solid #4cae65; box-shadow: none; }
.actions { margin-top: 14px; }
.actions > #hostBtn { min-height: 46px; font-size: 13px; }
.bot { width: 100%; min-width: 0; gap: 7px; }
.bot > span { width: 100%; }
.bot .seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
.bot .seg .btn { min-width: 0; padding: 6px 3px; }
.room-section { margin-top: 14px; padding-top: 12px; }
.host-status { min-height: 1.4em; margin: 8px 0 10px; color: var(--muted); font-size: 12px; text-align: center; }
#sizePick .btn { cursor: pointer; touch-action: manipulation; }
#sizePick .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#sizePick .btn:disabled { cursor: wait; opacity: .65; }
#rooms { max-height: 92px; }
.console-foot { justify-content: flex-end; margin-top: 0; padding-top: 12px; color: #a5b2aa; font-size: 9px; letter-spacing: .1em; }
.ping-readout { font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  #menu { padding: 12px; }
  .menu-shell { width: min(420px, 100%); margin: auto; }
  .menu-console { padding: 20px 17px 14px; }
  .menu-brand { margin-bottom: 15px; }
  .deck-row { padding: 11px 9px; }
  .room-section { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .battlefield-bg::before, .battlefield-bg::after { animation: none; }
}

#overlay .panel { width: min(360px, calc(100vw - 32px)); padding: 24px 22px 20px; border-radius: 9px; }
#resultTitle { margin: 0 0 9px; font-size: 25px; letter-spacing: -.025em; }
#resultSub { margin: 0 0 18px; color: #a7b2c1; font-size: 13px; }
#menuBtn { width: 100%; }
.battlefield-bg::after { filter: none; }
.menu-shell { background: rgba(16,21,31,.94); }
.menu-shell::before { background: linear-gradient(var(--red), var(--blue)); }
.menu-shell { border-color: rgba(198,211,233,.18); box-shadow: 0 18px 60px rgba(0,0,0,.38); }
.deck-row { background: rgba(28,34,45,.62); border-color: rgba(198,211,233,.15); }
.chip { background: rgba(13,18,27,.58); border-color: rgba(198,211,233,.12); }
.chip-name { color: #d0d6e1; }
.bot .seg .btn { background: #242c37; border-color: rgba(198,211,233,.2); }
.bot .seg .btn:hover { background: #2c3745; }
.console-top .eyebrow { color: #c4ccd9; }
.battlefield-bg { background-color: transparent; }
#hud { background: rgba(16,20,29,.98); border-bottom-color: rgba(198,211,233,.15); }
#conn { background: #1b2029; border-color: rgba(198,211,233,.18); }
.btn:not(.primary) { background: #242c37; border-color: rgba(198,211,233,.18); }
.btn:not(.primary):hover { background: #2c3745; }
#endlessBtn { background: #a8322b; border-color: #a8322b; color: #fff; }
#endlessBtn:hover { background: #ff8973; border-color: #ff8973; }

#fullscreenBtn[hidden] { display: none; }
#fullscreenBtn { position: fixed; top: 10px; right: 10px; z-index: 1000; }

/* Endless: controls beside the keyboard hints, rankings over the map. */
#hud.endless .bar, #hud.endless .barscale { display: none; }
#hud.endless #timer { font-size: 14px; }
#endlessTools { display: grid; gap: 3px; background: transparent; color: #869992; font-size: 10px; }
#endlessTools.hidden, #leaderboard.hidden { display: none; }
.camera-controls, .zoom-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.camera-key { cursor: pointer; touch-action: none; }
.camera-key:hover { background: #284246; }
.camera-key:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.camera-key:disabled { opacity: .4; cursor: default; }
#gameScreen.vertical.endless { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto minmax(0, 1fr); }
#gameScreen.endless #stage { position: relative; grid-column: 1; grid-row: 2; min-width: 0; overflow: hidden; }
#gameScreen.vertical.endless #tray { grid-column: 2; grid-row: 2; min-height: 0; align-content: start; }
#leaderboard { position: absolute; top: 12px; left: 12px; z-index: 20; width: min(250px, 45%); background: transparent; border: none; pointer-events: none; text-shadow: 0 1px 3px #000, 0 0 6px #000; }
#leaderboard h3 { display: flex; align-items: center; gap: 4px; margin: 0 0 5px; font-size: 12px; color: #fff; }
#leaderboard .leader-toggle { pointer-events: auto; background: transparent; border: none; color: inherit; font: inherit; padding: 2px 4px; cursor: pointer; text-shadow: inherit; }
#leaderboard .leader-toggle:focus-visible { outline: 1px solid var(--accent); border-radius: 3px; }
#leaderboard.collapsed { width: auto; }
#leaderContent[hidden] { display: none; }
.leader-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
#leaderboard .leader-tabs .btn { pointer-events: auto; background: transparent; border: none; box-shadow: none; padding: 3px; font-size: 10px; text-shadow: inherit; }
#leaderboard .leader-tabs [aria-pressed="true"] { color: var(--accent); text-decoration: underline; }
#leaderRows { max-height: 32vh; overflow-y: auto; margin: 5px 0; padding: 0; list-style: none; counter-reset: rank; pointer-events: auto; font-size: 11px; }
#leaderRows li { display: flex; gap: 6px; padding: 3px 0; counter-increment: rank; background: transparent; }
#leaderRows li::before { content: counter(rank) '.'; color: #fff; }
#leaderRows span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#leaderRows b { color: #fff; }
#leaderRows .you { font-weight: 800; }
@media (max-width: 1100px) { #gameScreen.vertical.endless { grid-template-columns: minmax(0, 1fr) 240px; } }
body.mobile #gameScreen.vertical.endless { display: flex; }
body.mobile #endlessTools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
body.mobile #endlessTools.hidden { display: none; }
body.mobile .camera-key { min-width: 24px; min-height: 24px; }

/* Shortcut hints and camera/touch controls live behind a small gear. */
#controlSettings { position: fixed; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 46; }
#controlsGear { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); color: var(--muted); font: 21px/1 system-ui; cursor: pointer; }
#controlsGear:hover, #controlsGear[aria-expanded="true"] { color: var(--text); border-color: var(--accent); }
#controlsGear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#controlsGear[hidden] { display: none; }
#homeSettings { display: flex; margin-top: 12px; }
#controlsMenu { position: fixed; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(0,0,0,.55); z-index: 45; }
#controlsMenu[hidden] { display: none; }
.settings-window { width: min(380px, 100%); max-height: calc(100dvh - 40px); overflow-y: auto; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: #10141d; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.settings-header h2 { margin: 0; font-size: 20px; }
#closeSettings { border: none; background: transparent; color: var(--text); font: 24px/1 system-ui; cursor: pointer; padding: 2px 6px; }
.settings-tabs { display: flex; gap: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.settings-tabs button { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 10px; cursor: pointer; }
.settings-tabs [aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
#controlsPanel { display: grid; gap: 12px; }
#controlsPanel[hidden], #graphicsPanel[hidden] { display: none; }
.graphics-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.graphics-option input { accent-color: var(--accent); margin-top: 3px; }
.graphics-option small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.4; }
#controlsMenu #help { display: grid; }
body.mobile #controlSettings { align-self: flex-end; }
body.mobile #controlsMenu #touchBar { flex-wrap: wrap; }
body.mobile #controlsMenu #touchHint { flex-basis: 100%; }
body.fast-graphics #menuBattle { display: none; }
