/* EN//CORE — the look is taken from the game itself: the black/white split of
   Weiß and Schwarz, the gold-lined colour frames of the cards, the round
   level/cost badges, the black name pills. Dark is the main mode; light mode
   is the same language on paper. No other branding. */

:root {
  --bg: #121214;
  --bg-2: #1a1a1d;
  --panel: #202024;
  --panel-2: #2a2a2f;
  --line: #3a3a41;
  --line-2: #4b4b54;
  --ink: #f0ede6;
  --ink-2: #b9b6ae;
  --muted: #7d7b75;
  --gold: #c9a24a;
  --gold-2: #e5c76b;
  --red: #c8102e;
  --red-2: #e63950;
  --good: #59b26a;
  --weiss: #f4f1ea;
  --schwarz: #0b0b0c;
  --mat: #141416;
  --mat-2: #1c1c20;
  --mat-line: #3b3b43;
  --side-me: rgba(244, 241, 234, 0.045);
  --side-opp: rgba(0, 0, 0, 0.3);
  --zone-bg: rgba(0, 0, 0, 0.22);
  --slot-bg: rgba(255, 255, 255, 0.025);
  --c-yellow: #e3b52a;
  --c-green: #3f9d5a;
  --c-red: #c93a3a;
  --c-blue: #3b6fc4;
  --c-purple: #7d4fb5;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  --radius: 10px;
  --card-w: 92px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-cond: "Roboto Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --font-jp: "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #efece4;
  --bg-2: #e6e2d8;
  --panel: #faf8f2;
  --panel-2: #eeebe3;
  --line: #d3cfc4;
  --line-2: #bdb8ab;
  --ink: #17171a;
  --ink-2: #4a4944;
  --muted: #8a877e;
  --gold: #a8842c;
  --gold-2: #c9a24a;
  --mat: #e2ded4;
  --mat-2: #ebe7de;
  --mat-line: #b9b4a6;
  --side-me: rgba(255, 255, 255, 0.5);
  --side-opp: rgba(0, 0, 0, 0.06);
  --zone-bg: rgba(0, 0, 0, 0.06);
  --slot-bg: rgba(255, 255, 255, 0.35);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  color-scheme: light;
}

* { box-sizing: border-box; }
/* no scrollbars anywhere: wheel and touch still scroll every panel */
* { scrollbar-width: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-2); text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: var(--gold); color: #000; }
.jp { font-family: var(--font-jp); }

/* ------------------------------------------------------------- shell ---- */
#app { height: 100%; display: flex; flex-direction: column; }
/* the header is the Weiß/Schwarz split: one skewed black shape whose right
   edge carries the gold line, so the colour edge and the slash are the same line */
