:root {
  --bg: #0b0806;
  --ink: #f3e6c8;
  --ink-dim: #cbb992;
  --panel: #100a07;
  --gold: #e2c076;
  --gold-deep: #9a7430;
  --line: rgba(226, 192, 118, 0.35);
  --radius-panel: 20px;
  --radius-btn: 8px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --font-display: Cinzel, Palatino, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --motion-fast: 180ms;
  --motion-emphasis: 600ms;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --hud-baseline: max(0.95rem, calc(env(safe-area-inset-bottom) + 0.55rem));
  --hud-ctrl: clamp(3.8rem, 14vw, 5.2rem);
  --hud-label-gap: 0.32rem;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  color-scheme: dark;
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  touch-action: none;
}

#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
}

#intro-menu {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(226, 192, 118, 0.1), transparent 48%),
    linear-gradient(180deg, rgba(10, 7, 5, 0.42), rgba(8, 5, 4, 0.7));
  transition: opacity var(--motion-emphasis) var(--ease-out), visibility var(--motion-emphasis) var(--ease-out);
}

#intro-menu.is-gone,
#hub-menu.is-gone {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#hub-menu {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(226, 192, 118, 0.1), transparent 48%),
    linear-gradient(180deg, rgba(10, 7, 5, 0.42), rgba(8, 5, 4, 0.7));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--motion-emphasis) var(--ease-out), visibility var(--motion-emphasis) var(--ease-out);
}

#hub-menu.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#logo-cine {
  z-index: 55;
  padding: 0;
  background: #050302;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 420ms var(--ease-out), visibility 420ms var(--ease-out);
}
#logo-cine.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#logo-cine video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #050302;
}

body.battle-paused #stage {
  pointer-events: none;
}

body.battle-paused #hub-menu {
  background:
    radial-gradient(ellipse at 50% 18%, rgba(226, 192, 118, 0.1), transparent 48%),
    linear-gradient(180deg, rgba(10, 7, 5, 0.42), rgba(8, 5, 4, 0.7));
}

body.theme-lava #intro-menu,
body.theme-lava #hub-menu,
body.theme-lava #how-overlay,
body.theme-lava #match-setup {
  background:
    radial-gradient(ellipse at 50% 22%, rgba(255, 92, 28, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(42, 10, 6, 0.34), rgba(16, 5, 4, 0.62));
}

body.theme-lava.battle-paused #hub-menu {
  background:
    radial-gradient(ellipse at 50% 22%, rgba(255, 92, 28, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(42, 10, 6, 0.34), rgba(16, 5, 4, 0.62));
}

body.theme-tree #intro-menu,
body.theme-tree #hub-menu,
body.theme-tree #how-overlay,
body.theme-tree #match-setup,
body.theme-tree.battle-paused #hub-menu {
  background:
    radial-gradient(ellipse at 50% 22%, rgba(120, 160, 60, 0.16), transparent 52%),
    linear-gradient(180deg, rgba(12, 22, 8, 0.34), rgba(8, 14, 6, 0.62));
}

body.theme-ocean #intro-menu,
body.theme-ocean #hub-menu,
body.theme-ocean #how-overlay,
body.theme-ocean #match-setup,
body.theme-ocean.battle-paused #hub-menu {
  background:
    radial-gradient(ellipse at 50% 22%, rgba(255, 140, 60, 0.16), transparent 52%),
    linear-gradient(180deg, rgba(28, 12, 28, 0.34), rgba(12, 8, 24, 0.62));
}

body.theme-desert #intro-menu,
body.theme-desert #hub-menu,
body.theme-desert #how-overlay,
body.theme-desert #match-setup,
body.theme-desert.battle-paused #hub-menu {
  background:
    radial-gradient(ellipse at 50% 22%, rgba(232, 140, 48, 0.18), transparent 52%),
    linear-gradient(180deg, rgba(48, 22, 8, 0.34), rgba(22, 10, 4, 0.62));
}

#hub-menu h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.45rem, 5.4vw, 1.95rem);
}

#hub-menu .hub-tribe {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 3.6vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: none;
  color: var(--gold);
  -webkit-text-fill-color: var(--gold);
  text-shadow: 0 1px 0 #3a2a10, 0 0 10px rgba(226, 192, 118, 0.35);
  animation: gold-glow 5.6s ease-in-out infinite;
}

#hub-menu .hub-tribe[hidden] {
  display: none;
}

.build-ver {
  margin: -0.2rem 0 0.85rem;
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: rgba(226, 194, 120, 0.78);
}

#btn-campaign.is-march {
  animation: march-cue 1.35s ease-out 1;
}

@keyframes march-cue {
  0% { box-shadow: 0 0 0 0 rgba(226, 180, 74, 0); }
  40% { box-shadow: 0 0 0 3px rgba(226, 180, 74, 0.9); }
  100% { box-shadow: 0 0 0 0 rgba(226, 180, 74, 0); }
}

.hub-bank {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.7rem, env(safe-area-inset-left));
  z-index: 3;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  padding: 0.42rem 0.72rem 0.48rem;
  background: rgba(10, 7, 5, 0.78);
  border: 1px solid #c4a05a;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 0 0 1px #3a2410;
  pointer-events: none;
}
.hub-bank[hidden] { display: none; }
#btn-continue-last {
  position: absolute;
  top: max(0.65rem, env(safe-area-inset-top));
  right: max(0.7rem, env(safe-area-inset-right));
  z-index: 4;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.06rem;
  min-height: 44px;
  padding: 0.38rem 0.72rem 0.42rem;
  background: rgba(10, 7, 5, 0.84);
  border: 1px solid #c4a05a;
  border-radius: 2px;
  color: #f6e2a8;
  -webkit-text-fill-color: #f6e2a8;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1.05;
  box-shadow:
    inset 0 0 0 1px #3a2410,
    0 6px 16px rgba(0, 0, 0, 0.45),
    0 0 10px rgba(226, 192, 118, 0.35);
  animation: continue-glow 2.6s ease-in-out infinite;
}
#btn-continue-last[hidden] { display: none; }
#btn-continue-last span {
  display: block;
}
#btn-continue-last span:first-child {
  font-size: 0.72rem;
  font-weight: 700;
}
#btn-continue-last span:last-child {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: #e8c878;
  -webkit-text-fill-color: #e8c878;
}
@keyframes continue-glow {
  0%, 100% {
    box-shadow:
      inset 0 0 0 1px #3a2410,
      0 6px 16px rgba(0, 0, 0, 0.45),
      0 0 8px rgba(226, 192, 118, 0.28);
    border-color: #c4a05a;
  }
  50% {
    box-shadow:
      inset 0 0 0 1px #6a4a18,
      0 6px 16px rgba(0, 0, 0, 0.45),
      0 0 18px rgba(255, 214, 120, 0.75);
    border-color: #ffe0a0;
  }
}
.hub-bank-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #e8c878;
}
.hub-bank-amount {
  display: flex;
  align-items: center;
  gap: 0.38rem;
}
.hub-bank .inherit-gem {
  width: 0.92rem;
  height: 1.02rem;
  flex: 0 0 auto;
}
#hub-bank-value {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: #f6e2a8;
  text-shadow: 0 0 8px rgba(226, 192, 118, 0.4);
}

.name-plaque {
  width: min(22.5rem, calc(100vw - 1.6rem));
  padding: 1.15rem 1.2rem 1.2rem;
  background:
    radial-gradient(ellipse at 50% 0%, #f3e2bc, #d4b882 55%, #b89458);
  border: 3px solid #5a3a14;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.5),
    inset 0 0 0 2px #e2c07688,
    inset 0 0 0 6px #6a4420;
  text-align: center;
  color: #1f120a;
}
.name-plaque .eyebrow {
  margin: 0 0 0.3rem;
  color: #6a4420;
  letter-spacing: 0.22em;
}
.name-plaque h1 {
  margin: 0 0 0.85rem;
  color: #1a1008;
  font-size: clamp(1.2rem, 4.4vw, 1.55rem);
}
.name-plaque input {
  width: 100%;
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid #6a4420;
  background: #f7ecd0;
  color: #1a1008;
  font-family: var(--font-display);
  font-size: 1rem;
  text-align: center;
}
#btn-name-confirm:disabled {
  opacity: 0.38;
  pointer-events: none;
  filter: grayscale(0.35);
}

#hub-menu .actions {
  gap: 0.5rem;
}

#hub-menu .panel {
  max-height: 100%;
  overflow: auto;
}

.panel {
  width: min(28rem, 100%);
  padding: 1.75rem 1.4rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.5),
    0 18px 50px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(226, 192, 118, 0.18);
  text-align: center;
}

.eyebrow {
  margin: 0 0 0.35rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--gold);
}

h1 {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 6vw, 2.15rem);
  line-height: 1.15;
  text-wrap: balance;
  color: var(--ink);
  text-shadow: 0 2px 0 #000, 0 0 24px rgba(226, 192, 118, 0.22);
}

#intro-menu .eyebrow {
  display: inline-block;
  color: var(--gold);
  -webkit-text-fill-color: var(--gold);
  animation: gold-glow 5.6s ease-in-out infinite;
}

@keyframes gold-shimmer {
  0%, 22% { background-position: 100% 50%; }
  48% { background-position: -10% 50%; }
  70%, 100% { background-position: 100% 50%; }
}

@keyframes gold-glow {
  0%, 22% { text-shadow: 0 0 0 transparent; }
  48% { text-shadow: 0 0 12px rgba(226, 192, 118, 0.5); }
  70%, 100% { text-shadow: 0 0 0 transparent; }
}

.tag {
  margin: 0.55rem 0 0.95rem;
  color: var(--ink-dim);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.audio-controls {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.15rem 0 0.1rem;
  text-align: left;
}

.audio-row {
  display: grid;
  grid-template-columns: 4.6rem 1fr;
  align-items: center;
  gap: 0.45rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.audio-row input[type="range"] {
  width: 100%;
  height: 1.6rem;
  margin: 0;
  accent-color: #e2c076;
  background: transparent;
  cursor: pointer;
}

button {
  -webkit-appearance: none;
  appearance: none;
  color-scheme: light;
  border: 1px solid var(--gold-deep);
  border-radius: var(--radius-btn);
  background: #2c1a0c;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  min-height: 44px;
  padding: 0.85rem 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform var(--motion-fast) var(--ease-out),
    opacity var(--motion-fast) var(--ease-out),
    box-shadow var(--motion-fast) var(--ease-out),
    border-color var(--motion-fast) var(--ease-out);
}

button:disabled {
  opacity: 0.45;
  cursor: wait;
}

button:not(:disabled):active {
  transform: scale(0.98);
}

button.ghost {
  background: transparent;
  border-color: var(--line);
}

button.is-press,
button.is-press:active {
  transform: scale(1.04);
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 18px rgba(226, 192, 118, 0.55);
}

#boot-status {
  margin: 0.9rem 0 0;
  min-height: 1.2em;
  font-size: 0.8rem;
  color: var(--ink-dim);
}

#boot-status[hidden] {
  display: none;
}

#name-overlay,
#later-overlay,
#continue-overlay,
#settings-overlay {
  z-index: 30;
  background: #060403;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-out), visibility var(--motion-fast) var(--ease-out);
}

#how-overlay,
#match-setup {
  z-index: 30;
  background:
    radial-gradient(ellipse at 50% 18%, rgba(226, 192, 118, 0.1), transparent 48%),
    linear-gradient(180deg, rgba(10, 7, 5, 0.42), rgba(8, 5, 4, 0.7));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-out), visibility var(--motion-fast) var(--ease-out);
}

