:root {
  color-scheme: dark;
  --ink: #edf1e8;
  --muted: #9ba69c;
  --paper: #151b18;
  --paper-2: #1c2420;
  --paper-3: #242e29;
  --line: #344139;
  --gold: #d8a94a;
  --gold-soft: #f0d28d;
  --green: #64b486;
  --red: #df786f;
  --shadow: 0 18px 48px rgb(0 0 0 / 28%);
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% -10%, rgb(63 102 77 / 34%), transparent 32rem),
    radial-gradient(circle at 90% 10%, rgb(111 82 39 / 18%), transparent 30rem),
    #0d1210;
}

button, input, select { font: inherit; }

button {
  border: 0;
  cursor: pointer;
}

button:disabled { cursor: not-allowed; opacity: .45; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: 1px solid rgb(255 255 255 / 8%);
  background: rgb(13 18 16 / 88%);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
  letter-spacing: .08em;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50% 50% 46% 54%;
  color: var(--gold-soft);
  font-family: Georgia, serif;
  font-size: 24px;
  transform: rotate(-5deg);
}

.brand b, .brand small { display: block; }
.brand b { font-family: Georgia, serif; font-size: 17px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: .2em; }

.room-tools { display: flex; align-items: center; gap: 8px; }
.room-code { color: var(--gold-soft); font-family: ui-monospace, monospace; letter-spacing: .16em; }

main {
  width: min(1440px, calc(100% - 32px));
  min-height: calc(100vh - 132px);
  margin: 0 auto;
  padding: 28px 0 48px;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 18px clamp(18px, 4vw, 64px);
  border-top: 1px solid rgb(255 255 255 / 6%);
  color: #657168;
  font-size: 10px;
  letter-spacing: .16em;
}
footer a { color: #89958b; text-decoration: none; }
footer a:hover { color: var(--gold-soft); }

h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Yu Mincho", serif; font-weight: 500; }
h1 { margin-bottom: 12px; font-size: clamp(34px, 6vw, 64px); line-height: 1; }
h2 { margin-bottom: 8px; font-size: clamp(25px, 3vw, 36px); }
h3 { margin-bottom: 12px; font-size: 14px; letter-spacing: .06em; }
p { color: var(--muted); line-height: 1.75; }

.eyebrow {
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: clamp(24px, 7vw, 90px);
  align-items: center;
  min-height: 68vh;
}

.hero-copy { max-width: 680px; }
.hero-copy .lead { max-width: 580px; font-size: 16px; }
.rule-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.rule-strip span, .tag {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #b9c3ba;
  font-size: 11px;
}

.entry-card, .panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(145deg, rgb(31 40 35 / 96%), rgb(20 27 24 / 96%));
  box-shadow: var(--shadow);
}

.entry-card { padding: clamp(22px, 4vw, 36px); }
.entry-card form + form { margin-top: 26px; padding-top: 26px; border-top: 1px solid var(--line); }
.entry-card h2 { font-family: inherit; font-size: 16px; font-weight: 700; }