.topbar {
  height: 48px; flex: none; display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: var(--weiss); border-bottom: 2px solid var(--gold); position: relative; isolation: isolate; overflow: hidden;
}
.topbar::before { content: ""; position: absolute; top: -2px; bottom: -2px; left: -60px; width: calc(50% + 60px); background: var(--schwarz); border-right: 2px solid var(--gold); transform: skewX(-18deg); z-index: -1; }
.brand { font-family: var(--font-cond); font-weight: 700; font-size: 20px; letter-spacing: 0.06em; color: #fff; text-transform: uppercase; }
.brand small { color: var(--gold-2); }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #ddd; padding: 6px 12px; border-radius: 6px; font-weight: 600; letter-spacing: 0.02em; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; color: #111; }
.topbar .right .who { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #111; }
.topbar .right img { width: 26px; height: 26px; border-radius: 50%; }
.topbar .right .btn { background: #111; color: #fff; border-color: #111; }
.topbar .right .btn:hover { background: #333; }
main { flex: 1 1 auto; min-height: 0; overflow: auto; }
.page { max-width: 1240px; margin: 0 auto; padding: 22px 20px 40px; }
.page h1 { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: 0.05em; font-size: 22px; margin: 0 0 14px; color: var(--gold-2); }
.page h2 { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: 0.05em; font-size: 15px; margin: 22px 0 10px; color: var(--ink-2); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover:not(:disabled) { background: var(--line); border-color: var(--gold); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--gold); color: #1a1408; border-color: var(--gold-2); }
.btn.primary:hover:not(:disabled) { background: var(--gold-2); }
.btn.danger { border-color: var(--red); color: var(--red-2); }
.btn.danger:hover:not(:disabled) { background: rgba(200, 16, 46, 0.15); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.lg { padding: 12px 22px; font-size: 15px; }
.input, select.input, textarea.input {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--ink); outline: none; min-width: 0;
}
.input:focus { border-color: var(--gold); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 12px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--gold); color: #1a1408; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.item:hover { border-color: var(--line-2); }
.item .name { font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.tag.ok { color: var(--good); border-color: var(--good); }
.tag.bad { color: var(--red-2); border-color: var(--red); }
.tag.gold { color: var(--gold-2); border-color: var(--gold); }
.err { color: var(--red-2); font-size: 13px; min-height: 1em; }
.toast-host { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid var(--gold); border-radius: 8px; padding: 10px 16px; box-shadow: var(--shadow); font-weight: 600; animation: toast-in 0.2s ease-out; }
.toast.bad { border-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.modal-host { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px); }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 20px 22px; width: min(480px, 94vw); box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-2); }
.modal .fld { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.modal .fld label { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); object-fit: cover; }
.info { display: inline-flex; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font-size: 10px; align-items: center; justify-content: center; margin-left: 6px; position: relative; cursor: default; vertical-align: middle; }
.info .tip { display: none; position: absolute; left: 50%; top: 22px; transform: translateX(-50%); width: 260px; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--ink); z-index: 20; box-shadow: var(--shadow); text-transform: none; letter-spacing: 0; font-weight: 400; }
.info:hover .tip, .info:focus .tip { display: block; }

/* ---------------------------------------------------------- the card ---- */
/* a card face is drawn from data (frame in the card's colour, badges, pills);
   the artwork sits on top when it exists, so unlit cards still read as WS cards */
.card {
  position: relative; width: var(--card-w); aspect-ratio: 63 / 88; border-radius: 6% / 4.3%; overflow: hidden; direction: ltr;
  background: #222; color: #111; user-select: none; flex: none; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  transition: transform 0.18s ease, box-shadow 0.18s ease, outline-color 0.15s;
  outline: 2px solid transparent; outline-offset: 1px; font-size: calc(var(--card-w) * 0.1);
}
/* the real back of a Weiß Schwarz card */
.card.back { background: #101012 url("/assets/cardback.png") center / 100% 100% no-repeat; }
.card .face { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 4%; }
.card[data-color="yellow"] .face { background: linear-gradient(160deg, #f1cf5b, var(--c-yellow) 60%, #b8901c); }
.card[data-color="green"] .face { background: linear-gradient(160deg, #6fc182, var(--c-green) 60%, #2c6f40); }
.card[data-color="red"] .face { background: linear-gradient(160deg, #e26d6d, var(--c-red) 60%, #8f2626); }
.card[data-color="blue"] .face { background: linear-gradient(160deg, #6f9be0, var(--c-blue) 60%, #274b8a); }
.card[data-color="purple"] .face { background: linear-gradient(160deg, #a77fd6, var(--c-purple) 60%, #55337d); }
.card .face .art { flex: 1 1 auto; margin: 2% 2% 0; background: rgba(255, 255, 255, 0.35); border-radius: 4%; display: flex; align-items: flex-end; justify-content: center; }
.card .badges { position: absolute; left: 5%; top: 5%; display: flex; flex-direction: column; gap: 3%; }
.card .badge { width: 1.9em; height: 1.9em; border-radius: 50%; background: #f5f2ea; border: 0.18em solid #2a2a2a; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1em; line-height: 1; }
.card .trig { position: absolute; right: 5%; top: 5%; display: flex; gap: 3%; }
.card .trig span { width: 1.5em; height: 1.5em; border-radius: 30%; background: #1b1b1b; color: var(--gold-2); font-size: 0.75em; font-weight: 800; display: flex; align-items: center; justify-content: center; border: 1px solid var(--gold); }
.card .namebar { margin-top: 3%; background: #111; color: #fff; border-radius: 999px; padding: 4% 8%; font-family: var(--font-cond); font-weight: 700; font-size: 0.95em; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid var(--gold); }
.card .bottom { display: flex; align-items: center; justify-content: space-between; margin-top: 3%; gap: 4%; }
.card .power { background: #f5f2ea; border: 0.16em solid #2a2a2a; border-radius: 999px; padding: 1% 10%; font-weight: 800; font-size: 1.05em; min-width: 40%; text-align: center; }
.card .soul { display: flex; gap: 2px; }
.card .soul i { width: 1.1em; height: 1.1em; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff2b0, #d4a017 70%); border: 1px solid #5a4300; display: block; }
.card .traits { display: flex; gap: 2%; margin-top: 3%; }
.card .traits span { flex: 1; background: rgba(255, 255, 255, 0.7); border: 1px solid rgba(0, 0, 0, 0.5); border-radius: 2px; padding: 1% 3%; font-size: 0.65em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }
.card .type-ev, .card .type-cx { position: absolute; left: 5%; top: 5%; background: #111; color: #fff; font-size: 0.7em; font-weight: 800; padding: 2% 6%; border-radius: 3px; border: 1px solid var(--gold); }
.card img.art-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.card.climax { aspect-ratio: 88 / 63; }
.card.climax .face { flex-direction: row; align-items: flex-end; }
.card.climax .namebar { flex: 1; margin: 0 0 0 30%; }
/* a rested card turns sideways; on the stage it is scaled so it still fits its position */
.card.rest { transform: rotate(90deg); }
.slot .card.rest { transform: rotate(90deg) scale(0.82); }
.card.reverse { transform: rotate(180deg); filter: saturate(0.6) brightness(0.8); }
.card.selectable { outline-color: var(--gold-2); cursor: pointer; box-shadow: 0 0 0 3px rgba(229, 199, 107, 0.25), 0 0 18px rgba(229, 199, 107, 0.5); }
.card.selectable:hover { transform: translateY(-4px) scale(1.03); }
.card.selectable.rest:hover { transform: rotate(90deg) translateY(-4px) scale(1.03); }
.slot .card.selectable.rest:hover { transform: rotate(90deg) translateX(4px) scale(0.85); }
.card.selected { outline-color: var(--red-2); box-shadow: 0 0 0 3px rgba(230, 57, 80, 0.35), 0 0 18px rgba(230, 57, 80, 0.6); }
.card.dim { opacity: 0.45; }
.card.attacking { box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.6), 0 0 24px rgba(200, 16, 46, 0.7); }
.card.defending { box-shadow: 0 0 0 3px rgba(59, 111, 196, 0.6), 0 0 24px rgba(59, 111, 196, 0.7); }
.card.revealed { outline-color: #fff; }
.card .marker-count { position: absolute; right: 4%; bottom: 4%; background: #111; color: var(--gold-2); border: 1px solid var(--gold); border-radius: 4px; font-size: 0.8em; padding: 1px 5px; font-weight: 800; }
.card .cnt { position: absolute; inset: auto 0 0 0; text-align: center; background: rgba(0, 0, 0, 0.7); color: #fff; font-weight: 800; font-size: 1.1em; padding: 2px 0; }

/* ------------------------------------------------------------ board ---- */
/* Everything on the mat is a fixed multiple of one unit (--u = card width),
   set once from the window size. Zones reserve the room for their maximum
   content, so nothing moves while the game is played. */
.duel {
  height: 100%; display: grid; grid-template-columns: 1fr 320px; grid-template-rows: 100%; min-height: 0;
  --u: 100px; --card-w: var(--u); --ch: calc(var(--u) * 1.397); --g: calc(var(--u) * 0.1); --cap: 16px; --mid: 44px;
  --w-stock: calc(var(--u) * 1.05); --w-cx: calc(var(--u) * 1.45); --w-lvl: calc(var(--u) * 0.95); --w-clk: calc(var(--u) * 2.1);
  --w-slot: calc(var(--u) * 1.15); --w-mem: calc(var(--u) * 1.45); --w-deck: calc(var(--u) * 1.05);
  --w-l: calc(var(--w-lvl) + var(--g) + var(--w-clk)); --w-s: calc(var(--w-slot) * 3 + var(--g) * 2); --w-r: calc(var(--w-mem) + var(--g) + var(--w-deck));
  --row-h: calc(var(--ch) + var(--cap));
}
.duel .field { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 6px 0; overflow: hidden; background: radial-gradient(ellipse at 50% 50%, var(--mat-2) 0%, var(--mat) 75%); }
/* the two hands: fixed strips, cards overlap once they would not fit */
.strip { position: relative; flex: none; width: 100%; display: flex; justify-content: center; }
.strip .hrow { display: flex; align-items: flex-end; }
.strip.my-hand { height: calc(var(--ch) + 12px); align-items: flex-end; padding-bottom: 6px; }
.strip.opp-hand { height: calc(var(--ch) * 0.5 + 8px); align-items: flex-start; padding-top: 4px; }
.strip.opp-hand .hrow { align-items: flex-start; }
.strip .card { flex: none; }
.strip.my-hand .card:hover { transform: translateY(-14px) scale(1.06); z-index: 6; }
.strip.my-hand .card.selectable:hover { transform: translateY(-14px) scale(1.07); }
.strip .hcount { align-self: center; margin-left: 16px; font-size: 11px; color: var(--muted); letter-spacing: 0.04em; white-space: nowrap; width: 0; overflow: visible; }
.strip .hcount b { color: var(--ink-2); font-weight: 700; }
/* one half of the mat: 3 columns (left block, stage, right block) x 2 rows */
.side {
  flex: none; display: grid; grid-template-columns: var(--w-l) var(--w-s) var(--w-r); grid-template-rows: var(--row-h) var(--row-h);
  column-gap: var(--g); row-gap: var(--g); padding: 4px 8px; border-radius: 10px;
}
.side.me { background: var(--side-me); }
.side.opp { background: var(--side-opp); direction: rtl; }
.blk { display: flex; gap: var(--g); align-items: stretch; min-width: 0; }
.blk.left { grid-column: 1; justify-content: flex-end; }
.blk.stage { grid-column: 2; }
.blk.right { grid-column: 3; }
.side.me .blk.a { grid-row: 1; }
.side.me .blk.b { grid-row: 2; }
.side.opp .blk.a { grid-row: 2; }
.side.opp .blk.b { grid-row: 1; }
/* the back stage sits under the gaps of the front row, as on the mat */
.blk.back { padding-inline-start: calc(var(--u) * 0.625); }
.zone, .slot { position: relative; display: flex; flex-direction: column; flex: none; }
/* a zone is a faint area with the printed outline of a card where the card goes, like the mat itself */
.zone .zbody, .slot .zbody { position: relative; height: var(--ch); display: flex; align-items: center; justify-content: center; border-radius: 7px; background: var(--zone-bg); }
.zbody::before { content: ""; position: absolute; top: 50%; left: 50%; width: var(--gw, var(--u)); height: var(--gh, var(--ch)); transform: translate(-50%, -50%); border: 1.5px dashed var(--mat-line); border-radius: 6% / 4.3%; pointer-events: none; }
.zbody.start { justify-content: flex-start; }
.zbody.start::before { left: auto; inset-inline-start: 0; transform: translateY(-50%); }
.zbody.top { align-items: flex-start; }
.zbody.top::before { top: 0; transform: none; }
.z-climax .zbody { --gw: var(--ch); --gh: var(--u); }
.z-clock .zbody, .z-memory .zbody, .z-level .zbody { --gw: calc(var(--u) * 0.6); --gh: calc(var(--ch) * 0.6); }
.z-resolution .zbody { --gw: calc(var(--u) * 0.7); --gh: calc(var(--ch) * 0.7); }
.zcap { height: var(--cap); display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 3px; font-size: 9.5px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); direction: ltr; white-space: nowrap; overflow: hidden; }
.zcap .zn { color: var(--gold-2); font-size: 11px; letter-spacing: 0; }
.zcap .pw { font-size: 12px; letter-spacing: 0; color: var(--ink); }
.zcap .pw.up { color: #8fe39d; }
.zcap .pw.down { color: #ff9a9a; }
.zcap .soul { display: inline-flex; gap: 2px; }
.zcap .soul i { width: 7px; height: 7px; border-radius: 50%; background: radial-gradient(circle at 40% 35%, #fff2b0, #d4a017 70%); border: 1px solid #5a4300; display: block; }
.zcap .lv { color: var(--ink-2); letter-spacing: 0; font-size: 10px; }
.z-stock { width: var(--w-stock); }
.z-climax { width: var(--w-cx); }
.z-level { width: var(--w-lvl); }
.z-clock { width: var(--w-clk); }
.z-memory, .z-resolution { width: var(--w-mem); }
.z-deck, .z-waitingRoom { width: var(--w-deck); }
.slot { width: var(--w-slot); }
.slot .zbody { justify-content: flex-start; background: var(--slot-bg); }
.slot .zbody::before { left: auto; inset-inline-start: 0; transform: translateY(-50%); border-style: solid; border-color: var(--mat-line); }
.slot.center .zbody::before { border-color: var(--line-2); }
.slot .zbody > .card { position: relative; z-index: 1; }
/* markers peek out from under the character */
.slot .markers { position: absolute; inset-inline-start: calc(var(--u) * 0.15); top: 0; width: var(--u); height: var(--ch); cursor: pointer; }
.slot .markers .card { position: absolute; left: 0; top: 0; }
.slot .markers .card:nth-child(2) { left: 3px; top: 3px; }
.slot .markers .card:nth-child(3) { left: 6px; top: 6px; }
.zone.clickable .zbody { cursor: pointer; }
.zone.clickable:hover .zbody { border-color: var(--gold); }
.zone.can-drop .zbody, .slot.can-drop .zbody { box-shadow: inset 0 0 0 1px var(--gold-2), inset 0 0 22px rgba(229, 199, 107, 0.3); cursor: pointer; }
.zone.can-drop .zbody::before, .slot.can-drop .zbody::before { border-color: var(--gold-2); border-style: solid; }
.slot.swap-from .zbody { box-shadow: inset 0 0 0 1px var(--red-2), inset 0 0 22px rgba(230, 57, 80, 0.35); }
.slot.swap-from .zbody::before { border-color: var(--red-2); }
.fan { display: flex; align-items: center; }
.fan.v { flex-direction: column; }
.fan .card:hover { z-index: 3; transform: translateY(-6px) scale(1.25); }
.fan.v .card:hover { transform: scale(1.25); }
.fan .card.rest:hover { transform: rotate(90deg) scale(1.25); }
/* piles show their thickness */
.pile { position: relative; }
.pile[data-n="1"] .card { box-shadow: 1px 1px 0 #2a2a2e, 2px 2px 0 #1c1c1f, 0 3px 8px rgba(0, 0, 0, 0.5); }
.pile[data-n="2"] .card { box-shadow: 1px 1px 0 #2a2a2e, 2px 2px 0 #1c1c1f, 3px 3px 0 #2a2a2e, 4px 4px 0 #1c1c1f, 0 5px 10px rgba(0, 0, 0, 0.55); }
.pile[data-n="3"] .card { box-shadow: 1px 1px 0 #2a2a2e, 2px 2px 0 #1c1c1f, 3px 3px 0 #2a2a2e, 4px 4px 0 #1c1c1f, 5px 5px 0 #2a2a2e, 6px 6px 0 #1c1c1f, 0 7px 12px rgba(0, 0, 0, 0.6); }

/* the strip between the halves: whose turn, the phase track, the prompt */
.midbar { height: var(--mid); flex: none; width: 100%; display: flex; align-items: center; gap: 14px; padding: 0 14px; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; z-index: 5; }
.midbar.mine { background: linear-gradient(90deg, rgba(201, 162, 74, 0.18), var(--panel) 55%); box-shadow: inset 4px 0 0 var(--gold); }
.turn { display: flex; align-items: center; gap: 8px; white-space: nowrap; flex: none; }
.turn .tn { font-family: var(--font-cond); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 13px; color: var(--gold-2); }
.turn .tp { font-weight: 700; font-size: 12px; padding: 2px 9px; border-radius: 4px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.turn .tp.w { background: var(--weiss); color: #111; border: 1px solid #c9c4b7; }
.turn .tp.s { background: #000; color: #fff; border: 1px solid #555; }
.phasebar { display: flex; flex: none; }
.phasebar span {
  font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; white-space: nowrap; line-height: 1;
  padding: 7px 14px 7px 18px; margin-left: -9px; color: var(--muted); background: var(--panel-2);
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%);
}
.phasebar span:first-child { margin-left: 0; padding-left: 12px; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%); border-radius: 4px 0 0 4px; }
.phasebar span:last-child { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 9px 50%); border-radius: 0 4px 4px 0; padding-right: 12px; }
.phasebar span.done { color: var(--ink-2); background: var(--line); }
.phasebar span.on { color: #1a1408; background: var(--gold); }
.phasebar.opp span.on { color: var(--bg); background: var(--ink); }
.prompt { flex: 1 1 auto; display: flex; align-items: center; gap: 10px; min-width: 0; }
.prompt .text { font-weight: 700; font-size: 13px; line-height: 1.2; max-height: 2.4em; overflow: hidden; }
.prompt .text.wait { color: var(--muted); font-weight: 600; }
.prompt .actions { display: flex; gap: 6px; flex: none; }
.prompt .count { font-size: 12px; color: var(--gold-2); font-weight: 700; white-space: nowrap; }

/* right column: preview + log + chat; the preview's boxes are fixed so the log never moves */
.duel .aside { border-left: 1px solid var(--line); background: var(--panel); display: grid; grid-template-rows: auto 1fr auto auto; min-height: 0; min-width: 0; overflow: hidden; }
.preview { padding: 12px 12px 8px; border-bottom: 1px solid var(--line); }
.preview .pcard { height: 350px; display: flex; align-items: center; justify-content: center; }
.preview .card { --card-w: 250px; font-size: 25px; }
.preview .card.climax { --card-w: 250px; }
.preview .pname { font-family: var(--font-cond); font-weight: 700; font-size: 15px; margin-top: 8px; height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview .pmeta { font-size: 11px; color: var(--muted); height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview .ptext { margin-top: 6px; height: 150px; overflow: auto; font-size: 12.5px; color: var(--ink-2); line-height: 1.45; }
.preview .ptext b { color: var(--ink); }
.preview .ptext .ab { margin: 0 0 6px; }
.preview .ptext .kw { color: var(--gold-2); font-weight: 700; }
.preview .ptext .gained { color: var(--gold-2); margin-bottom: 6px; }
.log { overflow: auto; padding: 8px 12px; font-size: 12.5px; min-height: 0; }
.log .e { padding: 2px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); color: var(--ink-2); }
.log .e.turn { color: var(--gold-2); font-weight: 800; margin-top: 6px; }
.log .e.me { color: var(--ink); }
.log .e b { color: var(--ink); font-weight: 600; }
.log .e.dmg { color: var(--red-2); }
.log .e.chat { color: var(--gold-2); }
.chatbox { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chatbox .input { flex: 1; }
.duel-controls { display: flex; gap: 6px; padding: 8px 12px; border-top: 1px solid var(--line); }
.replay-bar { padding: 6px 12px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }

/* card browser overlay (choices from piles, deck search, ordering) */
.browser { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; }
.browser .box { background: var(--panel); border: 1px solid var(--gold); border-radius: 12px; padding: 16px 18px; max-width: 1100px; width: 100%; max-height: 90vh; display: flex; flex-direction: column; gap: 12px; }
.browser h3 { margin: 0; font-family: var(--font-cond); text-transform: uppercase; letter-spacing: 0.05em; color: var(--gold-2); }
.browser .grid { display: flex; flex-wrap: wrap; gap: 10px; overflow: auto; padding: 4px; justify-content: center; }
.browser .grid .card { --card-w: 130px; font-size: 13px; }
.browser .grid .card .ord { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 16px; border: 2px solid #fff; }
.browser .foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

/* floating card menu (abilities / attack type) */
.cmenu { position: fixed; z-index: 85; background: var(--panel); border: 1px solid var(--gold); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); min-width: 180px; max-width: 320px; }
.cmenu button { text-align: left; white-space: normal; }
.cmenu .title { font-size: 11px; color: var(--muted); padding: 2px 6px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 800; }

/* effects */
@keyframes flash { 0% { box-shadow: 0 0 0 0 rgba(229, 199, 107, 0.9); } 100% { box-shadow: 0 0 0 16px rgba(229, 199, 107, 0); } }
.card.flash { animation: flash 0.6s ease-out; }
@keyframes shake { 0%, 100% { translate: 0 0; } 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.card.hit { animation: shake 0.3s ease-in-out; }

/* --------------------------------------------------------- deck builder ---- */
.builder { height: 100%; display: grid; grid-template-columns: 1fr 380px; min-height: 0; }
.builder .browse { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.builder .filters { display: flex; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; background: var(--panel); }
.builder .filters .input { width: 220px; }
.builder .filters select.input { width: auto; }
.builder .results { overflow: auto; padding: 12px 14px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; align-content: start; }
.builder .results .card { --card-w: 100%; width: 100%; font-size: 14px; }
.builder .results .cardbox { display: flex; flex-direction: column; gap: 4px; }
.builder .results .cardbox .cb-actions { display: flex; gap: 4px; align-items: center; justify-content: center; }
.builder .results .cardbox .cb-actions .n { font-weight: 800; min-width: 20px; text-align: center; }
.builder .decklist { display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.builder .decklist .head { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.builder .decklist .entries { overflow: auto; padding: 8px 14px; font-size: 13px; }
.builder .decklist .grp { margin: 8px 0 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.builder .decklist .ent { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.04); cursor: default; }
.builder .decklist .ent:hover { color: var(--gold-2); }
.builder .decklist .ent .n { font-weight: 800; width: 22px; }
.builder .decklist .ent .lc { font-size: 11px; color: var(--muted); width: 34px; }
.builder .decklist .ent .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.builder .decklist .ent .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.builder .decklist .stats { display: flex; gap: 10px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.builder .decklist .stats b { color: var(--ink); }
.builder .decklist .check { font-size: 12px; }
.builder .decklist .check .e { color: var(--red-2); }
.builder .decklist .check .w { color: var(--gold-2); }
.dot.yellow { background: var(--c-yellow); } .dot.green { background: var(--c-green); } .dot.red { background: var(--c-red); } .dot.blue { background: var(--c-blue); } .dot.purple { background: var(--c-purple); }
.curve { display: flex; gap: 4px; align-items: flex-end; height: 40px; }
.curve div { flex: 1; background: var(--gold); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.curve div span { position: absolute; top: -14px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--ink-2); }

/* ------------------------------------------------------------- lobby ---- */
.table-view { max-width: 980px; margin: 0 auto; padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.seats { display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: stretch; }
.seat { padding: 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 10px; min-height: 180px; }
.seat.w { border-color: var(--weiss); box-shadow: inset 4px 0 0 var(--weiss); }
.seat.s { border-color: #000; box-shadow: inset 4px 0 0 #000; }
.seat .pname { font-family: var(--font-cond); font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 10px; }
.seat .empty { color: var(--muted); font-style: italic; }
.seat .fld { display: flex; flex-direction: column; gap: 4px; }
.seat .fld label { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.vs { display: flex; align-items: center; justify-content: center; font-family: var(--font-cond); font-weight: 700; font-size: 26px; color: var(--gold-2); }
.result { text-align: center; padding: 24px; }
.result h2 { font-family: var(--font-cond); font-size: 32px; margin: 0 0 6px; color: var(--gold-2); text-transform: uppercase; }