#how-overlay.is-open,
#name-overlay.is-open,
#later-overlay.is-open,
#continue-overlay.is-open,
#settings-overlay.is-open,
#match-setup.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body:has(#how-overlay.is-open) #intro-menu {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body:has(#name-overlay.is-open) #hub-menu,
body:has(#later-overlay.is-open) #hub-menu,
body:has(#continue-overlay.is-open) #hub-menu,
body:has(#settings-overlay.is-open) #hub-menu,
body:has(#match-setup.is-open) #hub-menu,
body:has(#campaign-map.is-open) #hub-menu,
body:has(#reward-store.is-open) #hub-menu {
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#tribe-name-input {
  display: block;
  width: 100%;
  margin: 0 0 1rem;
  min-height: 44px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: rgba(8, 5, 4, 0.72);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.06em;
  text-align: center;
  touch-action: manipulation;
}

#tribe-name-input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-color: var(--gold);
}

#tribe-name-input::placeholder {
  color: var(--ink-dim);
  opacity: 0.8;
}

.name-actions {
  margin-top: 0.15rem;
}

.how-copy {
  margin: 0 0 1rem;
  text-align: left;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.how-copy p { margin: 0 0 0.75rem; }

#reset-camera,
#btn-menu,
#btn-gear,
#btn-help {
  position: fixed;
  z-index: 12;
  top: max(0.7rem, env(safe-area-inset-top));
  min-height: 44px;
  padding: 0.45rem 0.7rem;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  background: rgba(20, 12, 8, 0.72);
  border: 1px solid var(--line);
  pointer-events: auto;
}

#reset-camera {
  right: max(0.7rem, env(safe-area-inset-right));
  width: 3.05rem;
  min-width: 3.05rem;
  min-height: 52px;
  padding: 0.38rem 0.22rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  line-height: 1.12;
  text-align: center;
  white-space: normal;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}

#btn-menu {
  left: max(0.7rem, env(safe-area-inset-left));
}

#btn-gear {
  left: max(0.7rem, env(safe-area-inset-left));
  top: calc(max(0.7rem, env(safe-area-inset-top)) + 3.35rem);
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
  color: #f8e7b4;
}
#btn-gear svg {
  display: block;
  width: 1.2rem;
  height: 1.2rem;
}

#gear-pop {
  position: fixed;
  z-index: 16;
  top: calc(max(0.7rem, env(safe-area-inset-top)) + 6.55rem);
  left: max(0.7rem, env(safe-area-inset-left));
  width: min(16rem, calc(100vw - 1.4rem));
  padding: 0.7rem 0.8rem 0.8rem;
  background: rgba(16, 10, 7, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 14px 36px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  text-align: left;
}

#gear-pop .eyebrow {
  margin-bottom: 0.4rem;
}

#gear-pop [data-audio="mute"][aria-pressed="true"],
#audio-mute[aria-pressed="true"] {
  background: #5a3a12;
  color: #f8e7b4;
}

#btn-help {
  right: max(0.7rem, env(safe-area-inset-right));
  top: calc(max(0.7rem, env(safe-area-inset-top)) + 3.85rem);
  width: 3.05rem;
  min-width: 3.05rem;
  min-height: 3.05rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  color: #f8e7b4;
  border-radius: var(--radius-btn);
}

#reset-camera[hidden],
#btn-menu[hidden],
#btn-gear[hidden],
#gear-pop[hidden],
#btn-help[hidden],
#slice2-note[hidden],
#turn-bar[hidden],
#card-chip[hidden],
#btn-end-turn[hidden],
#pass-cover[hidden],
#win-overlay[hidden],
#eclipse-title[hidden],
#upgrade-sheet[hidden],
#turn-tip[hidden],
#hand-hud[hidden] { display: none; }

#turn-bar {
  position: fixed;
  z-index: 12;
  top: max(0.7rem, env(safe-area-inset-top));
  left: max(4.6rem, calc(env(safe-area-inset-left) + 3.9rem));
  right: max(4.2rem, calc(env(safe-area-inset-right) + 3.5rem));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  margin: 0;
  padding: 0.32rem 0.7rem 0.36rem;
  font-family: var(--font-display);
  color: var(--ink);
  background: rgba(16, 10, 7, 0.82);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  pointer-events: none;
}
#turn-who {
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#turn-scores {
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#pass-cover {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(1.25rem, env(safe-area-inset-top)) 1.25rem max(1.25rem, env(safe-area-inset-bottom));
  background: rgba(8, 5, 4, 0.92);
}
.pass-panel {
  width: min(22rem, 100%);
  padding: 1.6rem 1.3rem 1.4rem;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}
#pass-to {
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
#btn-iam {
  min-width: 8rem;
}

#win-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: #050301;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}
#win-overlay.is-in {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  visibility: visible !important;
  z-index: 100 !important;
  animation: winFadeIn 0.7s ease-out both;
}
#win-overlay.is-out {
  animation: winFadeOut 0.48s ease-in both;
  pointer-events: none;
}
.win-bloom {
  position: absolute;
  inset: -12%;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(255, 210, 96, 0.38), transparent 42%),
    radial-gradient(ellipse at 50% 80%, rgba(180, 90, 20, 0.28), transparent 55%);
  animation: winBloom 3.6s ease-in-out infinite;
  pointer-events: none;
}
.win-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.win-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 46%;
  transform: scale(1.1);
  filter: saturate(1.08) contrast(1.05);
  animation: winArtIn 1.15s cubic-bezier(0.16, 1, 0.3, 1) both;
  pointer-events: none;
}
#win-overlay.is-in .win-art {
  transform: scale(1);
}
#win-overlay.has-payout #win-title {
  bottom: 40%;
}
#win-true-warrior {
  position: absolute;
  left: 50%;
  bottom: 33%;
  z-index: 2;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 3.2vw, 1.55rem);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #ffb040;
  text-shadow:
    0 0 8px #ff6a18,
    0 0 18px #ff4010,
    0 2px 0 #3a0800;
  animation: trueWarriorFire 1.6s ease-in-out infinite;
}
#win-true-warrior[hidden] { display: none; }
@keyframes trueWarriorFire {
  0%, 100% { filter: brightness(1); text-shadow: 0 0 8px #ff6a18, 0 0 18px #ff4010, 0 2px 0 #3a0800; }
  50% { filter: brightness(1.25); text-shadow: 0 0 14px #ffd080, 0 0 28px #ff5018, 0 2px 0 #3a0800; }
}
#win-payout {
  position: absolute;
  left: 50%;
  bottom: max(5.6rem, calc(env(safe-area-inset-bottom) + 4.4rem));
  z-index: 3;
  width: min(17.5rem, calc(100vw - 1.6rem));
  transform: translateX(-50%);
  padding: 0.55rem 0.75rem 0.6rem;
  background: rgba(10, 8, 5, 0.82);
  border: 1px solid #c4a05a;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55), inset 0 0 0 1px #2a1c0c;
  color: #f0d48a;
  font-family: var(--font-ui);
  animation: winTitleIn 0.8s 0.45s ease both;
}
#win-payout[hidden] { display: none; }
.pay-line {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  padding: 0.12rem 0;
}
.pay-line b { font-family: var(--font-display); color: #f6e2a8; }
.pay-note {
  margin: 0.15rem 0 0.25rem;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: #c4a05a;
}
.pay-negate {
  margin: 0.35rem 0 0.15rem;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  line-height: 1.35;
  color: #e8c878;
}
.pay-bonus b { color: #ffc878; }
.pay-total {
  margin-top: 0.28rem;
  padding-top: 0.28rem;
  border-top: 1px solid #8a6428;
  font-weight: 700;
}
.pay-total b { font-size: 1.05rem; color: #ffe7a8; }
#win-title {
  position: absolute;
  left: 50%;
  bottom: 27%;
  z-index: 2;
  margin: 0;
  padding: 0.42rem 1.55rem 0.48rem;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.6vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--win-tribe, #f3d48a);
  background: #0a0806;
  border: 1px solid #2a2418;
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px #16120c;
  text-shadow:
    0 0 10px rgba(255, 210, 110, 0.55),
    0 1px 2px #000;
  animation: winTitleIn 1s 0.35s ease both;
}
#btn-win-hub {
  position: absolute;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 3;
  transform: translateX(-50%);
  min-width: 12.5rem;
  padding: 0.78rem 1.5rem 0.86rem;
  font-family: var(--font-display);
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f8e7b4;
  background:
    linear-gradient(180deg, #6a4a1c 0%, #3a240c 55%, #1c1006 100%);
  border: 1px solid #e2c076;
  border-radius: 999px;
  box-shadow:
    0 0 0 1px #8a6418,
    0 0 18px rgba(232, 176, 64, 0.45),
    0 8px 22px rgba(0, 0, 0, 0.55);
  animation: winBtnIn 0.7s 0.7s ease both, winBtnGlow 2.4s 1.2s ease-in-out infinite;
}
#btn-win-hub::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: inherit;
  border: 1px solid rgba(255, 220, 140, 0.55);
  box-shadow: 0 0 16px rgba(255, 200, 80, 0.55);
  opacity: 0.55;
  pointer-events: none;
  animation: winBtnRing 2.4s ease-in-out infinite;
}
#btn-win-hub:hover,
#btn-win-hub:focus-visible {
  color: #fff6d2;
  filter: brightness(1.08);
}
@keyframes winFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes winFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes winArtIn {
  from { opacity: 0; transform: scale(1.18); filter: brightness(0.4) saturate(0.8); }
  to { opacity: 1; transform: scale(1); filter: saturate(1.08) contrast(1.05); }
}
@keyframes winBloom {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
@keyframes winTitleIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); letter-spacing: 0.5em; }
  to { opacity: 1; transform: translateX(-50%); }
}
@keyframes winBtnIn {
  from { opacity: 0; transform: translateX(-50%) translateY(18px) scale(0.92); }
  to { opacity: 1; transform: translateX(-50%); }
}
@keyframes winBtnGlow {
  0%, 100% { box-shadow: 0 0 0 1px #8a6418, 0 0 16px rgba(232, 176, 64, 0.4), 0 8px 22px rgba(0,0,0,0.55); }
  50% { box-shadow: 0 0 0 1px #f0d078, 0 0 28px rgba(255, 210, 90, 0.85), 0 8px 22px rgba(0,0,0,0.55); }
}
@keyframes winBtnRing {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.045); }
}

#brother-toast {
  position: fixed;
  left: 50%;
  top: 16%;
  z-index: 60;
  margin: 0;
  padding: 0.75rem 1.15rem;
  border: 1px solid #e2c076;
  border-radius: 0.35rem;
  background: rgba(16, 10, 5, 0.92);
  color: #ffe7a8;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-align: center;
  box-shadow: 0 0 18px rgba(226, 192, 118, 0.72);
  pointer-events: none;
}
#brother-toast[hidden] { display: none; }
#brother-toast.is-on { animation: brother-toast 1.6s ease forwards; }
@keyframes brother-toast {
  0% { opacity: 0; transform: translateX(-50%) scale(0.96); }
  10% { opacity: 1; transform: translateX(calc(-50% - 5px)) scale(1); }
  22% { transform: translateX(calc(-50% + 5px)); }
  34% { transform: translateX(-50%); }
  72% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%); }
}

