
:root {
  color-scheme: dark;
  --ink: #f7f1df;
  --muted: #a8a394;
  --panel: rgba(17, 22, 25, 0.94);
  --panel-soft: rgba(26, 33, 36, 0.86);
  --line: rgba(225, 210, 165, 0.2);
  --gold: #e9bf68;
  --gold-soft: #ffe4a3;
  --teal: #4fd1c5;
  --red: #ee736b;
  --green: #86d69c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --motion-duration: 800ms;
  --card-width: clamp(52px, min(8.5vw, calc((100dvh - 260px) / 8)), 110px);
  --card-height: calc(var(--card-width) * 1.42);
  --field-card-width: min(calc(var(--card-width) * 1.375), 152.5px);
  --field-card-height: calc(var(--field-card-width) * 1.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
html:not(.match-active), body:not(.match-active) { overflow-x: hidden; }
body {
  background:
    radial-gradient(circle at 50% 38%, rgba(40, 104, 98, 0.18), transparent 32rem),
    linear-gradient(135deg, #080b0d 0%, #11191a 45%, #0b0d10 100%);
  color: var(--ink);
}
html.match-active, body.match-active { overflow: hidden; }
button, input, select { font: inherit; }
button, select, input { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
[aria-busy="true"] .game-page [data-action],
[aria-busy="true"] .opening-hand-page [data-action] { pointer-events: none; }
[aria-busy="true"] .action-buttons { opacity: 0.68; }
:focus-visible { outline: 3px solid var(--gold-soft); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-200%);
  background: var(--ink);
  color: #111;
  padding: 0.65rem 1rem;
  border-radius: 0.4rem;
}
.skip-link:focus { transform: none; }

.app-shell { min-height: 100vh; }
.match-active .app-shell { height: 100dvh; min-height: 0; overflow: hidden; }
.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 56px;
  min-height: 56px;
  padding: 0.4rem clamp(0.75rem, 2vw, 1.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 13, 0.88);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 0.8rem; }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(233, 191, 104, 0.65);
  border-radius: 50%;
  background: radial-gradient(circle, #335b55, #111);
  color: var(--gold-soft);
  font-family: Georgia, serif;
  font-weight: 700;
}
.brand h1 { margin: 0; font: 600 clamp(1rem, 2vw, 1.3rem)/1 Georgia, serif; letter-spacing: 0.08em; }
.brand small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; }
.topbar-actions { display: flex; align-items: center; gap: 0.55rem; }
.topbar-concede { padding: 0.45rem 0.7rem; }
.topbar.match-topbar {
  position: fixed;
  right: 0.55rem;
  left: auto;
  width: auto;
  height: auto;
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0.45rem;
  backdrop-filter: none;
  pointer-events: none;
}
.match-topbar .topbar-actions { pointer-events: auto; }
.connection { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.78rem; }
.connection::before { width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--red); content: ""; }
.connection[data-state="online"]::before { background: var(--green); box-shadow: 0 0 12px rgba(134, 214, 156, 0.65); }
.connection[data-state="connecting"]::before { background: var(--gold); animation: pulse 1s infinite; }

