/* Playtest page (templates/decks/playtest.html, static/playtest/playtest.js). A full-screen page of its own, so these
   styles don't share the site stylesheet; colours follow the site's (static/css/site.css). */
:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel2: #1d222c;
  --line: #2a303c;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #ff9a3d;
  --sun-1: #ffb347;
  --sun-2: #ff6a3d;
  --danger: #ff6b6b;
  --shield: #4aa3ff;
  --exp: #f5c542;
  --cw: 125px;
  --hw: 155px;  /* hand cards, a size up from the table's so they read easily */
  --lcw: calc(var(--cw) * 1.25);  /* leaders and the base print bigger; playtest.js fitLeaders fits them */
  --vigilance: #3c8ad8;
  --command: #3fa45b;
  --aggression: #d64545;
  --cunning: #e2b93b;
  --heroism: #e9e4d4;
  --villainy: #3a3a40;
  /* The standard card back, as Karabast uses it. */
  --card-back: url("https://karabast-data.s3.amazonaws.com/game/swu-cardback.webp");
}
* { box-sizing: border-box; }
.sizing * { transition: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.35 Inter, "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}
/* Buttons and chips as on the site (.btn, .pill-toggle in static/css/site.css), a size smaller. */
button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 11px;
  font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #3d4554; }
button.primary { background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); color: #1a0f05; border-color: transparent; }
button.primary:hover { filter: brightness(1.08); }
a.back-link.primary { display: inline-block; padding: 6px 12px; border-radius: 8px; background: linear-gradient(135deg, var(--sun-1), var(--sun-2)); color: #1a0f05; font-weight: 700; }
a.back-link.primary:hover { filter: brightness(1.08); }
button.mini { padding: 0 6px; font-size: 12px; line-height: 18px; }
a { color: var(--accent); text-decoration: none; }
button:focus-visible, .pill-toggle:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-toggle {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.pill-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.pill-toggle::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.pill-toggle:has(input:checked) { color: var(--text); border-color: var(--accent); background: var(--panel2); }
.pill-toggle:has(input:checked)::before { background: var(--accent); }
.pill-toggle:hover { border-color: #3d4554; }
.pill-toggle:has(input:checked):hover { border-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); }

/* ---------- top bar ---------- */
/* Three parts: deck on the left, the round in the middle, options on the right. */
#topbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 12px;
  padding: 6px 10px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.tb-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tb-side.right { justify-content: flex-end; }
.brand { display: flex; align-items: center; gap: 3px; font-size: 15px; margin-right: 6px; font-weight: 800; letter-spacing: .02em; color: var(--text); white-space: nowrap; }
/* The site's logo (matches static/css/site.css .logo-mark / .brand-text). */
.logo-mark { height: 22px; width: auto; flex: none; display: block; }
.brand-text { display: inline-flex; align-items: baseline; gap: .55em; color: #f2eee3; white-space: nowrap; }
.brand-name { font-family: "Unbounded", sans-serif; font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .01em; }
.brand-hub { font-weight: 400; font-size: 11px; text-transform: uppercase; letter-spacing: .32em; color: #cfcabd; }
/* Narrow windows: just the sun mark, so the back button and deck name keep their room. */
@media (max-width: 1100px) { .brand-text { display: none; } }
.back-link { display: inline-flex; align-items: center; flex: none; white-space: nowrap; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); color: var(--text); }
.back-link:hover { border-color: var(--accent); }
#deck-title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.spacer { flex: 1; }
/* Card size picker, as on the site (.card-size, .view-toggle in static/css/site.css). */
.card-size { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-toggle a { min-width: 30px; padding: 5px 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.view-toggle a:hover { color: var(--text); }
.view-toggle a.on { background: var(--panel2); color: var(--text); }
.view-toggle svg { display: block; }
.round {
  display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; font-size: 12px;
}
.round b { color: var(--accent); font-size: 22px; letter-spacing: 0; }
.dropdown { position: relative; }
.dropdown .menu { display: none; position: absolute; top: 100%; left: 0; z-index: 50; }
.dropdown.open .menu { display: block; }

/* ---------- board layout ---------- */
/* On ultrawide screens the table stops at a comfortable width, centred, rather than spreading the arenas apart. */
#board {
  flex: 1; min-height: 0; width: 100%; max-width: 2600px; margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 1fr auto auto;
  grid-template-areas: "center" "res" "hand";
  gap: 6px; padding: 6px;
}
#center {
  grid-area: center; min-height: 0;
  display: grid; grid-template-columns: 1fr calc(var(--lcw) * 2.8 + 34px) 1fr; gap: 6px;
}
#mid { overflow-y: auto; overflow-x: hidden; background: var(--panel2); border-radius: 8px; padding: 4px; }
#resources-row { grid-area: res; }
#hand-row { grid-area: hand; }
.hand-bar { display: flex; align-items: center; gap: 10px; }
.hand-bar .actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dropdown.up .menu { top: auto; bottom: 100%; margin-bottom: 4px; }
section { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.zone-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; margin: 2px 2px 4px; }
.zone-hint { text-transform: none; letter-spacing: 0; font-weight: 400; opacity: .6; margin-left: 6px; }
.pill { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 0 7px; color: var(--text); text-transform: none; letter-spacing: 0; margin-left: 4px; }
.zone {
  display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start;
  min-height: 40px; border-radius: 6px; padding: 4px;
  transition: background .1s;
}
.zone.drop-hover, .pile.drop-hover { background: rgba(255, 154, 61, .12); outline: 1px dashed var(--accent); }
.arena { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-radius: 8px; padding: 4px; }
.arena.space { background: linear-gradient(180deg, rgba(60, 80, 140, .18), transparent); }
.arena.ground { background: linear-gradient(180deg, rgba(120, 90, 50, .16), transparent); }
/* arenas are free-placement: cards are positioned absolutely where they were dropped */
.arena-zone { flex: 1; display: block; position: relative; overflow: auto; }
.slot.free { position: absolute; }
/* Twin Suns pyramid: base on top, the two leaders side by side underneath */
#zone-leaders { display: grid; grid-auto-flow: column; justify-content: center; align-items: center; gap: 8px; }
#zone-leaders .slot { justify-self: center; }
#zone-base { justify-content: center; }
/* The hand and, at its right, the deck, discard and set-aside piles. */
.hand-main { display: flex; gap: 10px; align-items: stretch; }
#zone-hand { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; min-height: calc(var(--hw) * 1.4 + 22px); padding-top: 12px; }
/* A big hand overlaps (playtest.js layoutHand); the card under the pointer comes to the front. */
#zone-hand .slot:hover { z-index: 5; }
#zone-hand .slot:hover .card { transform: translate(-50%, calc(-50% - 8px)); }
#zone-hand .slot { --w: var(--hw); --h: calc(var(--hw) * 1.4); }
#zone-resources { gap: 6px; align-items: center; min-height: calc(var(--cw) * 0.7 + 10px); }

/* Base HP, the Force and initiative under the base; credits in the resources bar. */
/* "Base" at the left, the Force and initiative centred over the base. */
.base-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px; margin-bottom: 2px; }
.base-head .toggles { display: flex; gap: 6px; }
.pill-toggle.sm { padding: 1px 9px; font-size: 12px; }
.base-wrap { position: relative; margin-bottom: 14px; }
/* Straddles the base card's bottom edge, so the card stays readable. */
.base-hp {
  position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 999px;
  background: rgba(10, 12, 16, .88); border: 1px solid var(--line); box-shadow: 0 4px 14px rgba(0, 0, 0, .6);
}
.base-hp b { min-width: 34px; text-align: center; font-size: 18px; font-weight: 800; color: var(--accent); }
.base-hp button { padding: 1px 7px; font-size: 12px; border-radius: 999px; }
/* Resources: the label and credits in a column at the left, the resources beside them (saves a row of height). */
#resources-row { display: flex; align-items: flex-start; gap: 10px; }
#zone-resources { flex: 1; min-width: 0; }
.res-bar { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; flex: none; padding-top: 2px; }
.res-bar .zone-label { margin: 0; }
.credits { display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.credits button { padding: 1px 8px; font-size: 12px; border-radius: 999px; }
.credits .tracker-value { display: flex; align-items: baseline; gap: 5px; min-width: 0; padding: 0 2px; }
.credits .tracker-value span { font-size: 16px; }
.tracker { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.tracker-value { min-width: 58px; text-align: center; }
.tracker-value span { display: block; font-size: 22px; font-weight: 800; line-height: 1.1; }
.tracker-value small { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; }
.basehp .tracker-value span { color: var(--accent); }
.stepper { display: flex; flex: 1; justify-content: flex-end; }
.stepper button { border-radius: 0; margin-left: -1px; padding: 4px 9px; font-size: 12px; min-width: 38px; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper button:hover { position: relative; z-index: 1; }
.tracker-toggles { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---------- cards ---------- */
.slot {
  --w: var(--cw); --h: calc(var(--cw) * 1.4);
  touch-action: none;
  position: relative; width: var(--w); height: var(--h); flex: 0 0 auto;
  cursor: grab; transition: width .12s, height .12s;
}
.slot.land { --w: calc(var(--cw) * 1.4); --h: var(--cw); }
#zone-leaders .slot.land, #zone-base .slot.land { --w: calc(var(--lcw) * 1.4); --h: var(--lcw); }
.slot.exhausted { width: var(--h); height: var(--w); }
.slot.has-attach { margin-bottom: var(--attach-h, 0px); }
.slot.dragging, .chip.dragging { opacity: .35; }
.ghost { position: fixed; z-index: 150; pointer-events: none; opacity: .9; margin: 0; }
.ghost .card { box-shadow: 0 10px 28px rgba(0, 0, 0, .7); }
.deploy-btn {
  display: none; position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 2;
  padding: 2px 10px; font-size: 12px; font-weight: 600; border-radius: 10px;
  background: rgba(14, 17, 22, .85); border-color: var(--accent); color: var(--accent);
}
.deploy-btn:hover { background: var(--accent); color: #1a1300; }
.slot.in-leaders .deploy-btn { display: block; }
.card {
  position: absolute; left: 50%; top: 50%;
  width: var(--w); height: var(--h);
  transform: translate(-50%, -50%);
  border-radius: calc(var(--cw) * 0.06);
  background: #222a35; overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .55);
  transition: transform .15s;
}
.slot.exhausted .card { transform: translate(-50%, -50%) rotate(90deg); filter: brightness(.72); }
.slot:hover .card { box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0, 0, 0, .6); }
.card img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
/* Cards as on the site (static/css/site.css): a faint edge, and the same foil. The foil fades out over the black border
   on Standard printings; other printings have none, so it covers them whole (.foil-full). */
.card::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
.slot.foil .card::before, .attach-card.foil::before {
  --foil-x: transparent 2.5%, #000 8%, #000 92%, transparent 97.5%;
  --foil-y: transparent 1.8%, #000 5.8%, #000 94.2%, transparent 98.2%;
  content: ""; position: absolute; inset: 0; pointer-events: none; mix-blend-mode: hard-light; opacity: .23;
  background: linear-gradient(135deg, #ff5f6d, #ffb347 8%, #fff176 16%, #6fe39a 25%, #5cc8ff 33%, #8f7bff 41%, #ff6fd8 46%, #ff5f6d 50%, #ffb347 58%, #fff176 66%, #6fe39a 75%, #5cc8ff 83%, #8f7bff 91%, #ff6fd8);
  -webkit-mask: linear-gradient(90deg, var(--foil-x)), linear-gradient(180deg, var(--foil-y));
  -webkit-mask-composite: source-in; mask-composite: intersect;
}
.slot.foil.land .card::before {
  --foil-x: transparent 1.8%, #000 5.8%, #000 94.2%, transparent 98.2%;
  --foil-y: transparent 2.5%, #000 8%, #000 92%, transparent 97.5%;
}
.slot.foil-full .card::before, .attach-card.foil::before { -webkit-mask: none; mask: none; }
body.no-images .slot.foil .card::before, .slot.noimg.foil .card::before { display: none; }
.card .txt { display: none; }
body.no-images .card img, .slot.noimg .card img { display: none; }
body.no-images .card .txt, .slot.noimg .card .txt { display: flex; }
.slot.token .card { outline: 2px dashed rgba(255, 255, 255, .35); outline-offset: -3px; }

/* text-mode card face */
.txt {
  position: absolute; inset: 0; flex-direction: column;
  padding: 5px 5px 4px 9px;
  font-size: calc(var(--cw) * 0.074); line-height: 1.22;
  background: linear-gradient(160deg, #26303d, #1a2029);
}
.txt .aspects { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; display: flex; flex-direction: column; }
.txt .aspects i { flex: 1; }
.t-head { display: flex; gap: 4px; align-items: flex-start; }
.t-cost { background: #0b0d10; border: 1px solid #556; color: #fff; border-radius: 50%; min-width: 1.7em; height: 1.7em; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.t-name { font-weight: 700; font-size: 1.08em; }
.t-name .uniq { color: var(--accent); }
.t-sub { color: var(--muted); font-style: italic; }
.t-type { color: var(--muted); font-size: .88em; border-bottom: 1px solid var(--line); padding-bottom: 2px; margin-bottom: 2px; }
.t-body { flex: 1; overflow: hidden; }
.t-stats { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.25em; }
.t-pow { color: #ff7a6e; }
.t-hp { color: #79c0ff; }
.ico { display: inline-block; background: #0b0d10; border: 1px solid #556; border-radius: 3px; padding: 0 2px; font-size: .9em; font-weight: 700; }
.kw { font-weight: 700; color: #fff; }

/* counters on cards */
.badges { position: absolute; inset: 0; pointer-events: none; }
.badge {
  position: absolute; min-width: calc(var(--cw) * 0.2); height: calc(var(--cw) * 0.2);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: calc(var(--cw) * 0.12); color: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .8); padding: 0 3px;
}
.badge.dmg { background: var(--danger); right: 4px; top: 30%; }
.badge.shield { background: var(--shield); left: 4px; top: 30%; border-radius: 40% 40% 50% 50%; }
.badge.exp { background: var(--exp); color: #2a1f00; left: 4px; top: 50%; border-radius: 4px; }
.badge.adv { background: #e07b2a; color: #2a1200; left: 4px; top: 70%; border-radius: 4px; }
.badge.weak { background: #7a4fa0; right: 4px; top: 50%; border-radius: 4px; }
.badge.pen { background: #6b2b2b; right: 3px; top: 3px; border-radius: 4px; font-size: calc(var(--cw) * 0.09); height: auto; }
.attachments {
  position: absolute; left: 0; right: 0; top: 100%; margin-top: 3px;
  display: flex; flex-direction: column; gap: 3px;
}
.chip {
  background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 4px; padding: 1px 5px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: grab;
}
.chip:hover { border-color: var(--accent); }
/* An attached upgrade tucked under its unit: the bottom of the card (text, stat bonus, title strip) shows. */
.attach-card {
  position: relative;
  width: var(--cw); height: calc(var(--cw) * 1.4 * 0.45); align-self: center; border-radius: 0 0 calc(var(--cw) * 0.06) calc(var(--cw) * 0.06);
  overflow: hidden; cursor: grab; box-shadow: 0 2px 6px rgba(0, 0, 0, .55); background: #222a35;
}
.attach-card img { width: 100%; height: 100%; object-fit: cover; object-position: bottom; display: block; pointer-events: none; }
.attach-card:hover { box-shadow: 0 0 0 2px var(--accent), 0 4px 12px rgba(0, 0, 0, .6); }

/* resources are face-down: a card back, turned sideways when exhausted; hover shows the card */
.slot.res { --w: calc(var(--cw) * 0.5); --h: calc(var(--cw) * 0.7); }
.slot.res .card { border-radius: 5px; }
.slot.res.exhausted .card { filter: brightness(.55); }
.slot.res .card .txt { display: none !important; }
.slot.res .res-name {
  position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .75);
  font-size: 12px; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.res-name { display: none; }
.slot.res:hover .res-name { display: block; }
body.no-images .slot.res .card, .slot.res.noimg .card { background: linear-gradient(135deg, #2b3a52, #1b2433); }
body.no-images .slot.res .res-name { top: 0; align-items: center; background: none; white-space: normal; line-height: 1.1; }
body.no-images .slot.res:hover .res-name { display: flex; }
.card-back { display: none; }
.slot.res .card-back {
  display: block; position: absolute; inset: 0; z-index: 1; transition: opacity .12s;
  border-radius: inherit; border: 3px solid #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12);
  background:
    var(--card-back) center / cover no-repeat,
    radial-gradient(circle at 50% 50%, transparent 0 17%, rgba(240, 180, 41, .85) 17% 20%, transparent 20% 27%, rgba(240, 180, 41, .35) 27% 28.5%, transparent 28.5%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 255, 255, .05) 0 6deg, transparent 6deg 12deg),
    radial-gradient(ellipse at 50% 45%, #2a3f6b 0%, #142039 55%, #0a1020 100%);
}
.slot.res:hover .card-back { opacity: 0; }

/* ---------- piles ---------- */
#piles { display: flex; align-items: flex-end; gap: 6px; padding-left: 10px; border-left: 1px solid var(--line); }
.pile { text-align: center; cursor: pointer; border-radius: 8px; padding: 4px; }
.pile-card {
  width: calc(var(--cw) * 0.9); height: calc(var(--cw) * 1.26); border-radius: 8px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: #2a313c center/cover no-repeat; border: 1px solid var(--line);
  box-shadow: 2px 2px 0 #0a0c10, 4px 4px 0 #1a1f27;
}
.pile-card span { background: rgba(0, 0, 0, .75); border-radius: 10px; padding: 2px 10px; font-weight: 800; font-size: 18px; }
/* Set aside is used less: a smaller pile. */
#pile-aside .pile-card { width: calc(var(--cw) * 0.5); height: calc(var(--cw) * 0.7); }
#pile-aside .pile-card span { font-size: 14px; padding: 1px 7px; }
.pile-card.back { background: var(--card-back) center / cover no-repeat, repeating-linear-gradient(45deg, #1c2a44, #1c2a44 6px, #22345a 6px, #22345a 12px); border-color: #3c5a8a; align-items: flex-end; padding-bottom: 6px; }
.pile-card.aside { background: #2a2334; }
.pile-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-top: 6px; }
.pile:hover .pile-card { border-color: var(--accent); }

/* ---------- preview & log ---------- */
#preview { flex: 1; min-height: 0; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.preview-empty { color: var(--muted); text-align: center; margin-top: 40px; }
#preview img { width: 100%; border-radius: 10px; display: block; margin-bottom: 8px; }
#preview .p-name { font-size: 17px; font-weight: 700; }
#preview .p-sub { color: var(--muted); font-style: italic; margin-bottom: 4px; }
#preview .p-meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
#preview .p-stats { display: flex; gap: 12px; font-weight: 700; margin: 4px 0 8px; }
#preview .p-text { background: var(--panel2); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; }
#preview .p-text h4 { margin: 0 0 3px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.aspect-tag { display: inline-block; padding: 0 6px; border-radius: 8px; font-size: 12px; margin-right: 3px; color: #fff; }

/* ---------- menus, modal, toast ---------- */
.menu {
  position: fixed; z-index: 100; min-width: 190px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .6); padding: 4px;
}
.menu.hidden, .hidden { display: none !important; }
.menu .mi { padding: 5px 10px; border-radius: 5px; cursor: pointer; white-space: nowrap; display: flex; justify-content: space-between; gap: 16px; }
.menu .mi:hover { background: rgba(255, 154, 61, .18); }
.menu .mi kbd { color: var(--muted); font: 12px monospace; }
.menu .msep { height: 1px; background: var(--line); margin: 4px 2px; }
.menu .mrow { display: flex; align-items: center; gap: 4px; padding: 4px 10px; color: var(--muted); }
.menu .mrow span { flex: 1; }
.menu .mrow button { padding: 1px 8px; font-size: 12px; }

#modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); z-index: 90; display: flex; align-items: center; justify-content: center; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(1200px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
#modal-body { padding: 12px 14px; overflow-y: auto; user-select: text; }
#modal-body textarea { width: 100%; height: 340px; background: #0b0e13; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font: 12.5px/1.4 Consolas, monospace; resize: vertical; }
#modal-body input[type=text], #modal-body input[type=number], #modal-body select {
  background: #0b0e13; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font: inherit;
}
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.warn { color: #ffb86b; }
.err { color: var(--danger); }
.grid-cards { display: flex; flex-wrap: wrap; gap: 14px; }
.grid-card { display: flex; flex-direction: column; align-items: center; gap: 4px; width: calc(var(--cw) * 1.4 + 4px); }
.grid-card .slot { cursor: default; }
.grid-card .acts { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; }
.grid-card .acts button { padding: 1px 6px; font-size: 12px; }
.help-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 18px; }
.help-grid kbd { background: var(--panel2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font: 12px monospace; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--panel2); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 16px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .6);
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2c3542; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