#mount-card-pop {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
#mount-card-pop[hidden] { display: none; }
.mount-card-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: min(92vw, 28rem);
  padding: 0 1rem;
}
.mount-card-face {
  width: min(46vh, 15.5rem);
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 0.65rem;
  border: 2px solid #f0d48a;
  background: #100c08;
  box-shadow:
    0 0 0 1px #6e4c16,
    0 0 22px rgba(255, 206, 96, 0.72),
    0 16px 36px rgba(0, 0, 0, 0.55);
}
.mount-card-line {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(0.95rem, 2.4vw, 1.2rem);
  line-height: 1.45;
  color: #ffe7a8;
  letter-spacing: 0.03em;
  text-shadow: 0 0 10px rgba(255, 210, 120, 0.55);
}
#mount-card-pop.is-on:not(.is-out) .mount-card-face {
  animation: mountCardIn 0.4s cubic-bezier(.2, .85, .2, 1) both, mountGlow 0.9s ease-in-out 0.4s 3;
}
#mount-card-pop.is-on .mount-card-line span {
  display: inline-block;
  margin: 0 0.16em;
  opacity: 0;
  animation: mountWord 0.42s ease forwards;
}
#mount-card-pop.is-on:not(.is-out) .mount-card-line {
  animation: mountLineGlow 0.9s ease-in-out var(--mount-glow-delay, 1.1s) 2;
}
#mount-card-pop.is-out .mount-card-stage {
  animation: mountShakeOut 0.7s ease forwards;
}
@keyframes mountCardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.86); }
  to { opacity: 1; transform: none; }
}
@keyframes mountGlow {
  0%, 100% {
    box-shadow: 0 0 0 1px #8a6420, 0 0 16px rgba(232, 176, 64, 0.45), 0 16px 36px rgba(0, 0, 0, 0.55);
  }
  50% {
    box-shadow:
      0 0 0 2px #ffe7b0,
      0 0 36px rgba(255, 214, 110, 0.95),
      0 0 64px rgba(232, 176, 64, 0.45),
      0 16px 36px rgba(0, 0, 0, 0.55);
  }
}
@keyframes mountWord {
  0% { opacity: 0; transform: translateY(8px); filter: brightness(2.2); }
  60% { opacity: 1; transform: none; text-shadow: 0 0 14px #fff1c4, 0 0 26px rgba(232, 176, 64, 0.85); }
  100% { opacity: 1; transform: none; filter: none; }
}
@keyframes mountLineGlow {
  0%, 100% { text-shadow: 0 0 8px rgba(255, 210, 120, 0.4); }
  50% { color: #fff8dc; text-shadow: 0 0 16px #fff1c4, 0 0 34px rgba(255, 196, 70, 0.9); }
}
@keyframes mountShakeOut {
  0% { transform: translateX(0); opacity: 1; }
  14% { transform: translateX(-9px) rotate(-1.2deg); }
  28% { transform: translateX(9px) rotate(1.2deg); }
  42% { transform: translateX(-6px) rotate(-0.8deg); }
  56% { transform: translateX(5px) rotate(0.6deg); }
  70% { transform: translateX(0); opacity: 1; }
  100% { transform: translateY(18px) scale(0.92); opacity: 0; }
}

#eclipse-title {
  position: fixed;
  inset: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  pointer-events: none;
  opacity: 0;
}
#eclipse-title .ecl-mark {
  position: absolute;
  width: 6.4rem;
  height: 6.4rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 38%, #0b0806 0 42%, transparent 44%),
    radial-gradient(circle at 50% 50%, #e07820 52%, #c45a18 60%, transparent 64%);
  box-shadow: 0 0 40px rgba(224, 120, 32, 0.45);
  opacity: 0.85;
}
#eclipse-title .ecl-text {
  position: relative;
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3.2rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(224, 120, 32, 0.55);
  text-align: center;
}
#eclipse-title.is-great .ecl-mark {
  width: min(18rem, 70vw);
  height: min(18rem, 70vw);
  animation: eclReveal 1.15s var(--ease-out) both;
}
#eclipse-title.is-great .ecl-text {
  font-size: clamp(2.4rem, 9vw, 4.4rem);
  letter-spacing: 0.14em;
  background: linear-gradient(100deg, #8a6230 0%, #f8ecd0 28%, #e2c076 50%, #c9a227 72%, #8a6230 100%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 18px rgba(224, 120, 32, 0.55));
  animation: gildSweep 1.8s ease-in-out infinite;
}
#eclipse-title.is-in {
  animation: eclipseIn 420ms var(--ease-out) forwards;
}
#eclipse-title.is-out {
  animation: eclipseOut 420ms ease-in forwards;
}
@keyframes eclipseIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes eclipseOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes gildSweep {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
@keyframes eclReveal {
  0% { transform: scale(0.2) rotate(-25deg); opacity: 0; }
  45% { transform: scale(1.12) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 0.55; }
}

#upgrade-sheet {
  position: fixed;
  inset: 0;
  z-index: 16;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 4, 3, 0.72);
  pointer-events: auto;
  opacity: 1;
  transition: opacity 420ms var(--ease-out);
}
#upgrade-sheet.is-out {
  opacity: 0;
  pointer-events: none;
}
.upgrade-stage {
  position: relative;
  width: min(100vw, calc(100vh * 1792 / 1008));
  height: min(100vh, calc(100vw * 1008 / 1792));
  max-width: 100%;
  max-height: 100%;
}
.upgrade-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.upgrade-ip-row {
  position: absolute;
  left: 22%;
  right: 22%;
  top: 20.5%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
  z-index: 2;
  pointer-events: none;
}
.up-ip {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.12rem 0.4rem 0.12rem 0.22rem;
  background: rgba(12, 8, 5, 0.55);
  border: 1px solid rgba(226, 192, 118, 0.28);
  border-radius: 999px;
  color: #f3e6c8;
  font-family: var(--font-display);
  font-size: clamp(0.62rem, 1.5vw, 0.85rem);
  letter-spacing: 0.06em;
}
.up-ip.is-turn {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(226, 192, 118, 0.45);
}
.up-gem {
  width: 0.72rem;
  height: 0.72rem;
  display: block;
  transform: rotate(45deg);
  background:
    linear-gradient(135deg, #fff3c4, var(--gem, #e2c076) 40%, #7a4a10);
  box-shadow: 0 0 6px var(--gem, #e2c076);
  flex: 0 0 auto;
}
.up-ip b { font-weight: 700; color: var(--gold); }
.up-ip em {
  font-style: normal;
  opacity: 0.82;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78em;
}
.upgrade-list {
  position: absolute;
  inset: 0;
  margin: 0;
  pointer-events: none;
}
.up-pane {
  position: absolute;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  min-width: 0;
  min-height: 0;
  pointer-events: auto;
  overflow: hidden;
  border-radius: 0.35rem;
}
.up-pane::before {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  top: 22%;
  bottom: 6%;
  border-radius: 50%;
  background: transparent;
  box-shadow:
    0 0 10px 2px rgba(255, 226, 170, 0.16),
    inset 0 0 14px rgba(255, 220, 150, 0.1);
  pointer-events: none;
  z-index: 0;
}
.up-step   { left: 7.2%;  top: 30.0%; width: 11.0%; height: 31.2%; }
.up-bishop { left: 26.5%; top: 30.0%; width: 10.8%; height: 31.2%; }
.up-knight { left: 45.3%; top: 30.0%; width: 10.8%; height: 31.2%; }
.up-rook   { left: 64.0%; top: 30.0%; width: 10.8%; height: 31.2%; }
.up-queen  { left: 82.6%; top: 30.0%; width: 11.0%; height: 31.2%; }
.upgrade-preview {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  pointer-events: none;
  filter: drop-shadow(0 0 7px rgba(255, 224, 160, 0.42));
}
.up-pane.is-dim { opacity: 0.42; filter: grayscale(0.35); }
.up-pane.is-owned {
  box-shadow: inset 0 0 0 2px #e2c076, 0 0 16px rgba(226, 192, 118, 0.4);
}
.up-pane.is-shake { animation: upShake 280ms ease-in-out; }
@keyframes upShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
#move-picker {
  position: fixed;
  inset: 0;
  z-index: 46;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 5, 3, 0.62);
}
#move-picker[hidden] { display: none; }
.move-panel { width: min(96vw, 720px); }
.move-banner {
  display: block;
  width: min(92%, 520px);
  height: auto;
  margin: 0 auto 0.35rem;
  pointer-events: none;
}
.move-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.15rem;
}
.move-row button {
  position: relative;
  width: 19%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
}
.move-row button img {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.move-row canvas {
  position: absolute;
  z-index: 0;
  left: 18%;
  top: 8%;
  width: 64%;
  height: 54%;
  pointer-events: none;
  background: transparent;
}
.move-row button.is-chosen {
  animation: move-shake 0.34s linear;
  filter: drop-shadow(0 0 8px rgba(255, 214, 120, 0.95)) drop-shadow(0 0 16px rgba(226, 160, 60, 0.65));
}
@keyframes move-shake {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-4px) rotate(-1.1deg); }
  50% { transform: translateX(4px) rotate(1.1deg); }
  75% { transform: translateX(-2px) rotate(-0.4deg); }
}
#btn-upgrade-skip {
  position: absolute;
  left: 37.6%;
  top: 83.2%;
  width: 24.8%;
  height: 8.4%;
  min-width: 0;
  min-height: 0;
  padding: 0.15rem 0.55rem 0.2rem;
  margin: 0;
  display: grid;
  place-items: center;
  border: 2px solid #1a0c04;
  border-radius: 0.55rem;
  background:
    radial-gradient(ellipse at 50% 12%, rgba(226, 192, 118, 0.28), transparent 46%),
    repeating-linear-gradient(92deg, rgba(42, 22, 8, 0.18) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, #7a5228 0%, #5a3618 38%, #3a220e 72%, #2a160a 100%);
  color: #d8b878;
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 1.9vw, 1.12rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow:
    0 1px 0 rgba(255, 230, 180, 0.42),
    0 -1px 0 rgba(20, 8, 0, 0.78),
    0 2px 2px rgba(0, 0, 0, 0.45);
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 170, 0.38),
    inset 0 -3px 6px rgba(0, 0, 0, 0.45),
    0 0 0 1px #c4a056,
    0 6px 12px rgba(0, 0, 0, 0.45);
  z-index: 2;
}
#btn-upgrade-skip span {
  pointer-events: none;
  display: block;
  line-height: 1;
  transform: translateY(0.04em);
}
#btn-upgrade-skip.is-press,
#btn-upgrade-skip:active {
  transform: scale(1.04);
  color: #fff0c8;
  border-color: #e2c076;
  box-shadow:
    inset 0 1px 0 rgba(255, 240, 200, 0.5),
    0 0 0 2px #e2c076,
    0 0 18px rgba(226, 192, 118, 0.7);
}
@media (max-width: 640px) {
  .upgrade-ip-row { gap: 0.35rem; top: 20%; }
  .up-ip em { display: none; }
  #btn-upgrade-skip { letter-spacing: 0.12em; font-size: 0.78rem; }
}

#card-chip {
  display: none !important;
}