label { display: block; margin-bottom: 7px; color: #bac3bb; font-size: 12px; }
.field { margin-bottom: 13px; }
input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid #3c4941;
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #101613;
}
input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgb(216 169 74 / 12%); }
input.code-input { text-transform: uppercase; letter-spacing: .18em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #111612;
  background: var(--gold);
  font-weight: 700;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-secondary { border-color: #48564d; color: var(--ink); background: #27322c; }
.btn-ghost { border-color: #3a463f; color: #b9c3ba; background: transparent; }
.btn-danger { color: #ffd3cf; border-color: #70423f; background: #3b2422; }
.btn-small { min-height: 30px; padding: 5px 9px; font-size: 11px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

.phase-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #111713;
}
.phase-step { position: relative; padding: 10px 14px; color: #707d73; font-size: 11px; text-align: center; letter-spacing: .08em; }
.phase-step + .phase-step { border-left: 1px solid var(--line); }
.phase-step.active { color: #171b18; background: var(--gold); font-weight: 800; }
.phase-step.done { color: var(--green); }

.notice {
  position: sticky;
  z-index: 9;
  top: 82px;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 16px;
  padding: 10px 14px;
  border: 1px solid #67502a;
  border-radius: 8px;
  color: #f6dfaa;
  background: #2e2618;
  box-shadow: var(--shadow);
}
.notice.error { border-color: #6e3d3a; color: #ffd2cf; background: #321f1e; }

.page-heading { display: flex; justify-content: space-between; gap: 18px; align-items: end; margin-bottom: 24px; }
.page-heading p { margin-bottom: 0; }
.status-block { min-width: 170px; text-align: right; }
.big-number { color: var(--gold-soft); font-family: Georgia, serif; font-size: 28px; }

.lobby-layout, .build-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
}
.panel { padding: 22px; }
.panel-flat { border: 1px solid var(--line); border-radius: 13px; background: rgb(18 24 21 / 82%); }

.seat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.seat {
  display: flex;
  align-items: center;
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #121915;
}
.seat.empty { color: #657068; border-style: dashed; }
.seat-number { display: grid; width: 34px; height: 34px; margin-right: 12px; place-items: center; border-radius: 50%; color: var(--gold-soft); background: #2c3028; }
.seat strong, .seat small { display: block; }
.seat small { margin-top: 4px; color: var(--muted); }
.host-badge { margin-left: auto; color: var(--gold); font-size: 10px; }

.rules-list { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.9; }
.divider { height: 1px; margin: 20px 0; background: var(--line); }

.draft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; }
.card-grid.compact { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); }

.game-card {
  --card-border: #566258;
  --card-surface: #252e29;
  --card-art-border: #465149;
  --card-art-a: #1c2420;
  --card-art-b: #202a24;
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  aspect-ratio: 5 / 7;
  flex-direction: column;
  padding: 8px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  color: var(--ink);
  background:
    linear-gradient(135deg, transparent 0 48%, rgb(255 255 255 / 3%) 48% 52%, transparent 52%),
    var(--card-surface);
  box-shadow: 0 8px 18px rgb(0 0 0 / 22%);
  text-align: left;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.game-card.card-color-white {
  --card-border: #c9bd86;
  --card-surface: #403e32;
  --card-art-border: #a99f75;
  --card-art-a: #36352e;
  --card-art-b: #454337;
}
.game-card.card-color-blue {
  --card-border: #4d8fbd;
  --card-surface: #1d3341;
  --card-art-border: #3e769b;
  --card-art-a: #172b38;
  --card-art-b: #203b4c;
}
.game-card.card-color-black {
  --card-border: #71627d;
  --card-surface: #29242e;
  --card-art-border: #5d5266;
  --card-art-a: #201c24;
  --card-art-b: #302936;
}
.game-card.card-color-red {
  --card-border: #b85d4a;
  --card-surface: #422722;
  --card-art-border: #914b3d;
  --card-art-a: #351f1b;
  --card-art-b: #4a2b24;
}
.game-card.card-color-green {
  --card-border: #4f9365;
  --card-surface: #20372a;
  --card-art-border: #417a54;
  --card-art-a: #192d22;
  --card-art-b: #25402f;
}
.game-card.card-color-multicolor {
  --card-border: #b99a4b;
  --card-surface: #3b3421;
  --card-art-border: #937b3f;
  --card-art-a: #302a1b;
  --card-art-b: #443b25;
}
.game-card.has-card-image { padding: 0; }
.game-card.has-card-image .card-name,
.game-card.has-card-image .card-type { display: none; }
.game-card.has-card-image .card-art { position: absolute; z-index: 0; inset: 0; margin: 0; border: 0; }
button.game-card:hover { z-index: 2; border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 12px 24px rgb(0 0 0 / 34%); }
.game-card.tapped { transform: rotate(8deg) scale(.92); transform-origin: center; }
.card-name { min-height: 29px; padding: 5px 6px; border-radius: 5px; color: #eff3ea; background: rgb(9 13 11 / 72%); font-size: 11px; font-weight: 800; overflow-wrap: anywhere; }
.card-art { display: grid; min-height: 0; flex: 2 1 0; margin: 6px 0; overflow: hidden; place-items: center; border: 1px solid var(--card-art-border); color: #8b978e; background: repeating-linear-gradient(-45deg, var(--card-art-a), var(--card-art-a) 8px, var(--card-art-b) 8px, var(--card-art-b) 16px); font-family: Georgia, serif; font-size: 22px; }
.card-art-image { width: 100%; height: 100%; min-height: 0; grid-area: 1 / 1; object-fit: cover; }
.opponent-facing .card-art-image { transform: rotate(180deg); }
.card-art-fallback { display: grid; grid-area: 1 / 1; place-items: center; }
.card-art-image + .card-art-fallback { display: none; }
.card-art.image-missing .card-art-image { display: none; }
.card-art.image-missing .card-art-fallback { display: grid; }
.card-type { min-height: 22px; padding: 5px; border-top: 1px solid #4d584f; color: #aeb8b0; font-size: 9px; }
.card-rules-tooltip { position: absolute; z-index: 5; top: 33.333%; right: 6px; bottom: 6px; left: 6px; padding: 8px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid rgb(216 169 74 / 65%); border-radius: 6px; color: #f3f0e8; background: rgb(8 11 9 / 94%); box-shadow: 0 6px 18px #000b; font-size: 9px; line-height: 1.5; opacity: 0; pointer-events: none; scrollbar-color: #a98743 #171b18; scrollbar-width: thin; transform: translateY(5px); transition: opacity .15s, transform .15s; }
.game-card:hover .card-rules-tooltip,
.game-card:focus-visible .card-rules-tooltip,
.game-card:focus-within .card-rules-tooltip { opacity: 1; pointer-events: auto; transform: translateY(0); }
.card-rules-tooltip::-webkit-scrollbar { width: 7px; }
.card-rules-tooltip::-webkit-scrollbar-track { background: #171b18; }
.card-rules-tooltip::-webkit-scrollbar-thumb { border-radius: 999px; background: #a98743; }
.card-limit { position: absolute; z-index: 2; right: 7px; bottom: 7px; padding: 3px 6px; border: 1px solid rgb(216 169 74 / 70%); border-radius: 999px; color: #fff2c9; background: rgb(20 17 11 / 90%); font-size: 9px; font-weight: 800; box-shadow: 0 2px 6px rgb(0 0 0 / 35%); }
.card-counter-badges { position: absolute; top: 42px; right: 7px; display: grid; gap: 3px; justify-items: end; }
.card-counter-badges span { padding: 3px 5px; border: 1px solid #c49b4c; border-radius: 999px; color: #fff2c9; background: rgb(34 28 16 / 92%); font-size: 8px; font-weight: 800; box-shadow: 0 2px 6px rgb(0 0 0 / 32%); }

.waiting {
  display: grid;
  min-height: 320px;
  place-items: center;
  border: 1px dashed #455248;
  border-radius: 14px;
  color: var(--muted);
  text-align: center;
}
.waiting-orb { width: 42px; height: 42px; margin: 0 auto 16px; border: 3px solid #344139; border-top-color: var(--gold); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pick-stack { max-height: 70vh; overflow: auto; }
.pick-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }

.build-list { display: grid; gap: 8px; }
.build-row { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid #344138; border-radius: 9px; background: #141b17; }
.build-row:hover, .build-row:focus-within { z-index: 10; }
.build-name { min-width: 0; outline: none; }
.build-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.build-name small { color: var(--muted); }
.build-card-tooltip { position: absolute; z-index: 12; top: calc(100% + 5px); left: 10px; display: block; width: min(420px, calc(100% - 20px)); padding: 10px 12px; visibility: hidden; border: 1px solid rgb(216 169 74 / 65%); border-radius: 7px; color: #f3f1e8; background: rgb(8 11 9 / 97%); box-shadow: 0 8px 24px rgb(0 0 0 / 60%); font-size: 11px; line-height: 1.6; opacity: 0; pointer-events: none; transform: translateY(-3px); transition: opacity .12s, transform .12s, visibility .12s; white-space: pre-wrap; }
.build-name:hover .build-card-tooltip, .build-name:focus .build-card-tooltip { visibility: visible; opacity: 1; transform: translateY(0); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { display: grid; width: 29px; height: 29px; place-items: center; border: 1px solid #48554c; border-radius: 6px; color: var(--ink); background: #252f29; }
.stepper output { min-width: 22px; color: var(--gold-soft); text-align: center; font-weight: 800; }
.deck-summary { position: sticky; top: 100px; }
.deck-meter { height: 9px; margin: 12px 0 20px; overflow: hidden; border-radius: 999px; background: #0c110e; }
.deck-meter span { display: block; height: 100%; background: var(--gold); transition: width .2s; }
.deck-meter span.over { background: var(--red); }
.summary-number { display: flex; align-items: baseline; gap: 5px; }
.summary-number strong { color: var(--gold-soft); font-family: Georgia, serif; font-size: 50px; font-weight: 400; }
.summary-number span { color: var(--muted); }
.build-section + .build-section { margin-top: 24px; }

.battle-shell { display: grid; gap: 10px; }
.turn-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 15px; border: 1px solid var(--line); border-radius: 9px; background: #161e1a; }
.turn-banner.mine { border-color: #826a38; box-shadow: inset 3px 0 var(--gold); }
.player-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 10px; }
.player-bar strong { margin-right: auto; font-size: 15px; }
.stat { padding: 5px 9px; border: 1px solid #465248; border-radius: 999px; color: #c5cec6; font-size: 11px; }
.life { color: #ffd1cd; border-color: #6a403c; }
.battle-side { padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: rgb(18 25 21 / 88%); }
.battle-side.opponent { background: rgb(25 22 20 / 82%); }
.zone { min-height: 158px; padding: 8px; border: 1px dashed #3c483f; border-radius: 10px; background: rgb(7 10 8 / 28%); }
.zone-title { display: flex; min-height: 30px; margin-bottom: 8px; align-items: center; justify-content: space-between; gap: 8px; color: #89958b; font-size: 10px; letter-spacing: .12em; }
.zone-title-action { padding: 5px 8px; border: 1px solid #6b5730; border-radius: 5px; color: #e5cd94; background: #2d2718; font-size: 9px; font-weight: 700; letter-spacing: 0; }
.zone-title-action:hover:not(:disabled) { border-color: var(--gold); color: #fff1bd; }
.zone-cards { display: flex; min-height: 112px; gap: 7px; overflow-x: auto; overflow-y: hidden; padding: 4px 4px 10px; }
.zone-card { position: relative; flex: 0 0 112px; }
.zone-card .game-card { aspect-ratio: 5 / 7; }
.zone-card .game-card.revealed-to-opponent { border-color: var(--gold); box-shadow: 0 0 0 2px rgb(216 169 74 / 20%), 0 8px 18px rgb(0 0 0 / 22%); }
.revealed-card-badge { position: absolute; z-index: 3; right: 5px; bottom: 5px; padding: 3px 5px; border: 1px solid #d8a94a; border-radius: 999px; color: #fff1bd; background: rgb(31 25 13 / 92%); font-size: 8px; font-weight: 800; pointer-events: none; }
.zone-revealed-hand { min-height: 150px; margin-bottom: 10px; border-color: #75633c; background: rgb(49 39 19 / 24%); }
.zone-battlefield .zone-cards { display: grid; min-height: 315px; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 7px; overflow: hidden; padding-bottom: 4px; }
.battlefield-row { display: flex; min-width: 0; min-height: 0; gap: 7px; overflow-x: auto; overflow-y: hidden; align-items: start; }
.battlefield-row .zone-card { flex: 0 0 112px; }
.zone-card[data-card-menu="true"] .game-card { cursor: context-menu; }
.zone-card[data-card-menu="true"] { -webkit-touch-callout: none; user-select: none; }
.zone-hand .zone-card[data-card-menu="true"] .game-card,
.zone-battlefield .zone-card[data-card-menu="true"] .game-card { cursor: pointer; }
.card-context-menu { position: fixed; z-index: 60; display: grid; width: 190px; gap: 4px; padding: 8px; border: 1px solid #75633c; border-radius: 9px; color: #e8ece7; background: #151d18; box-shadow: 0 14px 40px #000d; }
.card-context-menu strong { padding: 5px 6px 7px; overflow: hidden; color: var(--gold-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.card-context-menu > button { padding: 7px 8px; border: 1px solid #3d4a41; border-radius: 5px; color: #c7d0c8; background: #202923; text-align: left; font-size: 10px; }
.card-context-menu > button:hover { border-color: var(--gold); color: #fff1bd; }
.card-context-menu > button:disabled { color: #95896c; border-color: #51482f; background: #28251c; }
.card-menu-counter { display: grid; grid-template-columns: 1fr 30px 30px; align-items: center; overflow: hidden; border: 1px solid #67552e; border-radius: 5px; color: #e8d49e; background: #2b261a; font-size: 9px; }
.card-menu-counter span { padding-left: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-menu-counter button { height: 28px; border-left: 1px solid #67552e; color: #f2dfa9; background: #37301f; }
.battle-zone-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 24%); gap: 10px; align-items: stretch; }
.battle-zone-layout .side-zones { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 0; align-content: start; }
.battle-utility { min-width: 0; }
.battle-utility .life-controls { display: grid; width: 100%; margin: 0 0 8px; grid-template-columns: repeat(3, 1fr); }
.battle-utility .life-controls button { min-width: 0; }
.battle-utility .life-controls b { grid-column: 3; grid-row: 1; display: grid; place-items: center; }
.side-zones { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.mini-zone { min-height: 64px; padding: 9px; border: 1px solid #344138; border-radius: 8px; }
.mini-zone summary { color: #98a399; cursor: pointer; font-size: 11px; }
.mini-zone-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.mini-zone-actions button { padding: 5px 7px; border: 1px solid #48554c; border-radius: 5px; color: #b8c3ba; background: #202923; font-size: 8px; }
.mini-zone-actions button:hover:not(:disabled) { border-color: var(--gold); color: var(--gold-soft); }
.mini-zone .zone-cards { min-height: 0; margin-top: 8px; }
.battle-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.life-controls { display: inline-flex; align-items: center; gap: 4px; margin: -1px 0 10px; padding: 5px; border: 1px solid #5b3b38; border-radius: 9px; background: #241918; }
.life-controls button { min-width: 34px; height: 29px; border-radius: 5px; color: #ffd2ce; background: #452a28; font-size: 11px; }
.life-controls b { min-width: 48px; color: #ffd4cf; font-family: Georgia, serif; font-size: 22px; text-align: center; }
.player-counters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 10px; }
.counter-pill { display: inline-flex; align-items: center; min-height: 30px; overflow: hidden; border: 1px solid #64532f; border-radius: 999px; color: #ead6a2; background: #292418; font-size: 10px; }
.counter-pill b { padding: 0 9px; }
.counter-pill button { align-self: stretch; width: 27px; border-left: 1px solid #64532f; color: #efdaa5; background: #37301f; }
.roll-result { margin-left: auto; padding: 5px 9px; border: 1px solid #6b5730; border-radius: 6px; color: #d9c18c; font-size: 11px; }
.roll-result b { color: #fff0bb; font-size: 17px; }
.battle-history { box-shadow: none; }
.game-finish { display: flex; align-items: center; justify-content: space-between; gap: 20px; box-shadow: none; }
.game-finish h3 { margin-bottom: 5px; }
.game-finish p { margin-bottom: 0; font-size: 12px; }
.battle-log { display: grid; max-height: 230px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.battle-log li { display: grid; grid-template-columns: 48px 1fr; gap: 9px; padding: 7px 4px; border-top: 1px solid #2e3932; color: #b5bfb6; font-size: 11px; }
.battle-log li:first-child { border-top: 0; }
.battle-log time { color: #68756b; font-family: ui-monospace, monospace; }

.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; padding: clamp(10px, 3vw, 40px); place-items: center; background: rgb(2 5 3 / 80%); backdrop-filter: blur(8px); }
.search-modal { display: flex; width: min(1180px, 100%); max-height: 92vh; padding: clamp(16px, 3vw, 26px); overflow: hidden; border: 1px solid #5b674f; border-radius: 16px; flex-direction: column; background: #151d18; box-shadow: 0 30px 90px #000; }
.modal-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.modal-heading h2 { margin-bottom: 14px; }
.search-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; min-height: 180px; margin-top: 14px; padding: 4px 8px 20px 4px; overflow-y: auto; }
.search-card[hidden] { display: none; }
.search-card .card-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; margin-top: 5px; }
.search-card .card-actions button { padding: 4px 3px; border: 1px solid #3d4a41; border-radius: 4px; color: #b8c3ba; background: #202923; font-size: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }

.match-score { display: grid; grid-template-columns: minmax(90px, 1fr) auto minmax(90px, 1fr); gap: 12px; align-items: center; min-width: 300px; padding: 11px 16px; border: 1px solid #5d5136; border-radius: 12px; background: #211e16; }
.match-score div { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-width: 0; }
.match-score div:nth-of-type(2) { justify-content: flex-start; }
.match-score span { overflow: hidden; color: #c5cbbf; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.match-score b { color: #f3d58d; font-family: Georgia, serif; font-size: 30px; }
.match-score em { color: #777263; font-style: normal; }
.match-score small { grid-column: 1 / -1; color: #918871; font-size: 9px; text-align: center; }
.result-screen { display: flex; width: min(850px, 100%); min-height: 65vh; margin: 0 auto; padding: clamp(30px, 7vw, 72px) 0; align-items: center; flex-direction: column; text-align: center; }
.result-screen > p { max-width: 610px; }
.result-screen .match-score { width: min(520px, 100%); margin: 18px 0 28px; }
.ready-cards { display: grid; width: min(600px, 100%); grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 24px; }
.ready-card { display: flex; min-height: 90px; padding: 16px; border: 1px solid #424e46; border-radius: 11px; align-items: center; justify-content: space-between; color: #929e95; background: #141a17; }
.ready-card.ready { border-color: #3d7555; color: #c8efd6; background: #17271e; }
.ready-card b { font-size: 11px; letter-spacing: .1em; }
.waiting-inline { display: inline-flex; align-items: center; gap: 9px; padding: 10px 14px; color: #b4bdb5; font-size: 12px; }
.waiting-inline span { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 5px rgb(216 169 74 / 12%); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; transform: scale(.75); } }
.result-note { margin-top: 18px; font-size: 11px; }
.table-status-list { display: grid; width: min(680px, 100%); gap: 8px; margin: 4px 0 22px; }
.table-status { display: grid; grid-template-columns: 75px 1fr 100px; gap: 10px; align-items: center; padding: 12px 14px; border: 1px solid #3d4941; border-radius: 9px; color: #a7b0a8; background: #151c18; text-align: left; }
.table-status.complete { border-color: #41664e; }
.table-status span, .table-status small { color: #79857b; font-size: 9px; letter-spacing: .08em; }
.table-status small { text-align: right; }
.table-status strong { font-size: 12px; }
.result-actions { min-height: 60px; margin-bottom: 12px; }
.standings-panel { width: min(680px, 100%); margin-top: 12px; box-shadow: none; text-align: left; }
.standing-row { display: grid; grid-template-columns: 1fr repeat(4, 46px); gap: 5px; align-items: center; min-height: 39px; border-top: 1px solid #303b34; color: #c0c8c1; font-size: 11px; text-align: center; }
.standing-row.heading { min-height: 28px; border-top: 0; color: #6f7b72; font-size: 9px; }
.standing-row span:first-child { display: flex; align-items: center; gap: 9px; text-align: left; }
.standing-row span:first-child b { display: grid; width: 21px; height: 21px; place-items: center; border-radius: 50%; color: #d8c083; background: #2e2a1d; font-size: 9px; }
.sideboard-page { width: 100%; padding: 18px 0 40px; }
.sideboard-page > .table-status-list { margin-right: auto; margin-left: auto; }
.sideboard-page > .result-actions { text-align: center; }
.result-header { display: flex; max-width: 760px; margin: 0 auto 22px; align-items: center; flex-direction: column; text-align: center; }
.result-header > p { max-width: 620px; }
.result-header .match-score { width: min(520px, 100%); margin-top: 10px; }
.compact-ready { width: min(600px, 100%); margin-right: auto; margin-left: auto; }
.sideboard-editor { margin-top: 32px; padding-top: 28px; border-top: 1px solid var(--line); }
.sideboard-heading { margin-bottom: 18px; }
.sideboard-heading p { margin-bottom: 0; }
.sideboard-ready { display: flex; max-width: 820px; margin: 28px auto; align-items: center; justify-content: space-between; gap: 22px; text-align: left; }
.sideboard-ready h2 { margin-bottom: 4px; font-size: 25px; }
.sideboard-ready p { margin-bottom: 0; }
.wide-standings { max-width: 820px; margin-right: auto; margin-left: auto; }

.empty-copy { padding: 24px; color: #77837a; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .hero, .lobby-layout, .build-layout, .draft-layout { grid-template-columns: 1fr; }
  .battle-zone-layout { grid-template-columns: 1fr; }
  .battle-zone-layout .side-zones { grid-template-columns: repeat(2, 1fr); }
  .zone-battlefield .zone-cards { min-height: 315px; }
  .battle-utility .life-controls { width: min(360px, 100%); }
  .hero { padding-top: 24px; }
  .deck-summary { position: static; grid-row: 1; }
  .pick-stack { max-height: none; }
}

@media (max-width: 600px) {
  main { width: min(100% - 20px, 1440px); padding-top: 18px; }
  .site-header { min-height: 62px; padding: 10px 12px; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .room-tools .btn { padding: 6px 8px; font-size: 10px; }
  .room-code { font-size: 11px; }
  .page-heading { display: block; }
  .status-block { margin-top: 12px; text-align: left; }
  .seat-grid { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-limit { right: 5px; bottom: 5px; padding: 4px 7px; font-size: 10px; }
  .phase-step { padding: 8px 3px; font-size: 9px; }
  .panel { padding: 15px; }
  .game-finish { align-items: stretch; flex-direction: column; }
  .sideboard-ready { align-items: stretch; flex-direction: column; }
  .match-score { width: 100%; min-width: 0; margin-top: 14px; }
  .ready-cards { grid-template-columns: 1fr; }
  .table-status { grid-template-columns: 55px 1fr; }
  .table-status small { grid-column: 2; text-align: left; }
  .standing-row { grid-template-columns: 1fr repeat(4, 32px); }
  footer { display: none; }
}