.icon-button, .quiet-button, .primary-button, .danger-button {
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.65rem 0.9rem;
}
.icon-button:hover, .quiet-button:hover { border-color: rgba(233, 191, 104, 0.5); background: rgba(233, 191, 104, 0.08); }
.primary-button {
  border-color: rgba(233, 191, 104, 0.7);
  background: linear-gradient(135deg, #9a6f2c, #d4a952);
  color: #15110a;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(186, 132, 45, 0.25);
}
.primary-button:hover { filter: brightness(1.08); }
.danger-button { border-color: rgba(238, 115, 107, 0.45); color: #ffaaa4; }

.welcome {
  display: grid;
  min-height: calc(100vh - 62px);
  place-items: center;
  padding: clamp(1.2rem, 5vw, 4rem);
}
.welcome-card {
  width: min(100%, 690px);
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background:
    linear-gradient(rgba(10, 14, 16, 0.82), rgba(10, 14, 16, 0.96)),
    radial-gradient(circle at 70% 0%, rgba(233, 191, 104, 0.25), transparent 24rem);
  padding: clamp(1.5rem, 5vw, 3.5rem);
  box-shadow: var(--shadow);
}
.eyebrow { color: var(--gold); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.welcome-card h2 { margin: 0.5rem 0 0.8rem; font: 500 clamp(2rem, 7vw, 4.4rem)/0.95 Georgia, serif; }
.welcome-card p { max-width: 55ch; color: #c7c2b4; line-height: 1.7; }
.form-stack { display: grid; gap: 0.8rem; margin-top: 1.5rem; }
.form-stack label, .selection-grid label { display: grid; gap: 0.42rem; color: var(--muted); font-size: 0.8rem; font-weight: 700; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: #0d1214;
  padding: 0.78rem 0.85rem;
}

.lobby-page { width: min(1180px, 100%); margin: 0 auto; overflow-x: clip; padding: clamp(1.2rem, 4vw, 3rem); }
.lobby-hero { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.lobby-hero h2 { margin: 0.3rem 0 0; font: 500 clamp(1.8rem, 5vw, 3.5rem)/1 Georgia, serif; }
.lobby-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.lobby-panel { border: 1px solid var(--line); border-radius: 0.9rem; background: var(--panel-soft); padding: 1.2rem; box-shadow: var(--shadow); }
.lobby-panel h3 { margin: 0 0 0.45rem; font: 600 1.15rem Georgia, serif; }
.lobby-panel p { min-height: 3em; color: var(--muted); font-size: 0.86rem; line-height: 1.5; }
.lobby-panel .primary-button, .lobby-panel .quiet-button { width: 100%; }
.join-form { display: flex; gap: 0.5rem; }
.join-form input { min-width: 0; }

.room-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.2rem; align-items: start; }
.seat-list { display: grid; gap: 0.75rem; }
.seat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.025);
  padding: 0.9rem;
}
.seat-avatar { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: 50%; background: #294944; color: var(--gold-soft); font-weight: 800; }
.seat-copy { flex: 1; }
.seat-copy strong, .seat-copy small { display: block; }
.seat-copy small { margin-top: 0.2rem; color: var(--muted); }
.selection-panel { min-width: 0; }
.selection-panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.selection-panel-heading h3 { margin-top: 0.2rem; }
.selection-panel-heading p { max-width: 36rem; min-height: 0; margin: 0; text-align: right; }
.selection-grid { display: grid; gap: 1.15rem; margin-top: 1rem; }
.selection-grid fieldset { min-width: 0; margin: 0; border: 0; padding: 0; }
.selection-grid legend { margin-bottom: 0.65rem; color: var(--gold-soft); font: 700 0.78rem/1.2 system-ui, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.hero-option-strip { display: grid; grid-auto-columns: 92px; grid-auto-flow: column; gap: 0.55rem; overflow-x: auto; padding: 0.15rem 0.1rem 0.65rem; scrollbar-color: var(--line) transparent; }
.hero-option { display: block !important; cursor: pointer; }
.hero-option input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.hero-option > span { display: grid; grid-template-rows: 74px auto auto; height: 100%; overflow: hidden; border: 1px solid var(--line); border-radius: 0.72rem; background: #0d1214; transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease; }
.hero-option:hover > span { border-color: rgba(233, 191, 104, 0.55); transform: translateY(-1px); }
.hero-option input:focus-visible + span { outline: 2px solid var(--teal); outline-offset: 2px; }
.hero-option input:checked + span { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(233, 191, 104, 0.35), 0 0 18px rgba(233, 191, 104, 0.16); }
.hero-option img, .hero-option-fallback { width: 100%; height: 74px; object-fit: cover; object-position: center 20%; background: linear-gradient(145deg, #294944, #11181a); }
.hero-option-fallback { display: grid; place-items: center; color: var(--gold-soft); font: 600 2rem Georgia, serif; }
.hero-option > span > strong { overflow: hidden; padding: 0.42rem 0.45rem 0.15rem; color: var(--ink); font-size: 0.72rem; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.hero-option > span > small { display: flex; align-items: center; gap: 0.22rem; padding: 0 0.45rem 0.42rem; color: #ef8d8d; font-size: 0.7rem; }
.hero-option .stat-icon { width: 0.75rem; height: 0.75rem; }
.selected-hero-detail { display: grid; grid-template-columns: 150px minmax(0, 1fr); min-height: 190px; overflow: hidden; border: 1px solid rgba(233, 191, 104, 0.28); border-radius: 0.85rem; background: radial-gradient(circle at 0 0, rgba(233, 191, 104, 0.12), transparent 20rem), rgba(8, 12, 13, 0.82); }
.selected-hero-art { width: 150px; height: 100%; min-height: 190px; object-fit: cover; object-position: center 18%; }
.hero-art-fallback { display: grid; place-items: center; background: linear-gradient(145deg, #294944, #11181a); color: var(--gold-soft); font: 600 3rem Georgia, serif; }
.selected-hero-copy { padding: 1rem 1.1rem; }
.selected-hero-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.selected-hero-title small { color: var(--muted); font-size: 0.67rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.selected-hero-title h4 { margin: 0.16rem 0 0; color: var(--gold-soft); font: 600 1.45rem Georgia, serif; }
.hero-health { display: flex; align-items: center; gap: 0.3rem; color: #ef8d8d; font-size: 1rem; }
.hero-health .stat-icon { width: 1.15rem; height: 1.15rem; }
.hero-abilities { display: grid; gap: 0.4rem; margin: 0.8rem 0 0; padding: 0; list-style: none; }
.hero-abilities li { color: #d7d3c8; font-size: 0.8rem; line-height: 1.45; }
.hero-abilities li::before { content: "◆"; margin-right: 0.45rem; color: var(--teal); font-size: 0.6rem; }
.hero-ability-empty { min-height: 0 !important; margin: 0.8rem 0 0; }
.selected-hero-copy blockquote { margin: 0.75rem 0 0; color: var(--muted); font: italic 0.76rem/1.45 Georgia, serif; }
.clan-select-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 0.75rem; }
.clan-select-controls > span { padding-bottom: 0.8rem; color: var(--gold); font-size: 1.25rem; }
.clan-randomizer { display: flex; align-items: end; justify-content: space-between; gap: 0.75rem; margin-top: 0.8rem; border: 1px solid rgba(79, 209, 197, 0.2); border-radius: 0.75rem; background: rgba(79, 209, 197, 0.05); padding: 0.7rem; }
.clan-randomizer label { width: min(100%, 18rem); }
.clan-randomizer > div { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.clan-randomizer button, .clan-assign-actions button { width: auto; border-color: rgba(233, 191, 104, 0.3); background: #11191a; padding: 0.55rem 0.7rem; font-size: 0.68rem; }
.clan-browser-note { min-height: 0 !important; margin: 0.7rem 0; font-size: 0.72rem; }
.clan-set { margin-top: 0.55rem; border: 1px solid var(--line); border-radius: 0.8rem; background: rgba(255,255,255,0.018); }
.clan-set > summary { cursor: pointer; padding: 0.8rem 0.9rem; color: var(--gold-soft); list-style-position: inside; }
.clan-set > summary span { display: inline-flex; align-items: baseline; justify-content: space-between; width: calc(100% - 1.5rem); margin-left: 0.35rem; }
.clan-set > summary small { color: var(--muted); font-size: 0.65rem; font-weight: 500; }
.clan-option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; border-top: 1px solid var(--line); padding: 0.65rem; }
.clan-option-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 0.7rem; background: rgba(255,255,255,0.025); padding: 0.7rem; }
.clan-option-card > header { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 0.65rem; }
.clan-option-selected { border-color: var(--teal); box-shadow: inset 0 0 16px rgba(79, 209, 197, 0.08); }
.clan-crest { position: relative; display: grid; width: 48px; height: 54px; place-items: center; color: var(--gold-soft); }
.clan-crest svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.clan-crest svg path:first-child { fill: #172727; stroke: rgba(233, 191, 104, 0.7); stroke-width: 2; }
.clan-crest svg path:last-child { fill: rgba(79, 209, 197, 0.13); }
.clan-crest strong { position: relative; font: 700 0.72rem Georgia, serif; }
.clan-option-title { display: flex; align-items: baseline; justify-content: space-between; gap: 0.35rem; }
.clan-option-title h4 { overflow: hidden; margin: 0; color: var(--ink); font-size: 0.78rem; text-overflow: ellipsis; white-space: nowrap; }
.clan-option-title small { flex: none; color: var(--teal); font-size: 0.58rem; font-weight: 800; text-transform: uppercase; }
.clan-option-copy p { min-height: 0; margin: 0.18rem 0 0.38rem; color: #bdb8ac; font-size: 0.68rem; }
.clan-type-counts { display: flex; flex-wrap: wrap; gap: 0.18rem 0.45rem; color: var(--muted); font-size: 0.58rem; }
.clan-type-counts strong { color: var(--gold-soft); }
.clan-favorite { width: 2.3rem; height: 2.3rem; border-color: var(--line); border-radius: 50%; background: #11191a; padding: 0; color: var(--muted); font-size: 1.25rem; }
.clan-favorite.is-favorite { border-color: var(--gold); color: var(--gold); box-shadow: 0 0 14px rgba(233, 191, 104, 0.18); }
.clan-card-strip { display: grid; grid-auto-columns: 168px; grid-auto-flow: column; gap: 0.45rem; overflow-x: auto; margin-top: 0.65rem; padding: 0.15rem 0.05rem 0.55rem; scroll-snap-type: x proximity; scrollbar-color: var(--line) transparent; }
.clan-card-preview { display: grid; grid-template-rows: 112px auto auto 1fr; min-width: 0; overflow: hidden; border: 1px solid rgba(233, 191, 104, 0.18); border-radius: 0.55rem; background: #0c1112; scroll-snap-align: start; }
.clan-card-art { width: 100%; height: 112px; object-fit: cover; object-position: center 22%; background: linear-gradient(145deg, #294944, #11181a); }
.clan-card-art-fallback { display: grid; place-items: center; color: var(--gold-soft); font: 600 2rem Georgia, serif; }
.clan-card-preview > strong { overflow: hidden; padding: 0.38rem 0.42rem 0.1rem; color: var(--ink); font-size: 0.64rem; text-overflow: ellipsis; white-space: nowrap; }
.clan-card-preview > small { display: flex; align-items: center; min-height: 1.45rem; padding: 0 0.42rem 0.35rem; color: var(--muted); font-size: 0.57rem; }
.clan-card-preview .stat-icon { width: 0.68rem; height: 0.68rem; margin-right: 0.12rem; }
.clan-card-rules { display: grid; gap: 0.3rem; margin: 0; border-top: 1px solid rgba(233, 191, 104, 0.12); padding: 0.42rem; color: #d7d3c8; font-size: 0.59rem; line-height: 1.4; list-style: none; }
.clan-card-rules li::before { content: "◆"; margin-right: 0.3rem; color: var(--teal); font-size: 0.45rem; }
.clan-card-rules-empty { display: block; color: var(--muted); font-style: italic; }
.clan-assign-actions { display: flex; justify-content: end; gap: 0.4rem; margin-top: 0.55rem; }
.selection-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.selection-actions .quiet-button { width: auto; min-width: 10rem; }
.selection-actions > span { display: grid; gap: 0.1rem; }
.selection-actions > span small { color: var(--muted); font-size: 0.68rem; }
.random-toggle { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 0.65rem !important; cursor: pointer; }
.random-toggle input { width: auto; }
.random-toggle span { display: grid; gap: 0.12rem; }
.random-toggle strong { color: var(--ink); }
.random-toggle small { color: var(--muted); font-weight: 500; }
.clan-selector:disabled { opacity: 0.45; }
.room-code { font: 700 1.5rem ui-monospace, monospace; letter-spacing: 0.15em; color: var(--gold-soft); }
.quick-start { border: 1px solid var(--line); border-radius: 0.9rem; background: var(--panel-soft); color: var(--muted); }
.quick-start summary { cursor: pointer; color: var(--gold-soft); font: 600 1rem Georgia, serif; }
.quick-start-content { padding-top: 0.8rem; font-size: 0.84rem; line-height: 1.55; }
.quick-start-content h3 { margin: 0 0 0.5rem; color: var(--ink); }
.quick-start-content ol { margin: 0; padding-left: 1.25rem; }
.quick-start-content li + li { margin-top: 0.35rem; }
.opening-hand-page {
  display: grid;
  height: calc(100dvh - 56px);
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: clamp(1rem, 3vw, 2.5rem);
}
.opening-hand-panel {
  width: min(100%, 1320px);
  border: 1px solid rgba(233, 191, 104, 0.3);
  border-radius: 1.25rem;
  background:
    linear-gradient(rgba(10, 14, 16, 0.86), rgba(10, 14, 16, 0.97)),
    radial-gradient(circle at 50% 15%, rgba(79, 209, 197, 0.19), transparent 38rem);
  padding: clamp(1.25rem, 3vw, 2.5rem);
  box-shadow: var(--shadow);
}
.opening-hand-heading { max-width: 660px; margin: 0 auto; text-align: center; }
.opening-hand-heading h2 { margin: 0.4rem 0 0.65rem; font: 500 clamp(1.8rem, 4vw, 3rem)/1 Georgia, serif; }
.opening-hand-heading p { margin: 0; color: #c7c2b4; line-height: 1.55; }
.opening-hand-cards {
  --card-width: clamp(108px, 11vw, 158px);
  --card-height: calc(var(--card-width) * 1.42);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.55rem, 1.4vw, 1rem);
  margin: clamp(1.25rem, 3vh, 2.25rem) auto;
}
.opening-hand-cards .game-card { flex: 0 0 auto; }
.opening-hand-cards .game-card:hover,
.opening-hand-cards .game-card:focus-visible { transform: translateY(-10px) scale(1.04); }
.opening-hand-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.7rem; }
.opening-hand-actions button { min-width: 150px; }
.opening-hand-waiting { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--gold-soft); }
.opening-hand-waiting > span { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--gold); animation: pulse 1s infinite; }
.opening-hand-note { margin: 1rem 0 0; color: var(--muted); font-size: 0.72rem; text-align: center; }
.game-page {
  position: relative;
  display: grid;
  height: 100dvh;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.match-hud {
  position: absolute;
  z-index: 20;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  border: 1px solid rgba(225, 210, 165, 0.16);
  border-radius: 999px;
  background: rgba(8, 11, 13, 0.8);
  padding: 0.38rem 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
  pointer-events: none;
}
.combatant { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.combatant-copy { min-width: 0; }
.hero-medallion { display: grid; width: 2.7rem; height: 2.7rem; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: #182629; color: var(--gold-soft); }
.combatant strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resources { display: flex; flex-wrap: wrap; gap: 0.28rem; margin-top: 0.28rem; color: var(--muted); }
.resource-stat {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 0.34rem;
  min-width: 4.65rem;
  border: 1px solid rgba(225, 210, 165, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  padding: 0.38rem 0.66rem;
  white-space: nowrap;
}
.stat-icon { display: inline-block; width: 1em; height: 1em; flex: 0 0 auto; overflow: visible; }
.resource-stat .stat-icon { width: 1.08rem; height: 1.08rem; color: #b8c7c3; }
.resource-energy .stat-icon { color: #64e3d7; filter: drop-shadow(0 0 4px rgba(79, 209, 197, 0.55)); }
.resource-gold .stat-icon { color: #f3ca70; filter: drop-shadow(0 0 4px rgba(233, 191, 104, 0.5)); }
.resource-hand .stat-icon, .resource-deck .stat-icon, .resource-discard .stat-icon { color: #c7d4d0; }
.resource-stat strong { color: var(--ink); font-size: 1rem; line-height: 1; }
.resource-stat small { color: var(--muted); font-size: 0.64rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; }
.resource-stat-button { cursor: pointer; font: inherit; }
.resource-stat-button:hover, .resource-stat-button:focus-visible { border-color: var(--gold); background: rgba(233, 191, 104, 0.14); }
.resource-energy { border-color: rgba(79, 209, 197, 0.32); background: rgba(79, 209, 197, 0.08); }
.resource-gold { border-color: rgba(233, 191, 104, 0.34); background: rgba(233, 191, 104, 0.09); }
.resource-changed { animation: resource-pop var(--motion-duration) cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.turn-status { text-align: center; }
.turn-status strong { display: block; font: 600 1.05rem Georgia, serif; }
.turn-status small { color: var(--muted); }

.play-surface {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-columns: clamp(112px, 12vw, 178px) minmax(0, 1fr) clamp(112px, 12vw, 178px);
  align-items: stretch;
  gap: clamp(0.3rem, 1vw, 0.9rem);
  width: min(1560px, calc(100% - 0.5rem));
  margin: 0 auto;
  padding: 3.2rem 0 0.25rem;
}
.side-player-info {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: 24px minmax(0, 1fr) minmax(0, 1fr) calc(var(--card-height) + 0.45rem);
}
.opponent-player-info .combatant { grid-row: 2; }
.your-player-info .combatant { grid-row: 3; }
.side-player-info .combatant {
  display: grid;
  align-self: center;
  justify-items: center;
  gap: 0.45rem;
  width: 100%;
  border: 1px solid rgba(225, 210, 165, 0.16);
  border-radius: 0.9rem;
  background: rgba(10, 15, 17, 0.76);
  padding: 0.65rem 0.5rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  text-align: center;
}
.side-player-info .combatant-copy { width: 100%; }
.side-player-info .resources { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0.28rem; }
.side-player-info .resource-stat { width: 100%; min-width: 0; justify-content: center; pointer-events: auto; }
.field-stack {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  max-width: 1180px;
  height: 100%;
  margin-inline: auto;
}
.board-shell {
  --board-block-padding: clamp(0.35rem, 0.8vh, 0.7rem);
  --board-frame-inset: 0.2rem;
  --board-inline-padding: clamp(0.35rem, 1vw, 0.8rem);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: minmax(max-content, 1fr) minmax(38px, auto) minmax(max-content, 1fr);
  min-height: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--board-block-padding) var(--board-inline-padding);
}
.board-shell::before {
  position: absolute;
  inset: var(--board-frame-inset);
  z-index: -2;
  border: 1px solid rgba(233, 191, 104, 0.13);
  border-radius: 1.1rem;
  background:
    linear-gradient(90deg, transparent 49.85%, rgba(233, 191, 104, 0.08) 50%, transparent 50.15%),
    radial-gradient(ellipse at center, rgba(36, 77, 73, 0.5), rgba(12, 18, 20, 0.75) 68%);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.45);
  content: "";
}
.player-field {
  position: relative;
  isolation: isolate;
  display: grid;
  min-width: 0;
  min-height: 0;
  align-content: center;
  gap: clamp(0.2rem, 0.7vh, 0.5rem);
  padding-block: clamp(0.15rem, 0.45vh, 0.35rem);
}
.player-field::after {
  position: absolute;
  inset: 0;
  inset-inline: calc(var(--board-frame-inset) - var(--board-inline-padding));
  z-index: -1;
  border: 1px solid rgba(79, 209, 197, 0.62);
  border-radius: 0.9rem;
  background: radial-gradient(ellipse at center, rgba(79, 209, 197, 0.16), rgba(79, 209, 197, 0.035) 62%, transparent 78%);
  box-shadow: inset 0 0 34px rgba(79, 209, 197, 0.12), 0 0 24px rgba(79, 209, 197, 0.2);
  content: "";
  pointer-events: none;
}
.opponent-field::after { inset-block-start: calc(var(--board-frame-inset) - var(--board-block-padding)); }
.your-field::after { inset-block-end: calc(var(--board-frame-inset) - var(--board-block-padding)); }
.player-field::after { display: none; }
.board-shell.active-field-opponent .opponent-field::after,
.board-shell.active-field-you .your-field::after { display: block; }
.board-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--board-slot-count, 4), minmax(var(--field-card-width), 1fr));
  justify-items: center;
  gap: clamp(0.6rem, 2.4vw, 2.5rem);
  width: min(100%, 1080px);
  margin-inline: auto;
}
.row-label { position: absolute; left: 0.85rem; align-self: center; color: rgba(255, 255, 255, 0.28); font-size: 0.65rem; letter-spacing: 0.12em; text-transform: uppercase; writing-mode: vertical-rl; }
.slotless-zone,
.removed-zone {
  position: relative;
  display: flex;
  min-height: 0;
  align-items: center;
  justify-content: center;
  gap: clamp(0.3rem, 1vw, 0.8rem);
}
.removed-zone { opacity: 0.78; }
.slotless-zone .game-card,
.removed-zone .game-card,
.slotless-zone .card-with-abilities,
.removed-zone .card-with-abilities { width: calc(var(--field-card-width) * 0.82); height: calc(var(--field-card-height) * 0.82); }
.field-divider { display: flex; min-height: calc(var(--card-height) * 0.38); align-items: center; justify-content: center; gap: 0.8rem; color: rgba(233, 191, 104, 0.34); font: 600 0.58rem Georgia, serif; letter-spacing: 0.18em; text-transform: uppercase; }
.field-divider .game-card { flex: 0 0 auto; transform: scale(0.82); }
.field-divider::before, .field-divider::after { height: 1px; flex: 1; background: linear-gradient(90deg, transparent, rgba(233, 191, 104, 0.28), transparent); content: ""; }
.your-field-response { position: absolute; z-index: 4; top: 50%; right: 0; left: 0; display: flex; align-items: center; justify-content: center; gap: 0.65rem; transform: translateY(-50%); }
.your-field-response::before, .your-field-response::after { width: min(18vw, 9rem); height: 1px; background: linear-gradient(90deg, transparent, rgba(79, 209, 197, 0.42)); content: ""; }
.your-field-response::after { transform: scaleX(-1); }
.no-trap-button { min-width: 7.5rem; border-color: rgba(79, 209, 197, 0.72); box-shadow: 0 0 18px rgba(79, 209, 197, 0.2); }
.board-slot {
  position: relative;
  display: grid;
  width: var(--card-width);
  height: var(--card-height);
  place-items: center;
  border: 1px dashed rgba(210, 221, 215, 0.13);
  border-radius: 0.65rem;
  background: rgba(255, 255, 255, 0.018);
}
.board-row .board-slot,
.board-row .game-card,
.board-row .card-with-abilities {
  width: var(--field-card-width);
  height: var(--field-card-height);
}
button.board-slot { color: rgba(255, 255, 255, 0.45); }
button.board-slot.legal { border-color: var(--gold); background: rgba(233, 191, 104, 0.1); animation: legal-glow 1.4s infinite; }

.shop-toggle {
  position: fixed;
  z-index: 30;
  top: 4.15rem;
  right: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid rgba(233, 191, 104, 0.58);
  border-radius: 999px;
  background: rgba(33, 28, 17, 0.94);
  padding: 0.55rem 0.8rem;
  color: var(--gold-soft);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42), 0 0 16px rgba(233, 191, 104, 0.12);
}
.shop-toggle .stat-icon { width: 1.05rem; height: 1.05rem; }
.shop-toggle:hover, .shop-toggle:focus-visible { border-color: #ffe39b; background: rgba(73, 56, 23, 0.96); }
.shop-toggle.shop-beginning-ready { border-color: rgba(255, 226, 154, 0.96); background: rgba(73, 56, 23, 0.96); box-shadow: 0 0 0 3px rgba(233, 191, 104, 0.24), 0 0 28px rgba(233, 191, 104, 0.68); }
.shop-toggle.shop-interaction-ready { box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.22), 0 0 24px rgba(79, 209, 197, 0.55); }
.shop-backdrop {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: safe center;
  background: rgba(4, 7, 8, 0.72);
  overflow: auto;
  padding: 1rem;
  backdrop-filter: blur(8px);
}
.shop-strip {
  display: flex;
  width: min(720px, calc(100vw - 2rem));
  max-height: none;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.45rem, 1vh, 0.8rem);
  border: 1px solid rgba(233, 191, 104, 0.2);
  border-radius: 1rem;
  background: linear-gradient(180deg, rgba(39, 34, 23, 0.82), rgba(13, 18, 19, 0.94));
  overflow: visible;
  padding: clamp(0.8rem, 2vw, 1.25rem);
  box-shadow: inset 0 0 38px rgba(233, 191, 104, 0.04), var(--shadow);
}
.shop-strip.shop-open {
  border-color: rgba(255, 220, 132, 0.78);
  background: linear-gradient(180deg, rgba(77, 60, 25, 0.92), rgba(18, 24, 23, 0.96));
  box-shadow: inset 0 0 48px rgba(233, 191, 104, 0.12), 0 0 24px rgba(233, 191, 104, 0.24), var(--shadow);
}

.davy-locker {
  display: grid;
  gap: 0.2rem;
  justify-items: center;
  padding-left: 0.45rem;
  border-left: 1px solid rgba(114, 214, 226, 0.42);
}

.davy-locker-label {
  color: #9be7ef;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.shop-heading { display: flex; width: 100%; align-items: start; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 0.6rem; text-align: left; }
.shop-heading > div { min-width: 0; }
.shop-heading small { display: block; margin-top: 0.2rem; color: var(--muted); font-size: 0.62rem; letter-spacing: 0.08em; text-transform: uppercase; }
.shop-label { color: var(--gold); font: 600 0.72rem Georgia, serif; letter-spacing: 0.16em; text-transform: uppercase; }
.shop-open .shop-label { color: #ffe8a9; text-shadow: 0 0 16px rgba(255, 218, 119, 0.82); }
.shop-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-items: center; gap: clamp(0.8rem, 2vw, 1.4rem); }
.shop-card { display: flex; align-items: center; gap: clamp(0.35rem, 0.7vw, 0.6rem); margin: 0; }
.shop-buy-cost { display: grid; min-width: 2.65rem; grid-template-columns: auto auto; place-items: center; border: 1px solid rgba(255, 220, 132, 0.58); border-radius: 999px; background: radial-gradient(circle at 35% 30%, #f9da82, #9a671d 74%); padding: 0.38rem 0.45rem; color: #171007; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.48), 0 0 16px rgba(233, 191, 104, 0.18); }
.shop-buy-cost .stat-icon { width: 0.8rem; height: 0.8rem; }
.shop-buy-cost strong { font: 900 0.85rem/1 Georgia, serif; }
.shop-buy-cost small { grid-column: 1 / -1; margin-top: 0.12rem; font-size: 0.48rem; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.shop-open .shop-card.purchasable .game-card { box-shadow: 0 0 0 3px rgba(255, 226, 154, 0.16), 0 0 18px rgba(233, 191, 104, 0.42); }
.shop-card.ability-target .game-card { box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.2), 0 0 24px rgba(79, 209, 197, 0.58); }
.shop-hand { display: grid; width: 100%; gap: 0.6rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }
.shop-hand-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; text-align: left; }
.shop-hand-heading small { color: var(--muted); font-size: 0.62rem; letter-spacing: 0.05em; }
.shop-hand-cards { display: flex; width: 100%; min-height: calc(var(--card-height) + 0.8rem); flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.7rem; overflow: visible; padding: 0.4rem 0.45rem 0.8rem; }
.shop-hand-cards .game-card { flex: 0 0 auto; }
.shop-hand-card { cursor: default; }
.shop-hand-card:hover, .shop-hand-card:focus-visible { transform: translateY(-5px) scale(1.03); }
.barracks-staging { border-color: rgba(202, 164, 91, 0.5); }
.barracks-underlays { position: absolute; right: -0.65rem; bottom: -0.45rem; display: flex; z-index: 5; }
.barracks-underlay.game-card { width: 2.15rem; min-width: 2.15rem; height: 3rem; margin-left: -1.35rem; border-width: 1px; transform: rotate(calc((var(--underlay-index, 0) - 2) * 2deg)); }
.barracks-underlay.game-card:first-child { margin-left: 0; }
.barracks-underlay.game-card.legal { cursor: pointer; box-shadow: 0 0 0 2px rgba(255, 226, 154, 0.48), 0 0 16px rgba(233, 191, 104, 0.72); }
.barracks-underlay.game-card.selected { border-color: #9af7e8; box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.42), 0 0 18px rgba(79, 209, 197, 0.72); }
.barracks-order { display: grid; width: 1.2rem; height: 1.2rem; place-items: center; border-radius: 999px; background: #9af7e8; color: #10221e; font: 900 0.7rem/1 system-ui, sans-serif; }

.game-card {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  overflow: visible;
  border: 1px solid rgba(225, 210, 165, 0.45);
  border-radius: 0.65rem;
  background: #151a1b;
  padding: 0;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.4);
  text-align: left;
  transition: transform 160ms ease, filter 160ms ease, border-color 160ms ease;
}
.card-with-abilities { position: relative; z-index: 1; display: inline-grid; width: var(--card-width); height: var(--card-height); flex: 0 0 auto; place-items: center; overflow: visible; }
.card-with-abilities:hover, .card-with-abilities:focus-within { z-index: 18; }
.card-with-abilities > .game-card { width: 100%; height: 100%; }
.ability-ready-controls { position: absolute; z-index: 16; top: 50%; left: calc(100% + 0.22rem); display: grid; justify-items: start; gap: 0.22rem; transform: translateY(-50%); pointer-events: none; }
.ability-ready-button {
  display: grid;
  width: 1.35rem;
  height: 1.35rem;
  place-items: center;
  border: 1px solid rgba(255, 220, 132, 0.9);
  border-radius: 0.4rem;
  background: linear-gradient(135deg, #473717, #1b211b);
  padding: 0;
  color: #fff0b9;
  box-shadow: 0 0 0 2px rgba(13, 18, 20, 0.8), 0 0 15px rgba(233, 191, 104, 0.38);
  cursor: pointer;
  font-size: 0.62rem;
  line-height: 1;
  pointer-events: auto;
  animation: ability-ready-pulse 1.8s ease-in-out infinite;
}
.ability-ready-button:hover, .ability-ready-button:focus-visible { z-index: 2; border-color: #fff1ad; background: linear-gradient(135deg, #6a511d, #23302a); transform: translateX(1px) scale(1.06); }
.game-card:hover, .game-card:focus-visible { z-index: 12; transform: translateY(-7px) scale(1.04); }
.game-card.legal { border: 2px solid var(--gold); box-shadow: 0 0 0 3px rgba(233, 191, 104, 0.14), 0 10px 28px rgba(0, 0, 0, 0.5); }
.game-card.selected { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.2); }
.game-card.sanctions-selected { border-color: #f2c94c; box-shadow: 0 0 0 4px rgba(242, 201, 76, 0.28), 0 0 20px rgba(242, 201, 76, 0.42); transform: translateY(-8px); }
.game-card.not-active {
  border-color: rgba(193, 202, 199, 0.34);
  background: #111617;
  box-shadow: 0 6px 13px rgba(0, 0, 0, 0.48);
}
.game-card.not-active .card-art {
  filter: grayscale(0.78) saturate(0.48) brightness(0.76);
  opacity: 0.84;
}
.game-card.not-active .card-shade {
  background: linear-gradient(rgba(31, 38, 39, 0.18) 18%, rgba(4, 7, 8, 0.96) 88%);
}
.game-card.not-active .card-cost,
.game-card.not-active .card-name,
.game-card.not-active .card-type,
.game-card.not-active .card-stats {
  filter: grayscale(0.65) brightness(0.82);
}
.game-card.targetable,
.game-card.not-active.targetable {
  border: 2px solid #ffe29a;
  outline: 2px solid rgba(255, 226, 154, 0.52);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(233, 191, 104, 0.24), 0 0 24px 7px rgba(233, 191, 104, 0.78), 0 10px 28px rgba(0, 0, 0, 0.55);
}
.game-card.defensive::after {
  position: absolute;
  top: 0.28rem;
  right: 0.28rem;
  z-index: 3;
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  border: 1px solid rgba(218, 239, 244, 0.85);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e8f4f5, #75959c 72%);
  color: #102d34;
  content: "🛡";
  font: 0.9rem/1 "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  filter: none;
  box-shadow: 0 2px 7px #000, 0 0 12px rgba(171, 221, 229, 0.35);
}
.card-art { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; background: linear-gradient(140deg, #2b504a, #12191b 60%); }
.card-shade { position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(transparent 35%, rgba(4, 7, 8, 0.94) 88%); }
.card-cost { position: absolute; z-index: 2; top: -0.2rem; left: -0.2rem; display: flex; width: 1.9rem; height: 1.65rem; align-items: center; justify-content: center; gap: 0.08rem; border: 2px solid #baf5ef; border-radius: 999px; background: radial-gradient(circle at 35% 30%, #377f86, #173f47 76%); color: white; font-size: 0.72rem; font-weight: 900; box-shadow: 0 2px 7px #000, 0 0 10px rgba(79, 209, 197, 0.2); }
.card-cost .stat-icon { width: 0.58rem; height: 0.72rem; color: #9ff7ed; }
.card-cost strong { line-height: 1; }
.card-credit { position: absolute; z-index: 4; top: -0.32rem; right: -0.32rem; display: grid; min-width: 2.2rem; min-height: 2.2rem; grid-template-columns: auto auto; place-items: center; border: 2px solid #d9fff8; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #77e2d1, #17685f 74%); color: #061b18; line-height: 0.8; box-shadow: 0 3px 9px #000, 0 0 13px rgba(79, 209, 197, 0.35); }
.card-credit .stat-icon { width: 0.6rem; height: 0.6rem; }
.card-credit strong { font-size: 0.75rem; }
.card-credit small { grid-column: 1 / -1; font-size: 0.38rem; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase; }
.card-name { position: absolute; z-index: 2; right: 0.35rem; bottom: 1.65rem; left: 0.35rem; color: white; font: 700 clamp(0.56rem, 1vw, 0.78rem)/1.05 Georgia, serif; text-shadow: 0 1px 3px #000; }
.card-type { position: absolute; z-index: 2; right: 0.35rem; bottom: 0.35rem; left: 0.35rem; color: #d5d0bf; font-size: clamp(0.46rem, 0.7vw, 0.6rem); letter-spacing: 0.08em; text-transform: uppercase; }
.card-stats { position: absolute; z-index: 3; right: 0.3rem; bottom: 0.25rem; display: flex; align-items: center; gap: 0.28rem; border-radius: 0.35rem; background: rgba(0, 0, 0, 0.78); padding: 0.15rem 0.3rem; color: #fff; font-size: 0.62rem; font-weight: 800; }
.card-stat-group { display: inline-flex; align-items: center; gap: 0.1rem; }
.card-stat-group .stat-icon { width: 0.66rem; height: 0.66rem; }
.card-attack .stat-icon { color: #f3c873; }
.card-health .stat-icon { color: #ff7878; filter: drop-shadow(0 0 3px rgba(255, 75, 75, 0.42)); }
.card-stat.buffed { color: #74f5a1; text-shadow: 0 0 7px rgba(67, 232, 128, 0.72); }
.card-stat.debuffed { color: #ff7474; text-shadow: 0 0 7px rgba(255, 75, 75, 0.68); }
.card-tooltip {
  position: fixed;
  z-index: 90;
  inset: auto;
  display: none;
  width: min(260px, calc(100vw - 1rem));
  max-height: calc(100dvh - 1rem);
  overflow: hidden auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #0c1012;
  padding: 0.75rem;
  color: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.72rem;
  line-height: 1.45;
  pointer-events: none;
}
.card-tooltip:popover-open { display: block; }
.card-tooltip strong { display: block; margin-bottom: 0.3rem; color: var(--gold-soft); font-family: Georgia, serif; }
.card-tooltip p { margin: 0.3rem 0; }
.card-back { overflow: hidden; border-style: solid; background: radial-gradient(circle, #315f58 0 8%, transparent 9%), repeating-radial-gradient(circle, #182a2c 0 8px, #101719 9px 15px); }
.card-back::after { width: 62%; height: 62%; border: 1px solid rgba(233, 191, 104, 0.55); border-radius: 50%; content: ""; }

.hand-zone { position: relative; z-index: 24; display: flex; width: 100%; height: calc(var(--card-height) + 0.45rem); min-height: 0; justify-content: center; overflow: visible; padding: 0.35rem 0.5rem 0.1rem; }
.hand-zone .game-card, .hand-zone .card-with-abilities { flex: 0 0 auto; margin-left: calc(var(--card-width) * -0.18); transform-origin: bottom center; }
.hand-zone .game-card:first-child, .hand-zone .card-with-abilities:first-child { margin-left: 0; }
.hand-zone .card-with-abilities > .game-card { margin-left: 0; }
.hand-zone .game-card:hover, .hand-zone .game-card:focus-visible { transform: translateY(-18px) scale(1.08); }
.hand-zone.choosing-shop-credit .game-card { border-color: rgba(79, 209, 197, 0.64); }
.hand-zone.choosing-shop-credit .game-card.shop-credit-selected { border: 2px solid #8ff9e8; box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.28), 0 0 24px rgba(79, 209, 197, 0.55); transform: translateY(-10px); }
.hand-zone.choosing-shop-credit .game-card.shop-credit-selected:hover,
.hand-zone.choosing-shop-credit .game-card.shop-credit-selected:focus-visible { transform: translateY(-20px) scale(1.08); }
.hand-zone { scrollbar-width: none; }
.hand-zone::-webkit-scrollbar { display: none; }
.hero-staging { position: absolute; z-index: 28; bottom: 0.1rem; left: 0.5rem; display: flex; align-items: center; gap: 0.55rem; border: 1px solid rgba(233, 191, 104, 0.75); border-radius: 0.75rem; background: rgba(8, 11, 13, 0.94); padding: 0.35rem 0.5rem; box-shadow: 0 0 20px rgba(233, 191, 104, 0.22); }
.hero-staging > span { display: grid; max-width: 120px; gap: 0.15rem; color: var(--gold-soft); font-size: 0.68rem; line-height: 1.2; }
.hero-staging > span small { color: var(--muted); font-size: 0.6rem; }
.hand-zone .hero-staging .game-card { margin-left: 0; }
.hand-zone .hero-staging .game-card:hover, .hand-zone .hero-staging .game-card:focus-visible { transform: translateY(-8px) scale(1.05); }
.opponent-hand { display: flex; height: 24px; min-height: 0; justify-content: center; padding: 0.05rem 0 0.15rem; }
.opponent-hand .mini-back { width: 16px; height: 22px; margin-left: -5px; border: 1px solid #5f756f; border-radius: 3px; background: #16292a; transform: rotate(180deg); }
.opponent-hand .mini-back:first-child { margin-left: 0; }
.opponent-hand.revealed { height: 3.2rem; gap: 0.18rem; overflow: visible; }
.opponent-hand.revealed .card-with-abilities,
.opponent-hand.revealed .game-card { width: 2.15rem; min-width: 2.15rem; height: 3rem; }
.opponent-hand.revealed .game-card:hover,
.opponent-hand.revealed .game-card:focus-visible { transform: translateY(2px) scale(1.8); }

.action-rail {
  position: fixed;
  z-index: 25;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  justify-items: end;
  gap: 0.45rem;
}
.action-buttons { display: flex; flex-wrap: wrap; justify-content: end; gap: 0.4rem; max-width: min(550px, calc(100vw - 2rem)); border: 1px solid var(--line); border-radius: 0.8rem; background: rgba(8, 11, 13, 0.9); padding: 0.5rem; box-shadow: var(--shadow); backdrop-filter: blur(14px); }
.selection-hint { border-radius: 2rem; background: rgba(8, 11, 13, 0.88); padding: 0.45rem 0.8rem; color: var(--gold-soft); font-size: 0.76rem; }

.choice-popover { position: fixed; z-index: 45; inset: auto 50% 1.5rem auto; width: min(460px, calc(100vw - 2rem)); transform: translateX(50%); border: 1px solid var(--gold); border-radius: 0.8rem; background: var(--panel); padding: 1rem; box-shadow: var(--shadow); }
.choice-popover h3 { margin: 0 0 0.6rem; font: 600 1rem Georgia, serif; }
.choice-options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.shop-purchase-popover { top: 50%; bottom: auto; transform: translate(50%, -50%); }
.discard-popover { top: 50%; bottom: auto; width: min(760px, calc(100vw - 2rem)); transform: translate(50%, -50%); }
.popover-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.discard-popover > p { color: var(--muted); font-size: 0.78rem; }
.discard-cards { display: flex; flex-wrap: wrap; gap: 0.55rem; max-height: min(55vh, 480px); overflow: auto; }
.discard-cards .game-card { flex: 0 0 var(--card-w); }
.shop-payment-total { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; border-radius: 0.65rem; background: rgba(233, 191, 104, 0.09); padding: 0.65rem; }
.shop-payment-total strong { color: var(--gold-soft); font-size: 1.1rem; }
.shop-payment-total span { color: var(--muted); font-size: 0.72rem; }
.gold-allocation { display: grid; grid-template-columns: 1fr 5rem; align-items: center; gap: 0.35rem 0.8rem; }
.gold-allocation input { width: 100%; border: 1px solid var(--line); border-radius: 0.45rem; background: rgba(255, 255, 255, 0.06); padding: 0.45rem; }
.gold-allocation small { grid-column: 1 / -1; color: var(--muted); }
.shop-credit-instruction { display: grid; gap: 0.25rem; margin: 0.8rem 0; border: 1px solid rgba(79, 209, 197, 0.32); border-radius: 0.65rem; background: rgba(79, 209, 197, 0.08); padding: 0.65rem; }
.shop-credit-instruction strong { color: #9af7e8; font-size: 0.78rem; }
.shop-credit-instruction span { color: var(--muted); font-size: 0.7rem; line-height: 1.35; }

.settings-panel { position: fixed; z-index: 60; top: 70px; right: 1rem; width: min(340px, calc(100vw - 2rem)); border: 1px solid var(--line); border-radius: 0.85rem; background: var(--panel); padding: 1rem; box-shadow: var(--shadow); }
.settings-panel[hidden] { display: none; }
.settings-panel h2 { margin: 0 0 0.8rem; font: 600 1.2rem Georgia, serif; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.setting-with-detail { align-items: start; }
.setting-with-detail > span { display: grid; gap: 0.25rem; }
.setting-with-detail small { max-width: 18rem; color: rgba(255, 255, 255, 0.48); font-size: 0.66rem; font-weight: 400; line-height: 1.35; }
.setting input { width: auto; }

.error-banner { position: fixed; z-index: 80; top: 76px; left: 50%; width: min(620px, calc(100vw - 2rem)); transform: translateX(-50%); border: 1px solid rgba(238, 115, 107, 0.7); border-radius: 0.7rem; background: rgba(75, 20, 20, 0.96); padding: 0.75rem 1rem; box-shadow: var(--shadow); }
.empty-state { color: var(--muted); font-style: italic; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; }

.event-card-played, .visual-unit-placed { animation: unit-place var(--motion-duration) cubic-bezier(0.18, 0.85, 0.24, 1.2) both; }
.visual-unit-moved { animation: unit-move var(--motion-duration) ease-in-out both; }
.visual-card-drawn { z-index: 26; animation: card-draw var(--motion-duration) cubic-bezier(0.16, 0.82, 0.24, 1) both; }
.visual-opponent-draw { animation: opponent-draw var(--motion-duration) cubic-bezier(0.16, 0.82, 0.24, 1) both; }
.visual-state-active, .visual-state-defensive, .visual-state-inactive { animation: unit-state-change var(--motion-duration) ease both; }
.visual-state-defensive::after { animation: shield-deploy var(--motion-duration) cubic-bezier(0.18, 0.9, 0.28, 1.35) both; }
.visual-phase-changed { animation: phase-change var(--motion-duration) ease both; }
.event-damage { animation: damage-shake var(--motion-duration) ease both; }
.event-healing { animation: heal-glow var(--motion-duration) ease both; }
.event-card-defeated { animation: defeat var(--motion-duration) ease both; }
.spell-resolution-overlay {
  position: fixed;
  z-index: 55;
  inset: 56px 0 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(79, 209, 197, 0.14), transparent 42%);
  animation: spell-resolution-linger 4s ease-in-out both;
}
.spell-resolution-content { display: grid; justify-items: center; gap: 0.6rem; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.7)); }
.spell-resolution-caption { color: #dffff9; font: 700 0.82rem Georgia, serif; letter-spacing: 0.18em; text-shadow: 0 0 16px rgba(79, 209, 197, 0.9); text-transform: uppercase; }
.spell-resolution-card { --card-width: clamp(132px, 11vw, 180px); --card-height: calc(var(--card-width) * 1.4); animation: spell-card-hover 4s ease-in-out both; }
.spell-resolution-card .game-card { border-color: rgba(177, 255, 243, 0.9); box-shadow: 0 0 0 4px rgba(79, 209, 197, 0.2), 0 0 42px rgba(79, 209, 197, 0.58), 0 18px 32px rgba(0, 0, 0, 0.72); }
.spell-resolution-card .game-card:hover, .spell-resolution-card .game-card:focus-visible { transform: none; }
body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }

@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes resource-pop {
  0% { transform: scale(0.86); filter: brightness(2.2); box-shadow: 0 0 0 rgba(233, 191, 104, 0); }
  45% { border-color: #fff0bd; color: #fff4cd; transform: translateY(-4px) scale(1.14); filter: brightness(1.55); box-shadow: 0 0 10px rgba(255, 236, 177, 0.95), 0 0 32px rgba(233, 191, 104, 0.78); text-shadow: 0 0 12px rgba(255, 244, 205, 0.95); }
  100% { transform: none; filter: none; }
}
@keyframes legal-glow { 50% { box-shadow: inset 0 0 22px rgba(233, 191, 104, 0.18); } }
@keyframes unit-place { 0% { opacity: 0; transform: translateY(-38px) scale(0.72) rotate(-3deg); } 62% { opacity: 1; transform: translateY(5px) scale(1.06) rotate(1deg); } 100% { transform: none; } }
@keyframes unit-move { 0% { opacity: 0.45; transform: translateX(-28px) rotate(-2deg); } 55% { transform: translateX(5px) scale(1.05); } 100% { opacity: 1; transform: none; } }
@keyframes card-draw { 0% { opacity: 0; transform: translateY(-90px) scale(0.58) rotate(8deg); } 68% { opacity: 1; transform: translateY(8px) scale(1.08) rotate(-1deg); } 100% { transform: none; } }
@keyframes opponent-draw { 0% { opacity: 0; transform: translateY(55px) rotate(190deg) scale(1.7); } 100% { opacity: 1; transform: rotate(180deg); } }
@keyframes unit-state-change { 0%, 100% { transform: none; } 42% { transform: translateY(-7px) scale(1.1); box-shadow: 0 0 28px rgba(79, 209, 197, 0.75); } }
@keyframes shield-deploy { 0% { opacity: 0; transform: scale(0.2) rotate(-35deg); } 58% { opacity: 1; transform: scale(1.3) rotate(8deg); } 100% { transform: none; } }
@keyframes phase-change { 0% { opacity: 0.2; transform: translateY(-12px) scale(0.84); } 45% { color: var(--gold-soft); text-shadow: 0 0 24px rgba(233, 191, 104, 0.8); transform: scale(1.14); } 100% { opacity: 1; transform: none; } }
@keyframes damage-shake { 20%, 60% { transform: translateX(-6px); filter: saturate(2); } 40%, 80% { transform: translateX(6px); } }
@keyframes heal-glow { 50% { box-shadow: 0 0 32px rgba(134, 214, 156, 0.85); } }
@keyframes defeat { to { opacity: 0; transform: scale(0.75) rotate(4deg); filter: grayscale(1); } }
@keyframes spell-resolution-linger { 0% { opacity: 0; } 8%, 82% { opacity: 1; } 100% { opacity: 0; } }
@keyframes spell-card-hover { 0% { transform: translateY(24px) scale(0.72) rotate(-3deg); } 10% { transform: translateY(0) scale(1.06) rotate(0); } 70% { transform: translateY(-5px) scale(1.06); } 100% { transform: translateY(-28px) scale(0.9); } }
@keyframes ability-ready-pulse { 50% { box-shadow: 0 0 0 2px rgba(13, 18, 20, 0.8), 0 0 22px rgba(233, 191, 104, 0.62); } }

@media (max-width: 900px) {
  :root { --card-width: clamp(50px, min(12vw, calc((100dvh - 245px) / 8)), 90px); }
  .lobby-grid { grid-template-columns: 1fr; }
  .room-layout { grid-template-columns: 1fr; }
  .selection-grid { grid-template-columns: 1fr; }
  .room-seats { order: 2; }
  .selection-panel { order: 1; }
  .play-surface { grid-template-columns: clamp(88px, 12vw, 112px) minmax(0, 1fr) clamp(88px, 12vw, 112px); width: calc(100% - 0.4rem); gap: 0.25rem; }
  .side-player-info .combatant { padding: 0.45rem 0.3rem; }
  .side-player-info .hero-medallion { width: 2.2rem; height: 2.2rem; }
  .side-player-info .resource-stat { grid-template-columns: auto auto; padding: 0.3rem 0.22rem; }
  .side-player-info .resource-stat small { display: none; }
  .board-row { grid-template-columns: repeat(var(--board-slot-count, 4), minmax(var(--field-card-width), 1fr)); gap: clamp(0.4rem, 1.8vw, 1rem); }
  .row-label { display: none; }
  .action-rail { right: 0.5rem; bottom: 0.5rem; }
  .shop-strip { padding-inline: 0.8rem; }
}

@media (max-width: 560px) {
  :root { --card-width: clamp(46px, min(calc((100vw - 8rem) / 4), calc((100dvh - 225px) / 8)), 72px); }
  .topbar { height: 50px; min-height: 50px; padding: 0.35rem 0.55rem; }
  .game-page { height: 100dvh; }
  .opening-hand-page { height: calc(100dvh - 50px); padding: 0.6rem; }
  .opening-hand-panel { padding: 1rem 0.7rem; }
  .opening-hand-cards { --card-width: clamp(84px, 25vw, 112px); gap: 0.5rem; }
  .opening-hand-actions { display: grid; grid-template-columns: 1fr; }
  .opening-hand-actions button { width: 100%; }
  .selection-panel-heading { display: block; }
  .selection-panel-heading p { margin-top: 0.5rem; text-align: left; }
  .selected-hero-detail { grid-template-columns: 105px minmax(0, 1fr); }
  .selected-hero-art { width: 105px; }
  .selected-hero-copy { padding: 0.8rem; }
  .clan-select-controls { grid-template-columns: 1fr; }
  .clan-select-controls > span { display: none; }
  .clan-option-grid { grid-template-columns: 1fr; }
  .clan-randomizer { align-items: stretch; flex-direction: column; }
  .clan-randomizer label { width: 100%; }
  .clan-randomizer > div { display: grid; grid-template-columns: repeat(3, 1fr); }
  .clan-option-card > header { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .selection-actions { align-items: stretch; flex-direction: column; }
  .selection-actions .quiet-button { width: 100%; }
  .brand small, .connection span { display: none; }
  .game-page { overflow-x: hidden; }
  .match-hud { top: 0.45rem; max-width: calc(100% - 9rem); padding: 0.3rem 0.65rem; }
  .hero-medallion { width: 2.2rem; height: 2.2rem; }
  .combatant strong { font-size: 0.78rem; }
  .combatant { display: block; gap: 0.3rem; }
  .combatant-copy { width: 100%; }
  .combatant-copy > strong { display: none; }
  .resources { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.15rem; margin-top: 0; }
  .resource-stat { min-width: 0; grid-template-columns: auto auto; justify-content: center; padding: 0.3rem 0.24rem; }
  .resource-stat .stat-icon { width: 0.9rem; height: 0.9rem; }
  .resource-stat strong { font-size: 0.82rem; }
  .resource-stat small { display: none; }
  .turn-status strong { font-size: 0.8rem; }
  .turn-status small { font-size: 0.65rem; }
  .play-surface { grid-template-columns: 58px minmax(0, 1fr) 58px; padding-top: 3.65rem; }
  .side-player-info .combatant { border-radius: 0.65rem; padding: 0.35rem 0.18rem; }
  .side-player-info .hero-medallion,
  .side-player-info .combatant-copy > strong { display: none; }
  .side-player-info .resource-stat { gap: 0.12rem; border-radius: 0.45rem; padding: 0.25rem 0.08rem; }
  .side-player-info .resource-stat .stat-icon { width: 0.75rem; height: 0.75rem; }
  .side-player-info .resource-stat strong { font-size: 0.72rem; }
  .board-shell { --board-inline-padding: 0.25rem; }
  .board-row { gap: clamp(0.22rem, 1vw, 0.45rem); }
  .shop-toggle { top: auto; right: 0.35rem; bottom: 4.9rem; padding: 0.45rem 0.6rem; }
  .shop-strip { min-height: 0; padding-inline: 0.65rem; }
  .shop-heading small { font-size: 0.55rem; }
  .shop-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shop-card { gap: 0.18rem; }
  .shop-buy-cost { min-width: 2rem; padding: 0.3rem 0.25rem; }
  .shop-buy-cost small { display: none; }
  .card-name { font-size: 0.5rem; }
  .card-type { display: none; }
  .hand-zone { justify-content: center; padding-inline: 0.1rem; }
  .hand-zone .game-card { flex: 0 0 auto; margin-left: calc(var(--card-width) * -0.48); }
  .hand-zone .game-card:first-child { margin-left: 0; }
  .hero-staging > span { display: none; }
  .hero-staging { left: 0.1rem; padding: 0.2rem; }
  .action-rail { right: 0.375rem; bottom: 0.375rem; width: clamp(92px, 25vw, 118px); }
  .action-buttons { width: 100%; max-width: none; flex-direction: column; gap: 0.25rem; padding: 0.3rem; }
  .action-buttons button { width: 100%; padding: 0.5rem 0.2rem; font-size: 0.72rem; }
  .selection-hint { position: fixed; right: 0.375rem; bottom: 7.5rem; width: min(260px, calc(100vw - 0.75rem)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