#hand-hud {
  position: fixed;
  z-index: 14;
  left: 0;
  right: 0;
  bottom: 0;
  height: min(22vh, 10.4rem);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0.4rem var(--hud-baseline);
  background: linear-gradient(to top, rgba(8, 5, 4, 0.7) 0%, rgba(8, 5, 4, 0.18) 38%, transparent 100%);
  pointer-events: none;
}
#draw-well {
  position: absolute;
  left: max(0.7rem, calc(env(safe-area-inset-left) + 0.3rem));
  bottom: calc(var(--hud-baseline) + 0.75rem);
  width: var(--hud-ctrl);
  height: var(--hud-ctrl);
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 2;
}
#draw-pile {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  display: block;
}
#draw-pile:disabled {
  opacity: 0.45;
}
.pile-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 0.45rem);
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 1px 4px #000;
  line-height: 1;
  white-space: nowrap;
  z-index: 3;
  pointer-events: none;
}
#draw-pile.can-draw .pile-label {
  color: var(--gold);
}
.pile-3d {
  width: 100%;
  height: 100%;
  perspective: 720px;
  perspective-origin: 50% 78%;
  padding-bottom: 0;
  overflow: visible;
}
.pile-body {
  position: relative;
  display: block;
  width: 92%;
  margin: 0 auto;
  aspect-ratio: 5 / 7;
  transform-style: preserve-3d;
  transform: rotateX(54deg) rotateZ(-16deg) translate(10%, 10%) scale(0.92) translateZ(18px);
  box-shadow: 0 14px 12px rgba(0, 0, 0, 0.45);
}
#draw-pile.is-shuffling .pile-body {
  animation: pile-shuffle 0.72s ease;
}
#draw-pile.is-shuffling .pile-body i {
  animation: layer-riffle 0.72s ease;
}
@keyframes pile-shuffle {
  0% { transform: rotateX(54deg) rotateZ(-16deg) translate(10%, 10%) scale(0.92) translateZ(18px); }
  22% { transform: rotateX(18deg) rotateZ(28deg) translate(10%, -4%) scale(0.96) translateZ(18px); }
  48% { transform: rotateX(62deg) rotateZ(-38deg) translate(10%, 18%) scale(0.9) translateZ(18px); }
  72% { transform: rotateX(40deg) rotateZ(12deg) translate(10%, 4%) scale(0.94) translateZ(18px); }
  100% { transform: rotateX(54deg) rotateZ(-16deg) translate(10%, 10%) scale(0.92) translateZ(18px); }
}
@keyframes layer-riffle {
  0%, 100% { opacity: 1; }
  40% { opacity: 0.55; }
}
.pile-body i {
  position: absolute;
  inset: 0;
  border-radius: 5px;
  background:
    linear-gradient(90deg, #1a1008 0%, #4a3218 38%, #2a1a0c 100%);
  border: 1px solid #6e4e22;
  box-shadow: inset 0 0 0 1px rgba(210, 170, 80, 0.18);
}
.pile-body i:nth-child(1) { transform: translate3d(0, 14px, -20px); }
.pile-body i:nth-child(2) { transform: translate3d(0, 12px, -17px); }
.pile-body i:nth-child(3) { transform: translate3d(0, 10px, -14px); }
.pile-body i:nth-child(4) { transform: translate3d(0, 8px, -11px); }
.pile-body i:nth-child(5) { transform: translate3d(0, 6px, -8px); }
.pile-body i:nth-child(6) { transform: translate3d(0, 4px, -5px); }
.pile-body i:nth-child(7) { transform: translate3d(0, 2px, -3px); }
.pile-body i:nth-child(8) { transform: translate3d(0, 1px, -1px); }
.pile-top {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 5px;
  border: 1px solid #d4b56a;
  transform: translate3d(0, 0, 2px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  image-rendering: -webkit-optimize-contrast;
  box-shadow: 0 0 6px rgba(226, 192, 118, 0.18);
}
#draw-pile.can-draw .pile-top {
  box-shadow: 0 0 8px rgba(255, 220, 120, 0.35), 0 0 12px rgba(226, 192, 118, 0.18);
  animation: pile-hint 2.2s ease-in-out infinite;
}
@keyframes pile-hint {
  0%, 100% { box-shadow: 0 0 5px rgba(226, 192, 118, 0.16); }
  50% { box-shadow: 0 0 10px rgba(255, 220, 120, 0.4), 0 0 16px rgba(226, 192, 118, 0.22); }
}
@keyframes draw-glow {
  0%, 100% {
    color: #e2c076;
    text-shadow: 0 0 4px #9a7430, 0 0 10px rgba(226, 192, 118, 0.55);
  }
  50% {
    color: #fff6d4;
    text-shadow: 0 0 8px #ffe9a0, 0 0 18px #e2c076, 0 0 28px rgba(255, 210, 110, 0.7);
  }
}
.pile-count { display: none !important; }

#btn-deploy,
#btn-deploy-left {
  position: absolute;
  right: max(0.4rem, env(safe-area-inset-right));
  bottom: var(--hud-baseline);
  width: var(--hud-ctrl);
  height: var(--hud-ctrl);
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  display: block;
}
#btn-deploy-left {
  right: calc(max(0.4rem, env(safe-area-inset-right)) + var(--hud-ctrl) + 0.55rem);
}
#btn-deploy[hidden],
#btn-deploy-left[hidden] { display: none !important; }
.deploy-seal {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.5));
}
.deploy-seal img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 50%;
  pointer-events: none;
}
.deploy-seal::after {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  pointer-events: none;
  box-shadow:
    0 0 0 1.5px rgba(226, 192, 118, 0.42),
    0 0 6px rgba(226, 192, 118, 0.22);
}
.deploy-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.28rem);
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 1px 4px #000;
  line-height: 1;
  margin: 0;
  white-space: nowrap;
  pointer-events: none;
}
#btn-deploy.can-act .deploy-seal,
#btn-deploy-left.can-act .deploy-seal {
  animation: deploy-hint 1.8s ease-in-out infinite;
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45));
}
#btn-deploy.can-act .deploy-seal::after,
#btn-deploy-left.can-act .deploy-seal::after {
  animation: deploy-rim 1.8s ease-in-out infinite;
}
#btn-deploy:disabled,
#btn-deploy.is-dim,
#btn-deploy-left:disabled,
#btn-deploy-left.is-dim {
  opacity: 0.45;
  filter: grayscale(0.25);
  pointer-events: none;
}
#btn-deploy:disabled .deploy-seal,
#btn-deploy.is-dim .deploy-seal,
#btn-deploy-left:disabled .deploy-seal,
#btn-deploy-left.is-dim .deploy-seal {
  animation: none;
  filter: none;
}
#btn-deploy:disabled .deploy-seal::after,
#btn-deploy.is-dim .deploy-seal::after,
#btn-deploy-left:disabled .deploy-seal::after,
#btn-deploy-left.is-dim .deploy-seal::after {
  animation: none;
  opacity: 0.35;
}
@keyframes deploy-hint {
  0%, 100% { filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45)); }
  50% { filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 7px rgba(226, 192, 118, 0.4)); }
}
@keyframes deploy-rim {
  0%, 100% {
    box-shadow:
      0 0 0 1.5px rgba(226, 192, 118, 0.38),
      0 0 5px rgba(226, 192, 118, 0.18);
  }
  50% {
    box-shadow:
      0 0 0 2px rgba(255, 228, 160, 0.62),
      0 0 8px rgba(226, 192, 118, 0.38);
  }
}
#btn-deploy.is-shake,
#btn-deploy-left.is-shake,
#hand-fan.is-shake {
  animation: hud-shake 280ms ease;
}
@keyframes hud-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

#battle-stack {
  position: absolute;
  right: max(0.45rem, env(safe-area-inset-right));
  bottom: calc(var(--hud-baseline) + 5.4rem);
  width: clamp(2.6rem, 10vw, 3.6rem);
  padding: 0;
  border: 0;
  background: transparent;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
}
#battle-stack[hidden] { display: none; }
.battle-pile {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  position: relative;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.5));
}
.battle-pile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid #c4a056;
  transform: rotate(-8deg);
}
#battle-count {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 1px 4px #000;
}
#battle-peek {
  position: absolute;
  right: max(0.4rem, env(safe-area-inset-right));
  bottom: calc(var(--hud-baseline) + 8.2rem);
  display: flex;
  gap: 0.2rem;
  pointer-events: none;
  z-index: 16;
}
#battle-peek[hidden] { display: none; }
#battle-peek img {
  width: clamp(2.4rem, 9vw, 3.4rem);
  border-radius: 5px;
  border: 1px solid #c4a056;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45);
}
.held-card.is-best {
  box-shadow: 0 0 0 1px #e2c076, 0 6px 14px rgba(0, 0, 0, 0.45);
}
.held-card.is-addable {
  box-shadow: 0 0 0 2px #e8d08a, 0 0 16px rgba(226, 192, 118, 0.55);
}
.held-card.is-it-ready {
  animation: it-bounce 1.4s ease-in-out infinite;
}
@keyframes it-bounce {
  0%, 100% { transform: translateY(-8px) rotate(var(--rot, 0deg)); }
  50% { transform: translateY(-16px) rotate(var(--rot, 0deg)); }
}
.held-card.is-from-battle {
  box-shadow: 0 0 0 1px #8a6230, 0 6px 14px rgba(0, 0, 0, 0.45);
}

.fly-card {
  position: fixed;
  z-index: 40;
  pointer-events: none;
  border-radius: 6px;
  transform-origin: top left;
  perspective: 900px;
  will-change: transform;
}
.fly-card:not(.is-draw) {
  border: 1px solid #c4a056;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
  object-fit: cover;
  transition: transform 480ms var(--ease-out), opacity 480ms ease;
}
.fly-card.is-draw {
  border: none;
  box-shadow: none;
  background: transparent;
  transform-origin: center center;
}
.fly-spin {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(0deg);
}
.fly-spin img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #c4a056;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.5);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.fly-spin .fly-face {
  transform: rotateY(180deg);
}
.fly-card.is-flat-face .fly-spin {
  transform: none;
  transform-style: flat;
}
.fly-card.is-flat-face .fly-face {
  transform: none;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
}
.fly-card.is-discard {
  border-radius: 6px;
  border: 1px solid #c4a056;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.5);
  object-fit: cover;
  filter: brightness(0.92);
  transition: transform 480ms var(--ease-out), opacity 480ms ease;
}
.held-card.is-arriving {
  opacity: 0;
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  #draw-pile.can-draw .pile-label { animation: none; color: var(--gold); }
  #draw-pile.can-draw .pile-top { animation: none; }
  #draw-pile.is-shuffling .pile-body,
  #draw-pile.is-shuffling .pile-body i { animation: none; }
  #btn-deploy.can-act .deploy-seal,
  #btn-deploy-left.can-act .deploy-seal { animation: none; }
  .held-card.is-it-ready { animation: none; }
  .fly-card { transition: none; }
  .fly-spin { transform: rotateY(180deg); }
}
#hand-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  padding-bottom: 0.15rem;
}
#hand-strength {
  pointer-events: none;
  position: relative;
  z-index: 4;
  margin-top: 0.28rem;
  padding: 0.22rem 0.85rem 0.28rem;
  min-width: 9rem;
  text-align: center;
  color: #3a2a16;
  font-family: var(--font-display);
  font-size: clamp(0.72rem, 2.4vw, 0.92rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background:
    linear-gradient(180deg, #efe3c4 0%, #d8c08a 55%, #c9ad72 100%);
  border: 1px solid #8a6a38;
  border-radius: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 245, 220, 0.7),
    0 2px 0 #6a4e24,
    0 6px 12px rgba(0, 0, 0, 0.35);
}
#hand-strength[hidden] { display: none; }
#hand-strength-text {
  display: block;
}
#hand-fan {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  padding-bottom: 0;
  padding-left: clamp(3.8rem, 14vw, 5.6rem);
  padding-right: clamp(3.8rem, 14vw, 5.6rem);
  margin-bottom: 0.05rem;
}
.held-card {
  width: clamp(3.4rem, 14vw, 5.2rem);
  aspect-ratio: 5 / 7;
  margin: 0 -0.62rem;
  padding: 0;
  border: 1px solid #c4a056;
  border-radius: 7px;
  background: #e8d5a8;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45);
  transform: translateY(-8px) rotate(var(--rot, 0deg));
  transform-origin: 50% 100%;
  pointer-events: auto;
  transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out), opacity 180ms var(--ease-out);
}
.held-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  pointer-events: none;
}
.held-card img.is-pending {
  opacity: 1;
  background: #e8d5a8;
}
.held-card.is-on {
  animation: none;
  transform: translateY(-28px) rotate(var(--rot, 0deg)) scale(1.06);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold), 0 10px 20px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.held-card.is-pickable {
  cursor: pointer;
}
.held-card.is-ace {
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), 0 0 12px rgba(226, 192, 118, 0.35);
}
.held-card.is-inspecting {
  opacity: 0;
  pointer-events: none;
}
#card-inspect {
  position: fixed;
  z-index: 22;
  inset: 0;
  display: block;
  background: rgba(6, 4, 3, 0);
  pointer-events: auto;
  transition: background 420ms var(--ease-out);
}
#card-inspect.is-open {
  background: rgba(6, 4, 3, 0.62);
}
#card-inspect[hidden] { display: none; }
#card-inspect-close {
  position: fixed;
  z-index: 23;
  margin: 0;
  width: auto;
  height: auto;
  min-height: 0;
  padding: 0.28rem;
  border: 1px solid #e2c076;
  border-radius: 10px;
  background:
    linear-gradient(#2a1608, #120804) content-box,
    linear-gradient(180deg, #e2c076, #8a5a18);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px #4a2e10;
}
#card-inspect-close img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  pointer-events: none;
}

/* LOCKED town-1 tip. Centered on the top edge so it does not cover #btn-gear. */
#turn-tip {
  position: fixed;
  z-index: 14;
  top: max(0.65rem, env(safe-area-inset-top));
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  width: min(22rem, calc(100vw - 8.4rem));
  padding: 0.5rem 0.55rem 0.5rem 0.6rem;
  font-size: 0.76rem;
  line-height: 1.35;
  color: #3a2a16;
  background:
    linear-gradient(180deg, #efe0c0, #e2cf9e);
  border: 1px solid #8a6a38;
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
}
#turn-tip p {
  margin: 0;
  flex: 1;
  text-wrap: pretty;
}
.tip-bulb {
  flex: 0 0 1.1rem;
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.12rem;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #fff4c4, #e2b44a 55%, #9a7430);
  box-shadow: 0 0 8px rgba(226, 180, 74, 0.55);
}
#btn-tip-x {
  flex: 0 0 1.6rem;
  min-width: 1.6rem;
  min-height: 1.6rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: #3a2a16;
  background: transparent;
  border: none;
  box-shadow: none;
}

.continue-panel {
  width: min(22rem, 100%);
  text-align: center;
}
.continue-panel h1 {
  margin-bottom: 1rem;
}
#continue-actions[hidden] { display: none; }

#btn-end-turn {
  position: fixed;
  z-index: 15;
  left: 50%;
  bottom: calc(min(22vh, 10.4rem) + 0.55rem);
  transform: translateX(-50%);
  padding: 0.32rem 0.9rem;
  min-height: 36px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

#slice2-note {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: max(0.8rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  background: rgba(20, 12, 8, 0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  pointer-events: none;
  white-space: nowrap;
}

/* Torah scroll — Match Setup (dim overlay over live table, not a black page) */
#match-setup {
  padding-left: max(1.1rem, env(safe-area-inset-left));
  padding-right: max(1.1rem, env(safe-area-inset-right));
  transition: opacity 700ms var(--ease-out), visibility 700ms var(--ease-out);
}

.torah-scroll {
  width: min(26.5rem, calc(100% - 0.4rem));
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 18px 28px rgba(24, 18, 8, 0.55));
}

.scroll-roller {
  width: calc(100% + 1.15rem);
  height: 1.35rem;
  flex: 0 0 auto;
  border-radius: 999px;
  background:
    repeating-linear-gradient(90deg,
      #2a1608 0 6px,
      #4a2a10 6px 8px,
      #1a0c04 8px 10px,
      #5a3414 10px 16px,
      #3a200c 16px 22px,
      #120804 22px 23px,
      #6a4420 23px 28px);
  background-size: 48px 100%;
  border: 1px solid #1a0c04;
  box-shadow:
    inset 0 1px 0 rgba(180, 130, 70, 0.18),
    inset 0 -2px 3px rgba(0, 0, 0, 0.45),
    0 3px 6px rgba(0, 0, 0, 0.5);
  position: relative;
  z-index: 2;
}

.scroll-roller::before,
.scroll-roller::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #c4a06a, #6a3e18 52%, #2a1608 78%, #120804);
  border: 1px solid #1a0c04;
  transform: translateY(-50%);
}

.scroll-roller::before { left: -0.35rem; }
.scroll-roller::after { right: -0.35rem; }

#match-setup.is-open .scroll-roller-top,
#how-overlay.is-open .scroll-roller-top {
  animation: roller-turn 700ms var(--ease-out);
}
#match-setup.is-open .scroll-roller-bot,
#how-overlay.is-open .scroll-roller-bot {
  animation: roller-turn-rev 700ms var(--ease-out);
}
#match-setup.is-closing .scroll-roller-top {
  animation: roller-turn-rev 700ms var(--ease-out);
}
#match-setup.is-closing .scroll-roller-bot {
  animation: roller-turn 700ms var(--ease-out);
}

.scroll-roller.is-twitch {
  animation: roller-twitch 280ms var(--ease-out);
}

@keyframes roller-turn {
  from { background-position: 0 0; }
  to { background-position: 64px 0; }
}
@keyframes roller-turn-rev {
  from { background-position: 64px 0; }
  to { background-position: 0 0; }
}
@keyframes roller-twitch {
  0%, 100% { background-position: 0 0; }
  50% { background-position: 18px 0; }
}

.scroll-clip {
  width: 100%;
  display: grid;
  grid-template-rows: 0fr;
  overflow: hidden;
  margin: -0.2rem 0;
  transition: grid-template-rows 720ms var(--ease-out);
}

#match-setup.is-open .scroll-clip,
#how-overlay.is-open .scroll-clip {
  grid-template-rows: 1fr;
}

#match-setup.is-closing .scroll-clip {
  grid-template-rows: 0fr;
}

.scroll-sheet {
  min-height: 0;
  overflow: hidden;
  position: relative;
  width: 100%;
  padding: 1.35rem 1.85rem 1.5rem;
  color: #2a1a0e;
  color-scheme: light;
  border-left: 1px solid #6a5428;
  border-right: 1px solid #6a5428;
  background-color: #d2bc86;
  background-image:
    radial-gradient(ellipse at 8% 6%, rgba(90, 70, 36, 0.14), transparent 36%),
    radial-gradient(ellipse at 94% 10%, rgba(80, 62, 32, 0.12), transparent 32%),
    radial-gradient(ellipse at 18% 92%, rgba(70, 54, 28, 0.16), transparent 40%),
    radial-gradient(ellipse at 86% 88%, rgba(86, 66, 34, 0.12), transparent 34%),
    radial-gradient(circle at 40% 48%, transparent 55%, rgba(62, 48, 24, 0.14) 100%),
    repeating-linear-gradient(0deg, rgba(62, 48, 24, 0.05) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(93deg, transparent 0 18px, rgba(70, 54, 28, 0.045) 18px 19px),
    linear-gradient(180deg, #d8c490 0%, #cbb57a 42%, #b89a62 78%, #a88854 100%);
  box-shadow:
    inset 18px 0 22px rgba(70, 54, 28, 0.16),
    inset -18px 0 22px rgba(70, 54, 28, 0.16),
    inset 0 12px 18px rgba(62, 48, 24, 0.12),
    inset 0 -14px 20px rgba(50, 38, 18, 0.16);
}

.scroll-sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 22% 30%, rgba(90, 72, 36, 0.12) 0 10px, transparent 22px),
    radial-gradient(circle at 70% 22%, rgba(74, 58, 28, 0.1) 0 8px, transparent 18px),
    radial-gradient(circle at 48% 70%, rgba(86, 66, 34, 0.1) 0 14px, transparent 28px),
    radial-gradient(circle at 12% 62%, rgba(62, 48, 24, 0.12) 0 6px, transparent 14px);
}

.scroll-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(90deg, rgba(50, 38, 18, 0.18), transparent 14px, transparent calc(100% - 14px), rgba(50, 38, 18, 0.18)),
    linear-gradient(180deg, rgba(50, 38, 18, 0.1), transparent 10px, transparent calc(100% - 12px), rgba(40, 30, 14, 0.14));
  box-shadow:
    inset 0 0 0 1px rgba(90, 72, 36, 0.28);
  clip-path: polygon(
    0.6% 0.4%, 7% 0%, 22% 0.6%, 48% 0%, 71% 0.5%, 93% 0%, 99.4% 0.8%,
    100% 14%, 99.2% 31%, 100% 52%, 99.3% 74%, 100% 90%, 99% 100%,
    86% 99.4%, 62% 100%, 38% 99.2%, 14% 100%, 0.8% 99.2%,
    0% 84%, 0.8% 61%, 0% 40%, 0.7% 18%
  );
}

.wax {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 46% 54% 48% 52%;
  background: radial-gradient(circle at 35% 30%, #a84820, #5a1808 70%);
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.45);
  z-index: 2;
  pointer-events: none;
  opacity: 0.88;
}
.wax-tl { top: 10px; left: 10px; }
.wax-tr { top: 10px; right: 10px; }
.wax-bl { bottom: 10px; left: 10px; }
.wax-br { bottom: 10px; right: 10px; }

.scroll-title {
  position: relative;
  z-index: 1;
  margin: 0.15rem 0 1rem;
  padding: 0 0.4rem;
  text-align: center;
  font-family: "Cinzel Decorative", Cinzel, Palatino, serif;
  font-weight: 700;
  font-size: clamp(1.28rem, 5vw, 1.65rem);
  letter-spacing: 0.06em;
  line-height: 1.2;
  color: #3a2412;
  -webkit-text-fill-color: #3a2412;
  background: none;
  text-shadow: none;
  filter: none;
}

.seat-row {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  padding: 0.4rem 0.1rem 0.5rem;
}

.seat-emblem {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #2a1608;
  background: radial-gradient(circle at 38% 30%, #d8b078, #8a5a28 62%, #3a200c);
  border: 1px solid #2a1608;
  border-radius: 50%;
  flex: 0 0 48px;
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.22), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.seat-emblem.golem { color: #1a0c04; }

.row-word {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3a2412;
  -webkit-text-fill-color: #3a2412;
  text-shadow: none;
  filter: none;
  background: none;
}

.row-word.is-pulse {
  animation: row-word-pulse 260ms var(--ease-out);
}

@keyframes row-word-pulse {
  0%, 100% { color: #3a2412; -webkit-text-fill-color: #3a2412; }
  40% { color: #8a5a18; -webkit-text-fill-color: #8a5a18; }
}

.stepper {
  display: grid;
  grid-template-columns: 44px 2.7rem 44px;
  align-items: center;
  justify-content: center;
  column-gap: 0.55rem;
  margin: 0;
  width: calc(44px + 2.7rem + 44px + 1.1rem);
}

.stepper button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #1a0c04;
  background: radial-gradient(circle at 34% 28%, #d4b07a, #8a5a28 52%, #3a1e0c 78%);
  color: #1a0c04;
  box-shadow:
    inset 0 1px 0 rgba(255, 220, 170, 0.28),
    inset 0 -2px 3px rgba(0, 0, 0, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

.count-window {
  width: 2.4rem;
  height: 48px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.seat-count {
  display: block;
  min-width: 1.6rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: 2.35rem;
  line-height: 48px;
  font-weight: 700;
  color: #3a2412;
  -webkit-text-fill-color: #3a2412;
  text-shadow: none;
}

.seat-count.slide-up { animation: digit-up 250ms var(--ease-out); }
.seat-count.slide-down { animation: digit-down 250ms var(--ease-out); }

@keyframes digit-up {
  from { transform: translateY(0.7em); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes digit-down {
  from { transform: translateY(-0.7em); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.stepper.is-shake {
  animation: setup-shake 220ms var(--ease-out);
}

@keyframes setup-shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-5px); }
  60% { transform: translateX(5px); }
}

.tribe-pick {
  position: relative;
  z-index: 1;
  margin: 0.2rem 0 0.35rem;
  padding: 0.45rem 0.1rem 0.55rem;
  border-top: 1px solid rgba(42, 22, 8, 0.28);
  border-bottom: 1px solid rgba(42, 22, 8, 0.28);
}

.tribe-heading {
  margin: 0 0 0.4rem;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #3a2412;
}

.seals {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.7rem;
}

.seal {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  color-scheme: only light;
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid #2a1e0a;
  background-color: var(--seal);
  background-image: radial-gradient(circle at 32% 28%, rgba(255, 252, 230, 0.55), transparent 52%);
  box-shadow: inset 0 -3px 5px rgba(40, 28, 8, 0.28);
  transition: transform 220ms var(--ease-out), box-shadow 220ms var(--ease-out);
}

.seal[data-edge="yellow"] {
  --seal: #f2d24a;
}

.seal.is-on {
  transform: scale(1.22);
  border-color: #f8e48a;
  box-shadow:
    0 0 0 2px #f2d24a,
    inset 0 -3px 5px rgba(40, 28, 8, 0.28);
}

.seal.is-pick {
  animation: seal-pop 280ms var(--ease-out);
}

@keyframes seal-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.32); }
  100% { transform: scale(1.22); }
}

.setup-actions { position: relative; z-index: 1; margin-top: 0.55rem; }

.setup-actions button {
  background: radial-gradient(circle at 50% 0%, #4a2e16, #2a1a10);
  color: #ead8b0;
  border-color: #1a0c04;
}

.setup-actions button.ghost {
  background: transparent;
  color: #1f120a;
  border-color: #6a4220;
}

/* How to Play parchment */
#how-overlay {
  padding-left: max(0.7rem, env(safe-area-inset-left));
  padding-right: max(0.7rem, env(safe-area-inset-right));
  align-items: center;
  overflow: hidden;
  touch-action: none;
}
.how-scroll {
  position: relative;
  width: min(34rem, calc(100% - 0.2rem));
  margin: 0 auto;
}
#how-overlay.is-open .scroll-clip {
  max-height: calc(100dvh - 3.6rem);
  overflow: hidden;
}
#how-overlay .scroll-sheet {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100dvh - 3.2rem);
  min-height: 0;
  padding: 0.5rem 1.05rem 2.35rem;
  text-align: left;
  color: #2a1a0e;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#how-overlay .wax-bl,
#how-overlay .wax-br {
  bottom: 8px;
}
#how-overlay .how-page[data-how-page="1"].is-on {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.32rem;
  min-height: 0;
  height: auto;
  padding-bottom: 0.15rem;
}
#how-overlay[data-how-page="1"] .scroll-clip,
#how-overlay[data-how-page="1"].is-open .scroll-clip {
  max-height: none;
  height: auto;
  overflow: visible;
  grid-template-rows: max-content;
}
#how-overlay[data-how-page="1"] .scroll-sheet {
  max-height: none;
  height: auto;
  overflow: visible;
  padding-bottom: 0.85rem;
}
#how-overlay[data-how-page="1"] .how-close-wrap {
  position: relative;
  bottom: auto;
  margin-top: 0.4rem;
}
#how-overlay .how-page[data-how-page="2"].is-on {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100dvh - 7.4rem);
  overflow: hidden;
}
#how-overlay .how-page[data-how-page="2"] .scroll-title {
  flex: 0 0 auto;
  margin: 0 0 0.08rem;
}
#how-overlay .how-page[data-how-page="3"].is-on {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: calc(100dvh - 7.4rem);
  overflow: hidden;
}
#how-overlay .how-page[data-how-page="3"] .scroll-title,
#how-overlay .how-page[data-how-page="3"] .how-rank-note {
  flex: 0 0 auto;
}
#how-overlay .scroll-title {
  margin: 0.05rem 0 0.3rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.6vw, 1.28rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #1c1006;
  text-shadow: none;
}
.how-page {
  position: relative;
  z-index: 1;
}
.how-page[hidden],
.how-page:not(.is-on) {
  display: none !important;
}
.how-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  margin: 0;
}
.how-tag-plaque {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: 0.42rem 0.95rem 0.46rem;
  background-color: #0b0806;
  background-image:
    radial-gradient(ellipse at 50% 38%, #1c1410 0%, #0b0806 72%),
    repeating-linear-gradient(0deg, rgba(255, 248, 230, 0.03) 0 1px, transparent 1px 3px);
  border: 2px solid #d4b46a;
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px #5a3a14,
    inset 0 0 0 3px #0b0806,
    inset 0 0 0 4px #c4a05a,
    inset 0 0 18px rgba(0, 0, 0, 0.55);
  color-scheme: only light;
}
.how-filigree {
  position: absolute;
  width: 11px;
  height: 11px;
  pointer-events: none;
  border: 2px solid #e8c878;
  box-shadow: 0 0 6px rgba(226, 192, 118, 0.35);
}
.how-filigree-tl { top: 3px; left: 3px; border-right: 0; border-bottom: 0; }
.how-filigree-tr { top: 3px; right: 3px; border-left: 0; border-bottom: 0; }
.how-filigree-bl { bottom: 3px; left: 3px; border-right: 0; border-top: 0; }
.how-filigree-br { bottom: 3px; right: 3px; border-left: 0; border-top: 0; }
.how-tag {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(0.68rem, 2.4vw, 0.84rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e8c878;
  -webkit-text-fill-color: #e8c878;
  text-shadow: 0 1px 0 #3a2410, 0 0 10px rgba(226, 192, 118, 0.28);
  animation: gold-glow 5.6s ease-in-out infinite;
}
.how-lead {
  margin: 0.15rem 0 0.2rem;
  font-size: clamp(0.92rem, 3vw, 1.05rem);
  font-weight: 700;
  line-height: 1.32;
  color: #140c06;
}
.how-steps {
  margin: 0;
  padding: 0 0 0 1.2rem;
  font-size: clamp(0.84rem, 2.7vw, 0.96rem);
  font-weight: 700;
  line-height: 1.32;
  color: #140c06;
}
.how-steps li { margin: 0 0 0.28rem; }
.how-gates {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  position: relative;
  z-index: 3;
}
#how-overlay .how-title {
  margin: 0;
  padding: 0 0.1rem;
  font-family: "Cinzel Decorative", Cinzel, Palatino, serif;
  font-size: clamp(1.38rem, 5.2vw, 2.05rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.08;
  text-align: center;
  text-transform: none;
  color: #e8c878;
  -webkit-text-fill-color: #e8c878;
  text-shadow:
    0 1px 0 #fff4d2,
    0 2px 0 #5a3810,
    0 0 14px rgba(226, 192, 118, 0.38);
  animation: how-title-glow 4.8s ease-in-out infinite;
}
#how-overlay .how-title::after {
  content: "";
  display: block;
  width: min(12rem, 62%);
  height: 3px;
  margin: 0.14rem auto 0;
  background: linear-gradient(90deg, transparent, #c4a05a 16%, #f3e0a8 50%, #c4a05a 84%, transparent);
  box-shadow: 0 0 8px rgba(226, 192, 118, 0.45);
}
@keyframes how-title-glow {
  0%, 100% {
    text-shadow: 0 1px 0 #fff4d2, 0 2px 0 #5a3810, 0 0 8px rgba(226, 192, 118, 0.22);
  }
  50% {
    text-shadow: 0 1px 0 #fff8e0, 0 2px 0 #5a3810, 0 0 18px rgba(255, 220, 140, 0.55);
  }
}
.how-gate {
  min-height: 3.05rem;
  width: 100%;
  padding: 0.4rem 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(0.58rem, 2.15vw, 0.74rem);
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-transform: uppercase;
  color: #f8e7b4;
  background: linear-gradient(180deg, #6a4a1c 0%, #3a240c 100%);
  border: 1px solid #c4a05a;
  animation: how-gate-pulse 2.2s ease-in-out infinite;
}
@keyframes how-gate-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(196, 160, 90, 0.25), 0 0 8px rgba(226, 192, 118, 0.15); }
  50% { box-shadow: 0 0 0 1px #e2c076, 0 0 14px rgba(226, 192, 118, 0.45); }
}
.how-page[data-how-page="4"] { position: relative; }
#how-overlay[data-how-page="4"] .scroll-sheet {
  padding-bottom: 4.8rem;
}
.how-emblems {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.95rem;
  margin: 0.45rem auto 0;
}
.how-emblem-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(0.45rem, 2vw, 1.05rem);
  width: 100%;
}
.how-emblem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.32rem;
  flex: 1 1 0;
  width: 4.6rem;
  max-width: 5.5rem;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background: none;
  border: none;
  box-shadow: none;
  letter-spacing: 0;
  text-transform: none;
  color: #3a2412;
  -webkit-text-fill-color: #3a2412;
}
.how-emblem-row:last-child {
  width: 75%;
  max-width: calc(5.5rem * 3 + 1.05rem * 2);
}
.how-emblem > span:last-child {
  display: block;
  max-width: 100%;
  text-align: center;
  font-family: var(--font-display);
  font-size: clamp(0.5rem, 2.05vw, 0.66rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
}
canvas.emblem-face {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  background: none;
  border: none;
  box-shadow: none;
  pointer-events: none;
}
.how-reward-pop {
  position: relative;
  z-index: 2;
  margin: 0.85rem 0 0;
  padding: 0.7rem 0.85rem 0.75rem;
  text-align: center;
  cursor: pointer;
  background: linear-gradient(180deg, #2c1c10, #120c08);
  border: 1px solid #c4a05a;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}
.how-reward-pop[hidden] { display: none; }
#how-reward-name {
  margin: 0 0 0.35rem;
  font-family: Cinzel, Palatino, serif;
  font-size: 1rem;
  color: #f6e2a8;
  -webkit-text-fill-color: #f6e2a8;
}
#how-reward-blurb {
  margin: 0;
  color: #f3e6c8;
  -webkit-text-fill-color: #f3e6c8;
  font-size: 0.92rem;
  line-height: 1.4;
  text-transform: none;
  letter-spacing: 0;
}
.settings-way {
  margin: 0.15rem 0 0.2rem;
  text-align: center;
  font-size: 0.82rem;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  color: #e7d7b4;
  -webkit-text-fill-color: #e7d7b4;
}
.settings-tester {
  margin: 0.35rem 0 0;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
  color: #cbb992;
  -webkit-text-fill-color: #cbb992;
}
.art-toast {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(24rem, calc(100vw - 1.6rem));
  padding: 0.55rem 0.8rem;
  text-align: center;
  font-family: var(--font-body);
  font-size: 0.82rem;
  letter-spacing: 0;
  text-transform: none;
  color: #f6e2a8;
  background: rgba(18, 10, 6, 0.92);
  border: 1px solid #c4a05a;
  pointer-events: none;
}
#btn-store.is-cue,
#btn-gallery.is-cue {
  animation: way-pulse 1.35s ease-in-out infinite;
}
@keyframes way-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(226, 180, 74, 0.15); }
  50% { box-shadow: 0 0 0 3px rgba(226, 180, 74, 0.9); }
}
.how-foot {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.45rem;
  position: relative;
  z-index: 3;
  padding: 0;
  background: none;
}
.how-foot:not(:has(button:not([hidden]))) {
  display: none;
}
.how-foot .ghost {
  background: #3a240c;
  color: #f3e6c8;
  border-color: #6a4220;
}
.how-close-wrap {
  display: flex;
  justify-content: center;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.72rem;
  margin: 0;
  z-index: 6;
  pointer-events: none;
}
.how-close-wrap button {
  min-width: 8.5rem;
  pointer-events: auto;
  background: linear-gradient(180deg, #6a4a1c 0%, #3a240c 100%);
  color: #f8e7b4;
  border: 1px solid #c4a05a;
}
.how-row-label {
  margin: 0.16rem 0 0.1rem;
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 2.6vw, 0.92rem);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #140c06;
  text-align: center;
  flex: 0 0 auto;
  text-shadow: 0 1px 0 rgba(255, 236, 190, 0.35);
}
.how-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.42rem;
  flex-wrap: nowrap;
}
.how-row-fill {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.42rem;
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
}
.how-row-it {
  display: flex;
  justify-content: center;
  align-items: center;
}
.how-row-it .how-card {
  grid-column: auto;
}
.how-card {
  position: relative;
  height: 100%;
  width: auto;
  max-height: 100%;
  max-width: calc((100% - 1.26rem) / 4);
  aspect-ratio: 5 / 7;
  flex: 0 0 auto;
  padding: 0.28rem;
  background:
    linear-gradient(#2a1608, #120804) content-box,
    repeating-linear-gradient(
      90deg,
      #8a6230 0 3px,
      #e2c076 3px 4px,
      #8a6230 4px 7px,
      transparent 7px 10px
    ) padding-box,
    linear-gradient(180deg, #e2c076 0%, #8a5a18 42%, #3a240c 100%);
  border: 1px solid #f0d9a4;
  border-radius: 7px;
  overflow: hidden;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: stretch;
  box-shadow:
    0 0 0 1px #4a2e10,
    0 0 0 2px #c4a05a,
    inset 0 0 0 1px rgba(255, 230, 160, 0.28),
    0 3px 10px rgba(40, 16, 4, 0.45);
}
.how-card::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(226, 192, 118, 0.72);
  border-radius: 3px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(58, 36, 12, 0.85);
  z-index: 1;
}
.how-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at 7px 7px, #f8e7b4 0 1.4px, #c4a05a 1.6px 2.1px, transparent 2.3px),
    radial-gradient(circle at calc(100% - 7px) 7px, #f8e7b4 0 1.4px, #c4a05a 1.6px 2.1px, transparent 2.3px),
    radial-gradient(circle at 7px calc(100% - 7px), #f8e7b4 0 1.4px, #c4a05a 1.6px 2.1px, transparent 2.3px),
    radial-gradient(circle at calc(100% - 7px) calc(100% - 7px), #f8e7b4 0 1.4px, #c4a05a 1.6px 2.1px, transparent 2.3px);
}
.how-card img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  pointer-events: none;
  background: #1a0c06;
  border-radius: 2px;
}
.how-card.is-on {
  border-color: #fff1c4;
  box-shadow:
    0 0 0 1px #4a2e10,
    0 0 0 2px #e2c076,
    0 0 14px rgba(226, 192, 118, 0.7),
    inset 0 0 0 1px rgba(255, 230, 160, 0.45);
}
.how-detail {
  display: grid;
  grid-template-columns: 5.15rem 1fr;
  gap: 0.45rem;
  align-items: start;
  margin: 0.28rem 0 0;
  flex: 0 0 auto;
}
.how-demo-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.28rem;
  position: relative;
  z-index: 2;
}
.how-demo {
  position: relative;
  width: 5.15rem;
  height: 5.15rem;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #3a2a18, #120804 72%);
  border: 1px solid #c4a05a;
  overflow: hidden;
  box-shadow: inset 0 0 14px #000, 0 0 0 2px #3a240c;
  flex: 0 0 auto;
}
.how-combo {
  flex: 0 0 auto;
  margin: 0.28rem 0 0;
  width: 100%;
  padding: 0.28rem 0.4rem;
  background: linear-gradient(#f0d9a4, #cbb07a);
  border: 1.5px solid #6a4420;
  box-shadow: inset 0 0 0 1px #e2c076;
  color: #140c06;
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  position: relative;
  z-index: 5;
}
.how-combo[hidden] { display: none; }
.how-detail .how-blurb-frame {
  min-height: 5.15rem;
}
#how-demo-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}
.demo-pip {
  position: absolute;
  right: 0.22rem;
  top: 0.22rem;
  font-size: 0.68rem;
  font-weight: 800;
  font-family: var(--font-display);
  color: #e2c076;
  opacity: 0;
  z-index: 6;
  text-shadow: 0 0 6px #000;
  pointer-events: none;
}
.how-blurb-frame {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  min-height: 5.15rem;
  padding: 0.45rem 0.55rem;
  background: linear-gradient(#cbb07a, #b08a52);
  border: 2px solid #6a4420;
  box-shadow:
    inset 0 0 0 1px #e2c076,
    inset 0 0 18px rgba(80, 40, 10, 0.28),
    0 0 0 3px #3a240c;
}
.how-blurb-frame::before,
.how-blurb-frame::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 3px;
  background:
    repeating-linear-gradient(90deg, #6a4420 0 6px, transparent 6px 10px, #c4a05a 10px 12px, transparent 12px 16px);
  pointer-events: none;
}
.how-blurb-frame::before { top: 5px; }
.how-blurb-frame::after { bottom: 5px; }
#how-blurb {
  margin: 0;
  font-size: clamp(0.78rem, 2.6vw, 0.9rem);
  font-weight: 800;
  line-height: 1.3;
  color: #140c06;
  text-shadow: 0 1px 0 rgba(255, 236, 190, 0.45);
}
.how-rank-note {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #2a1a0e;
}
.how-rank-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8.2rem, 36%);
  gap: 0.5rem;
  align-items: stretch;
  flex: 1 1 0;
  min-height: 0;
}
.how-rank-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  gap: 0.32rem;
}
.how-ranks {
  list-style: none;
  margin: 0;
  padding: 0 0.2rem 0.4rem 0;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.how-ranks li {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.18rem;
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(0.78rem, 2.6vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #140c06;
  text-shadow: 0 1px 0 rgba(255, 236, 190, 0.35);
}
.rank-faces {
  display: flex;
  gap: 0.2rem;
  width: 100%;
  min-width: 0;
}
.rank-faces img {
  flex: 0 0 calc((100% - 0.8rem) / 5);
  width: calc((100% - 0.8rem) / 5);
  max-width: calc((100% - 0.8rem) / 5);
  aspect-ratio: 5 / 7;
  height: auto;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid #6a4420;
  background: #3a240c;
  box-shadow: 0 1px 3px rgba(40, 16, 4, 0.35);
}
.how-value-chart {
  position: relative;
  flex: 0 1 auto;
  z-index: 2;
  border: 1px solid #6a4420;
  box-shadow: inset 0 0 0 1px rgba(226, 192, 118, 0.35);
  background: #1a120c;
  overflow: visible;
  max-height: 48%;
}
.how-value-chart img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.how-value-help {
  position: absolute;
  top: 21.5%;
  right: 3.5%;
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid #e2c076;
  background: radial-gradient(circle at 40% 30%, #5a3a14, #1a0c04);
  color: #f8e7b4;
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: 0 0 8px rgba(226, 192, 118, 0.55);
  z-index: 3;
}
.how-value-help.is-on,
.how-value-help:focus-visible {
  background: #e2c076;
  color: #1a0c04;
}
.how-value-tip {
  position: absolute;
  top: 28%;
  left: 6%;
  right: 6%;
  z-index: 4;
  padding: 0.45rem 0.5rem;
  background: linear-gradient(#f0d9a4, #cbb07a);
  border: 2px solid #6a4420;
  box-shadow: inset 0 0 0 1px #e2c076, 0 8px 18px rgba(0, 0, 0, 0.35);
  color: #140c06;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: left;
}
.how-value-tip[hidden] { display: none; }

.how-crush {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.26rem;
}
.how-crush-frame {
  position: relative;
  flex: 1 1 auto;
  min-height: 5.2rem;
  background:
    radial-gradient(ellipse at 50% 30%, #2a1a10, #120a06 70%);
  border: 2px solid #c4a05a;
  box-shadow:
    inset 0 0 0 1px #6a4420,
    0 2px 8px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.how-crush-frame canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
.how-crush-blurb {
  margin: 0;
  padding: 0.32rem 0.4rem;
  font-size: clamp(0.62rem, 2.1vw, 0.72rem);
  font-weight: 700;
  line-height: 1.28;
  color: #140c06;
  background: linear-gradient(#f0d9a4, #cbb07a);
  border: 2px solid #6a4420;
  box-shadow: inset 0 0 0 1px #e2c076;
}

#campaign-map {
  z-index: 28;
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
  background: #120a06;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  transition: opacity 700ms var(--ease-out), visibility 700ms var(--ease-out);
}
#campaign-map.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.campaign-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: #120804;
  touch-action: none;
}
#campaign-view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.campaign-chrome {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.45rem 0.7rem;
  padding: 0.55rem max(0.7rem, env(safe-area-inset-right)) calc(0.7rem + env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
  background: linear-gradient(180deg, rgba(18, 10, 6, 0), rgba(18, 10, 6, 0.88) 28%, #120a06);
}
.campaign-chrome #btn-campaign-back {
  grid-row: 1;
  min-width: 5.5rem;
}
#campaign-hint {
  grid-column: 2;
  margin: 0;
  align-self: center;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 1px 4px #000;
}
.campaign-toggles {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}
.campaign-toggles button {
  position: relative;
  width: 5.6rem;
  height: 4.8rem;
  min-width: 5.2rem;
  min-height: 44px;
  padding: 0 0.2rem 0.15rem;
  border: 2px solid #5a3a14;
  border-radius: 10px;
  overflow: hidden;
  background:
    linear-gradient(#3a2412, #160c06);
  box-shadow:
    inset 0 0 0 1px #e2c07655,
    0 6px 10px rgba(0, 0, 0, 0.4);
  color: #f3e6c8;
}
.campaign-toggles button img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.45));
}
.campaign-toggles button span {
  position: relative;
  z-index: 1;
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-shadow: 0 1px 3px #000, 0 0 8px #4a2e10;
}
.campaign-toggles button.is-locked,
.campaign-toggles button:disabled {
  opacity: 1;
  filter: none;
  cursor: default;
}
.campaign-toggles button.is-locked img,
.campaign-toggles button:disabled img {
  filter: grayscale(1) brightness(0.45);
}
.campaign-toggles button.is-locked span,
.campaign-toggles button:disabled span {
  color: #8a7a62;
}
.campaign-toggles button.is-armed {
  border-color: var(--gold);
  box-shadow:
    0 0 0 1px var(--gold),
    0 0 16px rgba(226, 192, 118, 0.55),
    inset 0 0 0 1px #fff3;
  color: #fff6d4;
}
#campaign-pick {
  position: absolute;
  left: 50%;
  bottom: 0.85rem;
  top: auto;
  transform: translateX(-50%);
  width: min(22rem, calc(100vw - 1.4rem));
  padding: 0.7rem 0.85rem 0.8rem;
  background: linear-gradient(#efe0c0, #d4b882);
  border: 2px solid #6a4420;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  z-index: 6;
  text-align: center;
  pointer-events: auto;
}
#campaign-pick p {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #1f120a;
}
#campaign-pick .seals { margin-bottom: 0.55rem; }
#campaign-pick[hidden] { display: none; }
#btn-campaign-march {
  width: 100%;
  background: radial-gradient(circle at 50% 0%, #4a2e16, #2a1a10);
  color: #ead8b0;
}

@media (prefers-reduced-motion: reduce) {
  #campaign-map {
    animation: none;
    transition: none;
  }
}

@media (max-width: 520px) {
  .how-rank-split { grid-template-columns: minmax(0, 1fr) minmax(6.8rem, 34%); }
  .how-value-chart { max-width: none; margin: 0; max-height: 42%; }
  .how-crush-blurb { font-size: 0.6rem; }
}

#reward-store {
  z-index: 32;
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background: #2a180c;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  transition: opacity 500ms var(--ease-out), visibility 500ms var(--ease-out);
}
#reward-store.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
#store-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.store-chrome {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  padding: max(0.65rem, env(safe-area-inset-top)) max(0.85rem, env(safe-area-inset-right)) 0.5rem max(0.7rem, env(safe-area-inset-left));
  pointer-events: none;
  background: linear-gradient(180deg, rgba(12, 8, 6, 0.55), transparent 88%);
}
.store-chrome #btn-reward-back {
  pointer-events: auto;
  min-width: 5.5rem;
  min-height: 44px;
}
.store-title {
  margin: 0;
  font-family: "Cinzel Decorative", Cinzel, Palatino, serif;
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e8c878;
  -webkit-text-fill-color: #e8c878;
  text-shadow:
    0 1px 0 #fff6d0,
    0 2px 0 #8a5a18,
    0 0 10px rgba(226, 192, 118, 0.45);
}
.store-bank {
  margin: 0 0 0 0.55rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.08rem;
  padding: 0.28rem 0.7rem 0.32rem;
  font-family: "Cinzel Decorative", Cinzel, Palatino, serif;
  color: #e8c878;
  -webkit-text-fill-color: #e8c878;
  text-shadow: 0 1px 0 #5a3810, 0 0 8px rgba(226, 192, 118, 0.4);
  background: rgba(10, 7, 5, 0.55);
  border: 1px solid #c4a05a;
}
.store-bank[hidden] { display: none; }
.store-bank span {
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.store-bank strong {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

#reward-gem-rain {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}
.inherit-gem {
  display: inline-block;
  width: 1.15rem;
  height: 1.28rem;
  vertical-align: -0.18rem;
  background:
    radial-gradient(circle at 32% 26%, #fff6d2 0%, #ffc45a 30%, #e08a2a 58%, #8a3410 100%);
  clip-path: polygon(50% 0%, 94% 34%, 76% 100%, 24% 100%, 6% 34%);
  filter: drop-shadow(0 0 7px rgba(224, 138, 42, 0.9));
}
.inherit-gem.is-rain {
  position: fixed;
  width: 0.92rem;
  height: 1.02rem;
  margin: 0;
}
.reward-buy {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(8, 5, 3, 0.66);
}
.reward-buy[hidden] { display: none; }
.reward-buy-card {
  width: min(26rem, calc(100% - 0.4rem));
  padding: 1.2rem 1.15rem 1.05rem;
  text-align: center;
  background: linear-gradient(180deg, #2c1c10, #120c08);
  border: 1px solid #c4a05a;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), inset 0 0 0 1px #3a2410;
}
#reward-buy-ask {
  margin: 0 0 0.7rem;
  font-family: Cinzel, Palatino, serif;
  font-size: 1.12rem;
  line-height: 1.35;
  color: #f6e2a8;
  -webkit-text-fill-color: #f6e2a8;
}
.reward-buy-title {
  margin: 0 0 0.35rem;
  font-family: Cinzel, Palatino, serif;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: #f6e2a8;
  -webkit-text-fill-color: #f6e2a8;
}
.reward-buy-title[hidden] { display: none; }
.reward-buy-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
}
.reward-buy-price[hidden],
.reward-buy-actions[hidden],
.reward-buy-poor[hidden] { display: none; }
.reward-buy-price strong {
  font-family: Cinzel, Palatino, serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffe7a8;
  -webkit-text-fill-color: #ffe7a8;
  text-shadow: 0 0 10px rgba(224, 138, 42, 0.45);
}
.reward-buy-actions {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
}
.reward-buy-actions button {
  min-width: 6.2rem;
  min-height: 44px;
}
.reward-buy-poor {
  margin: 0 0 0.9rem;
  color: #f3e6c8;
  font-size: 0.95rem;
  line-height: 1.45;
}
#reward-buy-close {
  min-height: 44px;
  min-width: 6.5rem;
}
#btn-gallery {
  pointer-events: auto;
  position: relative;
  z-index: 8;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-btn);
  background: #2c1a0c;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transform: translateZ(0);
}

#gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 48;
  display: none;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(226, 192, 118, 0.16), transparent 42%),
    #140e0a;
  color: #f3e6c8;
}
#gallery-overlay.is-open { display: flex; }
#btn-gallery-back {
  position: absolute;
  z-index: 5;
  top: max(0.65rem, env(safe-area-inset-top));
  left: max(0.7rem, env(safe-area-inset-left));
  pointer-events: auto;
  min-width: 5.5rem;
  min-height: 44px;
}
#gallery-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: calc(4.2rem + env(safe-area-inset-top)) 0.8rem 1.4rem;
}
#gallery-plaque {
  margin: 0 auto 1rem;
  max-width: 40rem;
  padding: 0.75rem 1rem;
  text-align: center;
  font-family: "Cinzel Decorative", Cinzel, Palatino, serif;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  line-height: 1.35;
  color: #f6e4b0;
  -webkit-text-fill-color: #f6e4b0;
  background: linear-gradient(180deg, #6a4820, #2a180c 55%, #1a1008);
  border: 2px solid #e2c070;
  border-radius: 8px;
  box-shadow:
    0 0 16px rgba(226, 192, 118, 0.45),
    inset 0 0 18px rgba(255, 220, 150, 0.18);
}
#gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.85rem;
  max-width: 1100px;
  margin: 0 auto;
}
.gallery-reward {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  background: rgba(8, 5, 3, 0.72);
}
.gallery-reward[hidden] { display: none; }
.gallery-reward-card {
  width: min(22rem, calc(100% - 0.4rem));
  padding: 1.25rem 1.15rem 1.1rem;
  text-align: center;
  background: linear-gradient(180deg, #2c1c10, #120c08);
  border: 1px solid #c4a05a;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), inset 0 0 0 1px #3a2410;
}
#gallery-reward-title {
  margin: 0 0 0.45rem;
  font-family: Cinzel, Palatino, serif;
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: #f6e2a8;
  -webkit-text-fill-color: #f6e2a8;
}
.gallery-reward-price {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin: 0 0 0.55rem;
}
.gallery-reward-price strong {
  font-family: Cinzel, Palatino, serif;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #ffe7a8;
  -webkit-text-fill-color: #ffe7a8;
  text-shadow: 0 0 10px rgba(224, 138, 42, 0.45);
}
.gallery-reward-line {
  margin: 0 0 0.9rem;
  color: #f3e6c8;
  -webkit-text-fill-color: #f3e6c8;
  font-size: 0.95rem;
  line-height: 1.4;
}
#gallery-reward-ok {
  min-height: 44px;
  min-width: 6.5rem;
}
.g-plaque {
  margin: 0;
  padding: 0.45rem 0.45rem 0.55rem;
  background:
    linear-gradient(180deg, rgba(255, 226, 160, 0.16), transparent 28%),
    linear-gradient(180deg, #4a3018, #1c110a);
  border: 2px solid #c9a25a;
  border-radius: 12px;
  box-shadow:
    inset 0 0 0 1px #6e4e24,
    0 8px 16px rgba(0, 0, 0, 0.4);
}
.g-face {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #070504;
}
.g-face img {
  display: block;
  width: 100%;
  height: auto;
}
.g-plaque.is-locked .g-face img {
  filter: grayscale(1) brightness(0.55) contrast(0.92);
}
.g-plaque figcaption,
.reveal-card figcaption {
  margin: 0.4rem 0 0;
  text-align: center;
  font-family: Cinzel, Palatino, serif;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: #e8c878;
  -webkit-text-fill-color: #e8c878;
}
.chain-wrap { position: absolute; inset: 0; pointer-events: none; }
.chain-half { position: absolute; left: 8%; right: 8%; height: 52%; overflow: hidden; }
.chain-top { top: -2%; }
.chain-bot { top: 48%; }
.chain-half svg { display: block; width: 100%; height: 200%; }
.chain-bot svg { margin-top: -100%; }
#gallery-reveal {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 5, 3, 0.92);
  cursor: pointer;
}
#gallery-reveal[hidden] { display: none; }
.reveal-stage { width: min(78vw, 380px); text-align: center; }
.reveal-face {
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
.reveal-hint {
  margin: 0.8rem 0 0;
  font-family: Cinzel, Palatino, serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: #d9c7a2;
}
@keyframes chain-snap-up {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  35% { transform: translateY(-6px) rotate(-6deg); opacity: 1; }
  100% { transform: translateY(-70%) rotate(-18deg); opacity: 0; }
}
@keyframes chain-snap-down {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  35% { transform: translateY(6px) rotate(6deg); opacity: 1; }
  100% { transform: translateY(70%) rotate(16deg); opacity: 0; }
}
@keyframes gallery-vibe {
  0%, 100% { transform: translateX(0) rotate(0); }
  20% { transform: translateX(-7px) rotate(-1.2deg); }
  40% { transform: translateX(7px) rotate(1.2deg); }
  60% { transform: translateX(-4px) rotate(-0.6deg); }
  80% { transform: translateX(4px) rotate(0.6deg); }
}
@keyframes gallery-glow {
  from { box-shadow: 0 0 0 rgba(255, 220, 140, 0); }
  to { box-shadow: 0 0 28px 8px rgba(255, 214, 120, 0.85), 0 0 64px 16px rgba(226, 160, 60, 0.35); }
}
.reveal-card.is-breaking .chain-top { animation: chain-snap-up 0.55s ease-in forwards; }
.reveal-card.is-breaking .chain-bot { animation: chain-snap-down 0.55s ease-in forwards; }
.reveal-card.is-breaking .reveal-face {
  animation: gallery-vibe 0.42s 0.32s linear both, gallery-glow 0.55s 0.7s ease-out forwards;
}
.reveal-card.is-revealed .chain-wrap { display: none; }
.reveal-card.is-revealed .reveal-face {
  box-shadow: 0 0 28px 8px rgba(255, 214, 120, 0.85);
}

@media (prefers-reduced-motion: reduce) {
  #intro-menu,
  #hub-menu,
  #how-overlay,
  #name-overlay,
  #later-overlay,
  #settings-overlay,
  #match-setup,
  .scroll-clip,
  button {
    transition: none;
  }
  #intro-menu .eyebrow {
    animation: none;
    color: var(--gold);
    -webkit-text-fill-color: var(--gold);
    text-shadow: none;
  }
  #btn-name-tribe {
    animation: none;
  }
  #btn-continue-last {
    animation: none;
  }
}
