/* 三國風雲會: black lacquer and gilt, vermilion seals, ivory paper.
   The frames are 9-slice SVGs in ui/: plaques for buttons (plaque*.svg,
   slice 14), a panel with cloud-scroll corner fittings (panel.svg, slice 40),
   the 回 key fret for rules (fret.svg); seals are stamped through
   ui/stamp.svg, scrolls are laid with ui/paper.svg. */
:root {
  --ink: #f3e9d2;
  --ink-dim: #c9b893;
  --ink-dark: #2b1a0e;
  --lacquer: #1a0d09;
  --panel: rgba(36, 19, 12, 0.92);
  --panel-solid: #24130c;
  --gold: #d6b060;
  --gold-bright: #f2d27a;
  --gold-deep: #8a5c1c;
  --vermilion: #b3261e;
  --cinnabar: #8e1b14;
  --jade: #2e8a4f;
  --paper: #efe2c2;
  --line: rgba(214, 176, 96, 0.55);
  --font: 'Noto Serif TC', 'Noto Serif JP', 'Noto Serif KR', 'Noto Serif', serif;
  --font-head: 'LXGW WenKai TC', 'Noto Serif TC', serif;
  --font-btn: 'LXGW WenKai TC', 'Noto Serif TC', serif;
  --font-seal: 'LXGW WenKai TC', 'Noto Serif TC', serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}
html:lang(ja) { --font: 'Noto Serif JP', 'Noto Serif TC', serif; --font-head: 'LXGW WenKai TC', 'Noto Serif JP', serif; --font-btn: 'LXGW WenKai TC', 'Noto Serif JP', serif; }
html:lang(ko) { --font: 'Noto Serif KR', 'Noto Serif TC', serif; --font-head: 'Noto Serif KR', 'Noto Serif TC', serif; --font-btn: 'Noto Serif KR', 'Noto Serif TC', serif; }
html:lang(en) { --font: 'Noto Serif', 'Noto Serif TC', serif; --font-head: 'Cinzel', 'Noto Serif', serif; --font-btn: 'Noto Serif', 'Noto Serif TC', serif; }
html:lang(ja) body, html:lang(ja) button, html:lang(ja) input { font-family: var(--font); }
html:lang(ko) body, html:lang(ko) button, html:lang(ko) input { font-family: var(--font); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--lacquer); color: var(--ink); font-family: var(--font); overflow: hidden; }
#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------- plaques (buttons) */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
  font: inherit; font-family: var(--font-btn); font-weight: 700; color: var(--ink); letter-spacing: 0.03em; line-height: 1.25;
  cursor: pointer; touch-action: manipulation; text-decoration: none; text-align: center;
  min-height: 44px; padding: 0.2em 0.7em;
  border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch;
  background: none; text-shadow: 0 1px 0 #000, 0 0 8px #000a;
  filter: drop-shadow(0 3px 2px #000a);
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover { filter: brightness(1.14) drop-shadow(0 3px 2px #000a); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; filter: grayscale(0.75) brightness(0.8); transform: none; }
.btn.primary { border-image-source: url(ui/plaque-red.svg); color: #fff4dc; }
.btn.ghost { border-image-source: url(ui/plaque-ghost.svg); filter: none; }
.btn.ghost:hover { filter: brightness(1.25); }
.btn.on, .btn[aria-pressed="true"] { border-image-source: url(ui/plaque-on.svg); color: #fff6d8; filter: drop-shadow(0 0 7px #f2d27a77); }
.btn.small { font-size: 0.9em; min-height: 38px; padding: 0.1em 0.5em; border-width: 10px; border-image-width: 10px; }
.btn.tiny { font-size: 0.9em; min-height: 34px; min-width: 34px; padding: 0 0.25em; border-width: 9px; border-image-width: 9px; }
.btn.big { font-size: 1.12em; min-height: 56px; padding: 0.3em 1.1em; }
.btn small { display: block; font-family: var(--font); font-weight: 500; font-size: 0.7em; letter-spacing: 0.01em; color: var(--ink-dim); margin-top: 0.15em; text-shadow: 0 1px 2px #000; }
.btn.primary small { color: #f6d7bf; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold-bright); outline-offset: 2px; }

/* a seal stamped in vermilion: a glyph standing for each screen */
.seal-i {
  display: inline-grid; place-items: center; flex: none; width: 1.85em; height: 1.85em;
  font: 700 1.05em/1 var(--font-seal); font-style: normal; color: #fff3dc; letter-spacing: 0; text-shadow: none;
  -webkit-text-fill-color: #fff3dc;
  background: radial-gradient(circle at 30% 25%, #dc4a3c, #a8241b 55%, #7a140e); border-radius: 5px; transform: rotate(-4deg);
  box-shadow: inset 0 0 0 2px #a8241b, inset 0 0 0 3px #ffe7bdaa;
  -webkit-mask: url(ui/stamp.svg) center / 90px; mask: url(ui/stamp.svg) center / 90px;
}

/* gold: a round coin with a square hole */
.gold { color: var(--gold-bright); font-weight: 700; white-space: nowrap; }
.gold::before {
  content: ''; display: inline-block; width: 1.05em; height: 1.05em; margin-right: 0.35em; vertical-align: -0.17em; border-radius: 50%;
  background: linear-gradient(#3a200e, #3a200e) center / 32% 32% no-repeat, radial-gradient(circle at 35% 30%, #fff1b8, #e0b552 45%, #9c6c1e 78%, #6b4512);
  box-shadow: inset 0 0 0 1.5px #8a5f1a, 0 1px 2px #000a;
}

/* fields: a slip of paper */
input {
  font: inherit; font-size: 16px; color: var(--ink-dark); background: var(--paper) url(ui/paper.svg); border: 1px solid #7a5a2a; border-radius: 3px;
  padding: 0.5em 0.7em; box-shadow: inset 0 2px 4px #0003, 0 0 0 1px #d6b06055;
}
input::placeholder { color: #8a7352; opacity: 1; }

.screen { position: absolute; inset: 0; z-index: 2; }
.panel-screen { background: radial-gradient(ellipse at 50% 18%, #2c150cf0, #0d0604f6 70%); overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(24px + var(--safe-b)) calc(16px + var(--safe-l)); }

/* a screen's title: back plaque, seal and gilt title over a fret rule */
.sub-head { position: relative; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 1100px; margin: 0 auto 18px; padding-bottom: 14px; }
.sub-head::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: url(ui/fret.svg) repeat-x 0 0 / auto 100%; opacity: 0.4;
  -webkit-mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.sub-head h2 {
  display: flex; align-items: center; gap: 0.5em; margin: 0; flex: 1; min-width: 0;
  font-family: var(--font-head); font-weight: 700; font-size: 1.65em; letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff3c9, #e8bd62 55%, #b07a2c); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #2a1208);
}
.sub-head h2 .seal-i { font-size: 0.62em; }
.sub-head h2 small { font-family: var(--font); font-size: 0.48em; font-weight: 500; letter-spacing: 0.04em; -webkit-text-fill-color: var(--ink-dim); color: var(--ink-dim); }
.sub-body { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.panel-screen.wide .sub-head { max-width: none; }

/* a framed lacquer panel with cloud-scroll fittings at the corners */
.framed { border: 34px solid transparent; border-image: url(ui/panel.svg) 40 fill / 34px stretch; padding: 0 2px; filter: drop-shadow(0 14px 22px #000b); }

h3 { display: flex; align-items: center; gap: 0.6em; margin: 6px 0 2px; font-family: var(--font-head); font-size: 1.1em; letter-spacing: 0.05em; color: var(--gold-bright); }
h3::before { content: ''; width: 0.5em; height: 0.5em; flex: none; transform: rotate(45deg); background: linear-gradient(135deg, #fff0b8, #c8953f); box-shadow: 0 0 6px #f2d27a66; }
h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row .label { min-width: 5.5em; color: var(--ink-dim); font-family: var(--font-head); letter-spacing: 0.04em; }

/* a row of tallies: one is chosen */
.seg { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.seg > button {
  font: inherit; font-family: var(--font-btn); font-weight: 700; font-size: 0.92em; color: var(--ink); cursor: pointer; touch-action: manipulation;
  min-height: 38px; padding: 0 0.45em; border: 10px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 10px stretch; background: none;
  text-shadow: 0 1px 0 #000; filter: drop-shadow(0 2px 1px #0009);
}
.seg > button:hover { filter: brightness(1.15) drop-shadow(0 2px 1px #0009); }
.seg > button[aria-pressed="true"] { border-image-source: url(ui/plaque-red.svg); color: #fff4dc; filter: drop-shadow(0 0 6px #f2d27a66); }
.field { display: flex; flex-direction: column; gap: 4px; max-width: 360px; }
.field span { color: var(--ink-dim); font-size: 0.9em; font-family: var(--font-head); letter-spacing: 0.04em; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--vermilion); box-shadow: none; }

/* ---------------------------------------------------------- the main menu */
#menu { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: calc(16px + var(--safe-t)) 16px calc(22px + var(--safe-b)); pointer-events: none; }
#menu > * { pointer-events: auto; }
#menu .home { position: absolute; top: calc(10px + var(--safe-t)); left: calc(10px + var(--safe-l)); }
.logo { text-align: center; margin-bottom: auto; margin-top: clamp(34px, 8vh, 110px); pointer-events: none; }
.logo h1 { display: flex; align-items: center; justify-content: center; gap: 0.25em; margin: 0; font-family: var(--font-head); font-weight: 700; font-size: clamp(2.1rem, 7.2vw, 4.3rem); letter-spacing: 0.08em; line-height: 1.12; }
html:lang(en) .logo h1 { font-weight: 900; }
.logo h1 span { background: linear-gradient(180deg, #fff3cc, #e9bd5e 52%, #a8742a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #3a1a0a) drop-shadow(0 0 24px #ff9a4a55); }
.logo-seal {
  display: grid; place-items: center; flex: none; font: 700 0.3em/1.05 var(--font-seal); font-style: normal; letter-spacing: 0; writing-mode: vertical-rl;
  padding: 0.35em 0.25em; color: #fff1d6; border-radius: 4px; transform: rotate(4deg) translateY(-0.2em);
  background: radial-gradient(circle at 30% 25%, #dc4a3c, #a8241b 55%, #7a140e);
  box-shadow: inset 0 0 0 2px #a8241b, inset 0 0 0 3px #ffe7bdaa, 0 0 18px #b3261e66;
  -webkit-mask: url(ui/stamp.svg) center / 90px; mask: url(ui/stamp.svg) center / 90px;
}
.logo p { display: inline-block; margin: 8px 0 0; padding: 4px 28px; color: var(--ink); letter-spacing: 0.08em; text-shadow: 0 2px 6px #000;
  background: linear-gradient(90deg, transparent, #1a0d09b0 18%, #1a0d09b0 82%, transparent); font-family: var(--font-head); }
.logo p::before, .logo p::after { content: '◆'; color: var(--gold); font-size: 0.6em; vertical-align: 0.25em; margin: 0 0.8em; opacity: 0.8; }
.menu-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 10px; width: min(780px, 100%); }
.menu-buttons .btn { justify-content: flex-start; text-align: left; gap: 0.65em; padding: 0.2em 0.6em; min-height: 68px; }
.menu-buttons .btn > span { display: flex; flex-direction: column; min-width: 0; }
.menu-buttons .seal-i { font-size: 1.12em; }
.menu-buttons .btn.primary .seal-i { background: radial-gradient(circle at 30% 25%, #fff3d0, #f2d27a 55%, #c8953f); color: #7a140e; -webkit-text-fill-color: #7a140e; box-shadow: inset 0 0 0 2px #c8953f, inset 0 0 0 3px #7a140e88; }
.purse { display: flex; gap: 14px; align-items: center; margin: 10px 0 0; padding: 4px 18px; color: var(--ink-dim); text-shadow: 0 1px 4px #000;
  background: linear-gradient(90deg, transparent, #1a0d09c0 15%, #1a0d09c0 85%, transparent); }
.menu-notice { flex: none; width: min(780px, 100%); margin: 8px 0 0; padding: 6px 12px 0; border-top: 1px solid var(--line);
  color: var(--ink-dim); font-size: 0.8125rem; line-height: 1.5; text-align: center; text-wrap: pretty; text-shadow: 0 1px 4px #000;
  background: linear-gradient(90deg, transparent, #1a0d09c0 15%, #1a0d09c0 85%, transparent); }
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  /* a phone held sideways: a one-line title clear of the corner links */
  .logo { margin-top: 2px; }
  .logo h1 { font-size: clamp(1.5rem, 8.5vh, 2.5rem); }
  .logo p { margin-top: 2px; font-size: 0.78em; padding: 2px 20px; }
  .menu-buttons { width: min(700px, 100%); }
  .menu-buttons .btn { min-height: 54px; font-size: 1em; }
  .purse { margin-top: 4px; }
}
@media (max-width: 480px) {
  /* a phone: smaller seals and rims, so the labels keep their words whole */
  .menu-buttons { gap: 6px; }
  .menu-buttons .btn { font-size: 1em; min-height: 60px; gap: 0.45em; padding: 0.1em 0.25em; border-width: 10px; border-image-width: 10px; }
  .menu-buttons .seal-i { font-size: 0.9em; }
  .menu-buttons .btn small { font-size: 0.72em; }
}
@media (max-aspect-ratio: 1/1) {
  .menu-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logo { margin-top: clamp(26px, 6vh, 64px); }
  .logo h1 { flex-direction: column; gap: 0.15em; }
  .logo-seal { writing-mode: horizontal-tb; transform: rotate(-3deg); padding: 0.25em 0.45em; }
}

/* ---------------------------------------------------------- deck picker: banners of each force */
.deck-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 8px; }
.deck-pick button {
  position: relative; isolation: isolate; overflow: hidden; font: inherit; text-align: left; color: var(--ink); cursor: pointer; touch-action: manipulation;
  min-height: 72px; padding: 6px 10px; border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch; background: none;
  filter: drop-shadow(0 3px 2px #000a); text-shadow: 0 1px 2px #000;
}
.deck-pick button::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 3px; background: linear-gradient(135deg, var(--c1, #3b2216), var(--c2, #1a0d09)); box-shadow: inset 0 0 0 1px #f2d27a33; }
.deck-pick button::after { content: attr(data-glyph); position: absolute; right: 2px; bottom: -0.22em; z-index: -1; font: 700 3.4em/1 var(--font-seal); color: #fff; opacity: 0.13; }
.deck-pick button.painted::before { background: linear-gradient(90deg, var(--c2) 0%, color-mix(in srgb, var(--c2) 72%, transparent) 42%, transparent 78%), var(--art) 70% center / cover; }
.deck-pick button.painted::after { display: none; }
.deck-pick button:hover { filter: brightness(1.12) drop-shadow(0 3px 2px #000a); }
.deck-pick button[aria-pressed="true"] { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 9px #f2d27a88); }
.deck-pick button[aria-pressed="true"]::after { opacity: 0.3; color: var(--gold-bright); }
.deck-pick button:disabled { opacity: 0.45; cursor: not-allowed; }
.deck-pick b { display: block; font-family: var(--font-btn); font-size: 1.02em; letter-spacing: 0.02em; }
.deck-pick small { color: var(--ink-dim); font-size: 0.8em; }

/* ---------------------------------------------------------- lobby, room, chat */
.rooms-head { display: flex; align-items: center; gap: 8px; color: var(--gold-bright); font-family: var(--font-head); letter-spacing: 0.05em; }
.rooms { display: flex; flex-direction: column; gap: 6px; }
.rooms .empty { color: var(--ink-dim); font-style: italic; }
.room-item { display: flex; align-items: center; gap: 10px; padding: 2px 4px; border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch; filter: drop-shadow(0 2px 2px #0009); }
.room-item b { flex: 1; font-family: var(--font-btn); }
.room-item span { color: var(--ink-dim); font-size: 0.9em; }
.join { display: inline-flex; gap: 6px; align-items: center; }
.join input { width: 7.2em; text-transform: uppercase; letter-spacing: 0.14em; font-weight: 700; }
.join input::placeholder { letter-spacing: 0.02em; text-transform: none; font-weight: 500; }
.room-code { display: flex; align-items: center; gap: 8px; }
.room-code > span { white-space: nowrap; color: var(--ink-dim); font-family: var(--font-head); }
@media (max-width: 520px) {
  /* a phone: the code and its buttons get their own row */
  #room .sub-head { flex-wrap: wrap; }
  .room-code { flex: 1 0 100%; justify-content: flex-start; flex-wrap: wrap; }
}
.room-code b { font: 900 1.35em/1 'Noto Serif', serif; letter-spacing: 0.22em; color: var(--gold-bright); padding: 6px 4px 6px 10px; border-radius: 4px; background: #120a06; box-shadow: inset 0 0 0 1px var(--line), inset 0 2px 8px #000; }
.seats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seat { position: relative; min-height: 96px; padding: 0 4px; border: 26px solid transparent; border-image: url(ui/panel.svg) 40 fill / 26px stretch; }
.seat > small:first-child { display: inline-block; font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.08em; }
.seat b { display: block; font-size: 1.15em; font-family: var(--font-btn); margin: 2px 0; }
.seat small { color: var(--ink-dim); }
.seat .btn { margin-top: 6px; }
.host-set { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid #d6b06033; }
.go-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wait { color: var(--ink-dim); margin: 0; font-style: italic; }
.chatbox { padding: 8px 10px; border-radius: 4px; background: #0e0705d0; box-shadow: inset 0 0 0 1px var(--line), inset 0 4px 14px #000a; }
.chat-log { max-height: 160px; overflow-y: auto; font-size: 0.92em; display: flex; flex-direction: column; gap: 3px; }
.chat-log .sys { color: var(--ink-dim); font-style: italic; }
#chat-form { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
#chat-form input { flex: 1; min-width: 0; }
.chat-log .npc { color: var(--gold-bright); }
/* the chat beside a 輪抽's table: closed on a phone until someone opens it */
.dr-chat { margin-top: 16px; }
.dr-chat > summary { cursor: pointer; font-family: var(--font-btn); letter-spacing: 0.05em; color: var(--gold); }
.dr-chat.unread > summary::after { content: ' ●'; color: var(--gold-bright); }
.dr-chat[open] > summary { margin-bottom: 6px; }
#dr-chat-form { display: flex; gap: 6px; margin-top: 8px; align-items: center; }
#dr-chat-form input { flex: 1; min-width: 0; }

/* ---------------------------------------------------------- the game HUD */
.hud { pointer-events: none; }
.hud > * { pointer-events: auto; }

/* each lord: a lacquer nameplate with a bronze morale medallion */
.g-player {
  position: absolute; display: flex; align-items: center; gap: 8px; min-height: 58px; max-width: min(46vw, 340px); cursor: default;
  padding: 0 10px; border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch;
  filter: drop-shadow(0 4px 5px #000b); transition: filter 0.2s;
}
.g-player.me { left: calc(22px + var(--safe-l)); bottom: calc(10px + var(--safe-b)); }
.g-player.opp { left: calc(22px + var(--safe-l)); top: calc(10px + var(--safe-t)); }
.g-player.active { border-image-source: url(ui/plaque-on.svg); }
.g-player.deciding { filter: drop-shadow(0 0 8px #f2d27aaa) drop-shadow(0 4px 5px #000b); }
.g-player.targetable { cursor: pointer; animation: throb 0.9s infinite alternate; }
@keyframes throb { from { filter: drop-shadow(0 0 4px #ff5a3c) drop-shadow(0 0 2px #ff5a3c); } to { filter: drop-shadow(0 0 12px #ff5a3c) drop-shadow(0 0 3px #ff8a6c); } }
.g-who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.g-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-btn); letter-spacing: 0.02em; }
.g-counts { display: flex; gap: 2px; margin-left: -4px; font-size: 0.78em; color: var(--ink-dim); white-space: nowrap; }
/* hand, library and graveyard: a little icon and a count each */
.g-chip { display: inline-flex; align-items: center; gap: 3px; padding: 1px 4px; border: 0; border-radius: 4px; background: none; font: 700 1em/1.2 'Noto Serif', 'Noto Serif TC', serif; color: inherit; font-variant-numeric: tabular-nums; }
.g-chip svg { width: 1.15em; height: 1.15em; fill: none; stroke: var(--gold); stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }
.g-chip b { color: var(--ink); }
button.g-chip { cursor: pointer; touch-action: manipulation; }
button.g-chip:hover { background: #f2d27a22; }
/* a library running low (with no card to draw, its lord loses): red, beating once empty */
.g-chip.low svg { stroke: #ff8a6c; }
.g-chip.low b { color: #ffb09a; }
.g-chip.low.out b, .g-pile.lib.low.out b { animation: lowBeat 0.9s ease-in-out infinite; }

/* the turn and step: a small plaque by the tools */
.g-phase { position: absolute; top: calc(8px + var(--safe-t)); right: calc(108px + var(--safe-r)); text-align: center; line-height: 1.2; min-width: 6.4em;
  padding: 0 0.4em; border: 10px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 10px stretch; filter: drop-shadow(0 3px 3px #000a); }
.g-phase b { display: block; color: var(--gold-bright); font-family: var(--font-head); letter-spacing: 0.05em; }
.g-phase span { font-size: 0.78em; color: var(--ink-dim); white-space: nowrap; }
.g-tools { position: absolute; top: calc(8px + var(--safe-t)); right: calc(10px + var(--safe-r)); display: flex; gap: 4px; }
.g-icon { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid transparent; border-radius: 10px; background: #1a0d0955; color: var(--gold-bright); cursor: pointer; touch-action: manipulation; }
.g-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 2px #000b); }
.g-icon:hover { border-color: var(--line); background: #1a0d09aa; }

/* the prompt: a silk ribbon with swallowtail ends */
/* (at the board's left edge, across from the turn's buttons on the right,
   clear of the lords' portraits in the middle) */
.g-prompt { position: absolute; left: calc(10px + var(--safe-l)); top: 41%; transform: translateY(-50%); margin: 0; max-width: min(25vw, 300px);
  text-align: left; padding: 7px 26px 7px 14px; font-size: 0.92em; line-height: 1.45; pointer-events: none; text-shadow: 0 1px 2px #000;
  background: linear-gradient(var(--gold), var(--gold)) top / 100% 1px no-repeat, linear-gradient(var(--gold), var(--gold)) bottom / 100% 1px no-repeat,
    linear-gradient(180deg, #3e1e12f2, #1d0e08f2);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%); }
.g-prompt:empty { display: none; }
.g-prompt.bad { color: #ffd8c8; background: linear-gradient(#ff7a5a, #ff7a5a) top / 100% 1px no-repeat, linear-gradient(#ff7a5a, #ff7a5a) bottom / 100% 1px no-repeat, linear-gradient(180deg, #6a1610f2, #3a0a07f2); }
.g-actions { position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(14px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.g-actions .btn { font-size: 1em; min-width: 7em; min-height: 46px; padding: 0.15em 0.8em; }
/* 結束回合: a great round seal of vermilion lacquer in a gilt bronze rim, at the
   bottom right; it lights up gold when there's nothing left to do, and stands
   dark through the opponent's turn */
.g-main { --d: 116px; display: grid; place-items: center; width: var(--d); height: var(--d); padding: 12px; border: 0; border-radius: 50%; cursor: pointer; touch-action: manipulation;
  font: 700 1.24em/1.12 var(--font-seal); color: #fff3dc; letter-spacing: 0.04em; text-align: center; text-shadow: 0 1px 2px #000b; overflow-wrap: anywhere;
  background: radial-gradient(circle at 34% 28%, #ef6a52, #b3291e 46%, #7a140e 74%, #4a0a06);
  box-shadow: inset 0 0 0 3px #5a0c08, inset 0 0 0 5px #f2d27acc, inset 0 0 0 7px #8a5c1c, inset 0 -10px 18px #0006, inset 0 8px 14px #ffb08a44,
    0 0 0 3px #2a140b, 0 0 0 6px #c8953f, 0 0 0 8px #5a3a14, 0 12px 22px #000c;
  transition: filter 0.2s, transform 0.12s; }
.g-main:hover { filter: brightness(1.12); }
.g-main:active { transform: scale(0.95); }
.g-main.done { animation: endReady 1.1s ease-in-out infinite alternate; color: #2a140b; text-shadow: 0 1px 0 #fff6; background: radial-gradient(circle at 34% 28%, #fff3b8, #f2c84a 46%, #c8902c 74%, #8a5c1c); }
@keyframes endReady { from { box-shadow: inset 0 0 0 3px #6e4614, inset 0 0 0 5px #fff3c4, inset 0 0 0 7px #8a5c1c, 0 0 0 3px #2a140b, 0 0 0 6px #c8953f, 0 0 0 8px #5a3a14, 0 12px 22px #000c, 0 0 10px #ffd86a66; }
  to { box-shadow: inset 0 0 0 3px #6e4614, inset 0 0 0 5px #fff3c4, inset 0 0 0 7px #8a5c1c, 0 0 0 3px #2a140b, 0 0 0 6px #f2d27a, 0 0 0 8px #5a3a14, 0 12px 22px #000c, 0 0 38px #ffd86add; } }
.g-main.ghost { filter: saturate(0.55) brightness(0.72); }
.g-main.ghost:hover { filter: saturate(0.7) brightness(0.88); }
.g-main.idle, .g-main:disabled { cursor: default; color: #c9b893; filter: none; transform: none; animation: none; text-shadow: 0 1px 1px #000;
  background: radial-gradient(circle at 34% 28%, #5a3a26, #33200f 50%, #1e120a 76%, #120a05); }
html:is(:lang(en), :lang(ko)) .g-main { font-size: 1.08em; letter-spacing: 0.01em; }
.g-timer { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: #00000066; pointer-events: none; }
.g-timer i { display: block; height: 100%; background: linear-gradient(90deg, #8a5c1c, #f2d27a); transform-origin: left; box-shadow: 0 0 8px #f2d27a88; }
.g-timer.low i { background: #ff5a3c; box-shadow: 0 0 8px #ff5a3c; }

/* the battle log: a paper scroll */
.g-log { position: absolute; right: calc(10px + var(--safe-r)); top: calc(72px + var(--safe-t)); width: min(370px, 82vw); max-height: 46vh; overflow-y: auto;
  padding: 10px 14px; font-size: 0.86em; color: var(--ink-dark); border-radius: 3px;
  background: var(--paper) url(ui/paper.svg); box-shadow: 0 14px 30px #000c, inset 0 0 0 1px #8a5c1c66, inset 0 0 30px #8a5c1c33; }
.g-log p { margin: 0; padding: 3px 0 3px 0.9em; border-bottom: 1px dotted #8a5c1c55; position: relative; }
.g-log p::before { content: ''; position: absolute; left: 0.1em; top: 0.85em; width: 4px; height: 4px; transform: rotate(45deg); background: #8a5c1c; }
.g-log p.turn { margin-top: 6px; padding-left: 0; border-bottom: 1px solid #8e1b1466; font-family: var(--font-head); font-weight: 700; color: var(--cinnabar); letter-spacing: 0.04em; }
.g-log p.turn::before { display: none; }
.g-floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
/* under a hand card lifted to be read */
.hud .under-card { opacity: 0; pointer-events: none; transition: opacity 0.12s; }
.hud .g-traps.under-card .g-trap { pointer-events: none; }
/* (a bubble's own show/gone opacity would win otherwise; keep its pop-in) */
.hud .g-bubble.under-card { transition: scale 0.2s cubic-bezier(.3, 1.6, .5, 1), opacity 0.12s; }
.floater { position: absolute; left: 0; top: 0; font-weight: 900; font-size: 1.6em; text-shadow: 0 2px 0 #000, 0 0 10px #000; white-space: nowrap; }
.floater.dmg { color: #ff6a4a; }
.floater.heal, .floater.buff { color: #8affa8; }
.floater.bad { color: #ffb0a0; font-size: 1.2em; font-family: var(--font-head); }
/* what isn't on a general's card: counters, gained keywords, 連環, a shield, 💤 */
.g-chips { position: absolute; left: 0; top: 0; display: flex; gap: 3px; align-items: center; white-space: nowrap; }
.g-chips b { display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; font: 800 12px/1 'Noto Serif', 'Noto Serif TC', serif;
  color: #f3e9d2; background: radial-gradient(circle at 35% 30%, #4a2614, #22100a 70%); box-shadow: 0 2px 5px #000c, inset 0 0 0 1px #c8953f; }
.g-chips b.icon { padding: 0; font-size: 12px; }
/* (hover shows what a chip means; a tap shows it as a banner) */
.g-chips b[title] { pointer-events: auto; cursor: help; touch-action: manipulation; }
.g-chips b.ctr { color: #1a0d09; background: radial-gradient(circle at 35% 30%, #d8ffd8, #6fcf7f 60%, #2e8a4f); box-shadow: 0 2px 5px #000c, inset 0 0 0 1px #154a2a; }
.g-chips b.kw { font: 700 11px/1 var(--font-btn); color: #fff3d0; }
/* 伏兵 set by a lord: small face-down cards along the portrait's edge toward
   the field, fanned a little; a new one drops in, all pulse when one is set */
.g-traps { position: absolute; left: 0; top: 0; display: flex; align-items: flex-end; padding: 0 4px; pointer-events: none; }
.g-traps.opp { align-items: flex-start; }
.g-trap { pointer-events: auto; position: relative; width: 30px; height: 42px; margin: 0 -3px; padding: 0; border: 0; border-radius: 3px; cursor: pointer; touch-action: manipulation;
  background: #5c120d var(--card-back) center / cover; transform: rotate(var(--tilt, 0deg));
  box-shadow: 0 3px 6px #000c, 0 0 0 1px #2a0806, 0 0 0 2px #c8953f, 0 0 10px #ffc24a55; transition: transform 0.15s ease-out, box-shadow 0.15s; }
.g-traps.opp .g-trap { transform: rotate(calc(-1 * var(--tilt, 0deg))); }
.g-trap:hover, .g-trap:focus-visible { transform: rotate(var(--tilt, 0deg)) translateY(-4px) scale(1.08); box-shadow: 0 5px 10px #000c, 0 0 0 1px #2a0806, 0 0 0 2px #ffe08a, 0 0 14px #ffd86aaa; }
.g-traps.opp .g-trap:hover { transform: rotate(calc(-1 * var(--tilt, 0deg))) translateY(4px) scale(1.08); }
.g-trap.new { animation: trapDrop 0.45s cubic-bezier(.2, .9, .3, 1.3); }
.g-traps.fresh .g-trap { animation: trapPulse 0.9s ease-out; }
@keyframes trapDrop { from { opacity: 0; translate: 0 -26px; scale: 1.5; } to { opacity: 1; translate: 0 0; scale: 1; } }
@media (max-width: 559px), (max-height: 500px) { .g-trap { width: 24px; height: 34px; margin: 0 -2px; } }
@keyframes trapPulse { 30% { box-shadow: 0 3px 6px #000c, 0 0 0 1px #2a0806, 0 0 0 2px #ffe08a, 0 0 22px #ffd86a; } }
.badge { position: absolute; left: 0; top: 0; min-width: 1.8em; height: 1.8em; display: grid; place-items: center; font-weight: 900; color: #1a0d09;
  background: radial-gradient(circle at 35% 30%, #fff3c4, #f2d27a 50%, #c8953f); border-radius: 999px; box-shadow: 0 2px 6px #000, inset 0 0 0 1px #8a5c1c; padding: 0 0.4em; }

/* the battle drawn on the table: arrows to the lords, morale on the portraits,
   the seals that send the charge and answer it, a red flush when you're hit */
.g-arrows { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.g-arrows .arrow { stroke-width: 1.6; stroke-linejoin: round; }
.g-arrows .arrow.flow { animation: arrowBreath 0.9s ease-in-out infinite alternate; }
/* an aimed spell's arrow: sparks running down its spine, and a turning
   reticle on the target it's locked onto */
.g-arrows .arrow-spine { fill: none; stroke: #fff6d8; stroke-linecap: round; stroke-dasharray: 3 15; opacity: 0.9; animation: spineFlow 0.5s linear infinite; filter: drop-shadow(0 0 3px #ffe8a8); }
@keyframes spineFlow { to { stroke-dashoffset: -18; } }
/* the ✕ on a block the rules won't take (outlined dark so it reads on any card) */
.g-arrows .arrow-x { pointer-events: none; }
.g-arrows .arrow-x path { fill: none; stroke-linecap: round; }
.g-arrows .arrow-x-back { stroke: #1a0504; stroke-width: 12; }
.g-arrows .arrow-x-mark { stroke: #ff3a2a; stroke-width: 6.5; filter: drop-shadow(0 0 4px #ff2a1a); }
.g-arrows .reticle { pointer-events: none; }
.g-arrows .reticle-spin { animation: reticleSpin 2.4s linear infinite; }
.g-arrows .reticle-ring { fill: none; stroke: #ff7a3c; stroke-width: 4; stroke-dasharray: 46 17; filter: drop-shadow(0 0 5px #ff5a3c); }
.g-arrows .reticle-ticks { fill: none; stroke: #ffe7bd; stroke-width: 4; stroke-linecap: round; }
.g-arrows .reticle-inner { fill: none; stroke: #ffe7bd88; stroke-width: 2; animation: reticleBeat 0.7s ease-in-out infinite alternate; }
@keyframes reticleSpin { to { transform: rotate(360deg); } }
@keyframes reticleBeat { from { opacity: 0.4; } to { opacity: 1; } }
@keyframes arrowBreath { to { opacity: 0.62; } }
.g-hurt { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 38%, #b0140a66 70%, #8a0a04e6 100%); }
.g-hurt.on { animation: hurtFlush 0.8s ease-out; }
@keyframes hurtFlush { 0% { opacity: var(--k, 0.8); background-color: #ff2a1022; } 100% { opacity: 0; background-color: transparent; } }
.g-lordhp { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); transform-origin: 0 0; pointer-events: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #8a1a12 0 54%, #4a0a06 60%, transparent 61%),
    conic-gradient(from 200deg, #fff0b8, #c8953f, #6e4614, #e8c46a, #8a5c1c, #f5dc95, #fff0b8);
  box-shadow: 0 3px 8px #000c; }
.g-lordhp b { font: 900 1.35em/1 'Noto Serif', 'Noto Serif TC', serif; color: #fff3d0; text-shadow: 0 2px 0 #000; font-variant-numeric: tabular-nums; }
.g-lordhp.low b { color: #ffb09a; animation: lowBeat 0.9s ease-in-out infinite; }
.g-lordhp.hit { animation: hpHit 0.5s ease-out; }
@keyframes lowBeat { 50% { transform: scale(1.18); color: #ff6a4a; } }
@keyframes hpHit { 0% { scale: 1.5; filter: brightness(2) saturate(2); } 30% { scale: 0.92; rotate: -6deg; } 60% { scale: 1.06; rotate: 4deg; } }
.g-incoming { position: absolute; left: 100%; top: 50%; transform: translate(5px, -50%); font: 900 0.95em/1 'Noto Serif', serif; font-style: normal; color: #ff6a4a;
  font-size: 1.15em; text-shadow: 0 1px 0 #000, 0 0 6px #000, 0 0 10px #ff3a1a; white-space: nowrap; animation: lowBeat 0.9s ease-in-out infinite; }
.g-incoming:empty { display: none; }
.g-all, .g-guard { position: absolute; left: 0; top: 0; display: grid; place-items: center; align-content: center; gap: 1px; min-width: 72px; height: 72px; padding: 0 12px;
  border: 0; border-radius: 9px; cursor: pointer; touch-action: manipulation; font: 700 1.25em/1 var(--font-seal); color: #fff3dc; letter-spacing: 0.06em; text-shadow: 0 1px 1px #0008;
  background: radial-gradient(circle at 30% 25%, #e0503f, #a8241b 55%, #74120c);
  box-shadow: inset 0 0 0 3px #a8241b, inset 0 0 0 5px #ffe7bdbb, 0 6px 12px #000b; }
/* "attack with N generals": a vermilion seal laid across the enemy's portrait */
.g-go { position: absolute; z-index: 2; left: 0; top: 0; min-height: 44px; padding: 7px 16px; border: 0; border-radius: 22px; cursor: pointer; touch-action: manipulation;
  font: 700 1.08em/1.2 var(--font-seal); color: #fff3dc; letter-spacing: 0.04em; text-align: center; text-shadow: 0 1px 2px #000a; text-wrap: balance;
  background: radial-gradient(ellipse at 35% 25%, #ec5a44f2, #a8241bf2 55%, #74120cf2);
  box-shadow: inset 0 0 0 2px #74120c, inset 0 0 0 4px #ffe7bdbb, 0 6px 14px #000c; animation: goBeat 0.85s ease-in-out infinite alternate; }
.g-go::before { content: '⚔ '; }
/* both of the buttons that have to be pressed to go on (attack with N, fight / don't block)
   have a band of light sweeping across them, and a rest between the sweeps */
.g-go, .g-guard { overflow: hidden; }
:is(.g-go, .g-guard)::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(105deg, #fff0 38%, #fffbe6b3 50%, #fff0 62%) 110% 0 / 250% 100% no-repeat;
  animation: btnShimmer 1.8s ease-in-out infinite; }
@keyframes btnShimmer { 0% { background-position: 110% 0; } 55%, 100% { background-position: -10% 0; } }
@media (prefers-reduced-motion: reduce) { :is(.g-go, .g-guard)::after { animation: none; display: none; } }
.g-guard small { font: 800 0.62em/1 'Noto Serif', serif; color: #ffe7bd; }
.g-guard small:empty { display: none; }
@keyframes goBeat { from { box-shadow: inset 0 0 0 2px #74120c, inset 0 0 0 4px #ffe7bdbb, 0 6px 14px #000c, 0 0 6px #ff5a3c66; }
  to { box-shadow: inset 0 0 0 2px #74120c, inset 0 0 0 4px #ffe7bdbb, 0 6px 14px #000c, 0 0 28px #ff7a3cdd; } }
.g-go:hover, .g-all:hover, .g-guard:hover { filter: brightness(1.15); }
.g-go:active, .g-all:active, .g-guard:active { filter: brightness(0.92); }
.g-all { min-width: 54px; height: 54px; font-size: 1em; color: var(--gold-bright); background: radial-gradient(circle at 30% 25%, #4a2614, #2a140b 60%, #1a0d09);
  box-shadow: inset 0 0 0 2px #8a5c1c, inset 0 0 0 3px #f2d27a88, 0 5px 10px #000b; }
.g-guard { background: radial-gradient(circle at 30% 25%, #6fd39a, #2e8a4f 55%, #154a2a); box-shadow: inset 0 0 0 3px #154a2a, inset 0 0 0 5px #f2d27aaa, 0 6px 12px #000b, 0 0 18px #5fd38d77; }
.g-guard.none { color: #f3e9d2; background: radial-gradient(circle at 30% 25%, #6a5a4a, #3a2a1e 55%, #1e140c); box-shadow: inset 0 0 0 3px #3a2a1e, inset 0 0 0 5px #e8d8bc88, 0 6px 12px #000b; }
html:is(:lang(en), :lang(ko)) :is(.g-go, .g-all, .g-guard) { font-size: 1.02em; letter-spacing: 0.01em; }
/* ⚔ on the top edge of a general that may charge: gold and beating until it's
   sent, then red */
.g-ready { position: absolute; left: 0; top: 0; }
/* (a real tap target: the floaters layer lets everything through to the table,
   but half of this hangs over the card's edge, where nothing on the table is) */
.g-ready i { position: relative; pointer-events: auto; cursor: pointer; touch-action: manipulation;
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font-size: 23px; font-style: normal; line-height: 1;
  color: #2a140b; background: radial-gradient(circle at 35% 30%, #fff3c4, #f2d27a 50%, #c8953f); box-shadow: 0 3px 8px #000c, inset 0 0 0 1.5px #8a5c1c;
  animation: readyBeat 0.9s ease-in-out infinite alternate; }
.g-ready i::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; }
.g-ready.on i { color: #fff3dc; background: radial-gradient(circle at 35% 30%, #ffb46a, #e2412a 55%, #8a1a10); box-shadow: 0 0 14px #ff7a3c, inset 0 0 0 1.5px #ffe7bd; animation-duration: 0.55s; }
@keyframes readyBeat { from { transform: scale(0.9); box-shadow: 0 3px 8px #000c, inset 0 0 0 1.5px #8a5c1c, 0 0 2px #ffd86a00; }
  to { transform: scale(1.12); box-shadow: 0 3px 8px #000c, inset 0 0 0 1.5px #8a5c1c, 0 0 18px #ffd86acc; } }
.g-ready.on i { animation-name: readyBeatOn; }
@keyframes readyBeatOn { from { transform: scale(0.95); } to { transform: scale(1.14); box-shadow: 0 0 26px #ff7a3c, inset 0 0 0 1.5px #ffe7bd; } }
.g-clash { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; line-height: 1;
  color: #fff; background: radial-gradient(circle at 35% 30%, #d8f0ff, #6aa8d8 55%, #234a6a); box-shadow: 0 0 12px #9fdcff, inset 0 0 0 1px #fff; }

/* a triggered ability going off (gold), the Mandate giving its card (jade):
   rings spreading from the card or the portrait */
.g-pulse { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
.g-pulse i, .g-pulse b { position: absolute; left: -40px; top: -40px; width: 80px; height: 80px; border-radius: 50%; }
.g-pulse i { border: 3px solid #ffe08a; box-shadow: 0 0 14px #ffd86a, inset 0 0 10px #ffd86a88; animation: pulseRing 0.75s ease-out forwards; }
.g-pulse i + i { animation-delay: 0.16s; opacity: 0; }
.g-pulse b { background: radial-gradient(circle, #fff6d0cc, #ffd86a44 45%, transparent 70%); animation: pulseCore 0.6s ease-out forwards; }
.g-pulse.jade i { border-color: #8ff0bc; box-shadow: 0 0 14px #5fd38d, inset 0 0 10px #5fd38d88; }
.g-pulse.jade b { background: radial-gradient(circle, #e8fff0cc, #6fe0a044 45%, transparent 70%); }
@keyframes pulseRing { 0% { transform: scale(0.3); opacity: 1; } 100% { transform: scale(2.1); opacity: 0; } }
@keyframes pulseCore { 0% { transform: scale(0.4); opacity: 0; } 25% { opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
/* the 天命 seal blinks when the Mandate gives its card: three bright beats,
   so the extra card isn't lost in the change of turn */
.g-lordseal.blink { animation: sealBlink 2.4s ease-in-out; }
@keyframes sealBlink {
  0%, 24%, 48%, 76%, 100% { filter: brightness(1); scale: 1; }
  12%, 36%, 60% { filter: brightness(1.7) drop-shadow(0 0 6px #e8fff0) drop-shadow(0 0 16px #5fd38d); scale: 1.55; }
}
html:is(:lang(en), :lang(ko)) .floater.stamp { font-size: 1.15em; }
.floater.dmg.big { font-size: 2.7em; color: #ff4a2a; -webkit-text-stroke: 1px #3a0806; text-shadow: 0 3px 0 #000, 0 0 16px #ff3a1a; }
.floater.stamp { display: grid; place-items: center; min-width: 1.9em; height: 1.9em; padding: 0 0.3em; font: 700 1.7em/1 var(--font-seal); color: #fff3dc; text-shadow: none; border-radius: 6px;
  background: radial-gradient(circle at 30% 25%, #6fb8e8, #2a6a9a 55%, #143a5a); box-shadow: inset 0 0 0 2px #143a5a, inset 0 0 0 3px #e8f4ffcc, 0 0 22px #9fdcffcc; }

/* each library and graveyard: its count on a plaque under it (the graveyard's opens it) */
.g-pile { position: absolute; left: 0; top: 0; display: inline-flex; align-items: baseline; gap: 4px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 3px;
  background: #1a0d09d9; color: var(--ink-dim); font: 700 12px/1.3 var(--font-btn); white-space: nowrap; box-shadow: 0 2px 6px #000a; pointer-events: none; }
.g-pile b { font: 800 13px/1 'Noto Serif', serif; color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.g-pile.grave { cursor: pointer; pointer-events: auto; touch-action: manipulation; }
.g-pile.grave:hover { border-color: var(--gold-bright); color: var(--ink); }
.g-pile.empty { opacity: 0.55; pointer-events: none; }
.g-pile.lib.low { border-color: #ff6a4a; color: #ffb09a; }
.g-pile.lib.low b { color: #ffb09a; }
.g-pile small.ex { margin-left: 4px; }

/* the Mandate on its holder's portrait: the imperial jade seal */
.g-lordseal { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); transform-origin: 0 0; cursor: help; touch-action: manipulation; font: 700 0.78em/1.05 var(--font-seal); color: #fff6d8; padding: 4px 3px; border-radius: 4px;
  writing-mode: vertical-rl; background: radial-gradient(circle at 35% 28%, #8fe0ad, #2e8a4f 55%, #154a2a);
  box-shadow: inset 0 0 0 1.5px #154a2a, inset 0 0 0 2.5px #f2d27a99, 0 0 14px #5fd38d88, 0 3px 6px #000b; }
html:is(:lang(en), :lang(ko)) .g-lordseal { writing-mode: horizontal-tb; padding: 3px 6px; }

/* the 主將's power: a small round button on the portrait's right, its icon inside, its cost on a seal */
.g-power { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  touch-action: manipulation; color: var(--gold-bright); background: radial-gradient(circle at 40% 32%, #5a3018, #2a140b 62%, #140905);
  box-shadow: inset 0 0 0 2px #8a5c1c, 0 4px 8px #000c; transition: filter 0.2s; }
.g-power-icon { width: calc(100% - 6px); height: calc(100% - 6px); }
.g-power-cost { position: absolute; top: -6px; right: -6px; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%;
  font: 800 11px/1 'Noto Serif', serif; font-style: normal; color: #fff3dc; background: radial-gradient(circle at 35% 30%, #e0503f, #a8241b 60%, #74120c); box-shadow: 0 2px 4px #000b, inset 0 0 0 1px #ffe7bd99; }
/* a power's icon: its painting cropped round, or its glyph on lacquer */
.power-icon { display: inline-grid; place-items: center; flex: none; border-radius: 50%; overflow: hidden; font: 700 1.25em/1 var(--font-seal); color: var(--gold-bright);
  text-shadow: 0 1px 2px #000, 0 0 8px #f2d27a66; background: radial-gradient(circle at 40% 35%, #3a1d10, #160a06 70%) center / cover no-repeat; box-shadow: inset 0 0 0 1px #f2d27a55; }
.power-icon.painted { box-shadow: inset 0 0 0 1px #f2d27a88, inset 0 0 6px #000a; }
.gen-icon { width: 24px; height: 24px; font-size: 0.82em; }
.g-power.ready { animation: powerReady 1s ease-in-out infinite alternate; }
@keyframes powerReady { from { box-shadow: inset 0 0 0 2px #c8953f, inset 0 0 0 4px #f2d27aaa, 0 5px 10px #000c, 0 0 8px #f2d27a66; }
  to { box-shadow: inset 0 0 0 2px #f2d27a, inset 0 0 0 4px #fff0b8, 0 5px 10px #000c, 0 0 24px #f2d27add; } }
.g-power.used { filter: grayscale(0.85) brightness(0.6); }
.g-power.fired { animation: powerFired 0.7s ease-out; }
@keyframes powerFired { 30% { filter: brightness(2.2); box-shadow: 0 0 34px #ffe8a8; } }
.g-power:hover { filter: brightness(1.15); }
.g-power.used:hover { filter: grayscale(0.85) brightness(0.75); }
.floater.stamp.power { width: auto; padding: 0 0.45em; font-size: 1.25em; color: #2a140b;
  background: radial-gradient(circle at 30% 25%, #fff3c4, #f2d27a 55%, #c8953f); box-shadow: inset 0 0 0 2px #8a5c1c, inset 0 0 0 3px #fff8, 0 0 22px #ffe08acc; }
.g-sheet.gen { width: min(94vw, 520px); }

/* the 主將: a tile (portrait, name, the power), the picker of all of them */
.gen-tile { display: flex; gap: 12px; align-items: center; width: 100%; min-height: 0; padding: 4px 8px; text-align: left; color: var(--ink); font: inherit;
  border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch; background: none; filter: drop-shadow(0 3px 2px #000a); }
button.gen-tile { cursor: pointer; touch-action: manipulation; }
button.gen-tile:hover { filter: brightness(1.12) drop-shadow(0 3px 2px #000a); }
.gen-tile.on { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 9px #f2d27a88); }
.gen-face { flex: none; width: 84px; height: 84px; border-radius: 50%; filter: drop-shadow(0 3px 4px #000b); }
.gen-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gen-name { font: 700 1.12em/1.2 var(--font-head); color: var(--gold-bright); letter-spacing: 0.04em; }
.gen-title { color: var(--ink-dim); font-size: 0.78em; }
.gen-power { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; }
.gen-power em { font: 700 0.95em/1.2 var(--font-btn); font-style: normal; color: #fff3d0; }
.gen-cost { display: grid; place-items: center; flex: none; width: 21px; height: 21px; border-radius: 50%; font: 800 12px/1 'Noto Serif', serif; font-style: normal; color: #fff3dc;
  background: radial-gradient(circle at 35% 30%, #e0503f, #a8241b 60%, #74120c); box-shadow: inset 0 0 0 1px #ffe7bd99; }
.gen-text { font-size: 0.82em; line-height: 1.45; color: var(--ink); }
.gen-cost.inline { display: inline-grid; width: 1.35em; height: 1.35em; margin: 0 0.1em; vertical-align: -0.2em; font-size: 0.9em; }
.gen-pick { max-width: 600px; }
.gen-pick .gen-tile.current { position: relative; }
.gen-pick .gen-tile.current::after { content: '⇄'; position: absolute; right: 6px; top: 2px; color: var(--gold-bright); font-size: 1.1em; opacity: 0.8; }
.gen-picker { position: fixed; inset: 0; z-index: 75; display: grid; place-items: center; padding: 12px; background: #0a0503c4; animation: tipIn 0.2s ease-out; }
.gen-panel { width: min(1000px, 96vw); max-height: 92vh; max-height: 92dvh; overflow-y: auto; padding: 0 6px; border: 28px solid transparent; border-image: url(ui/panel.svg) 40 fill / 28px stretch;
  filter: drop-shadow(0 18px 30px #000d); overscroll-behavior: contain; }
.gen-panel header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gen-panel h2 { margin: 0; font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.06em; display: flex; align-items: center; gap: 10px; }
.gen-rule { margin: 6px 0 10px; color: var(--ink-dim); font-size: 0.86em; line-height: 1.5; }
.gen-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 6px 10px; }
.gen-force { grid-column: 1 / -1; margin: 8px 0 0; font: 700 1em/1.3 var(--font-head); letter-spacing: 0.1em; border-bottom: 1px solid var(--line); }
.gen-force.wei { color: #a9c5ec; } .gen-force.shu { color: #a9dbb4; } .gen-force.wu { color: #f3b19d; } .gen-force.han { color: #f5df94; } .gen-force.qun { color: #cbb6e8; }
@media (max-width: 559px) {
  .gen-panel { border-width: 18px; border-image-width: 18px; }
  .gen-face { width: 64px; height: 64px; }
  .gen-list { grid-template-columns: 1fr; }
  .g-power { width: 40px; height: 40px; }
}

/* a word of advice, sealed with 策 */
/* (in the prompt's place at the board's left edge, while it shows) */
.g-tip { position: absolute; left: calc(8px + var(--safe-l)); top: 41%; transform: translateY(-50%); width: min(34vw, 400px); display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center;
  padding: 0 2px; border: 26px solid transparent; border-image: url(ui/panel.svg) 40 fill / 26px stretch; filter: drop-shadow(0 10px 18px #000c); animation: tipIn 0.3s ease-out; }
.g-tip[hidden] { display: none; }
.g-tip .seal-i { font-size: 1.05em; }
.g-tip p { margin: 0; flex: 1 1 calc(100% - 3em); font-size: 0.92em; line-height: 1.5; }
.g-tip .btn { flex: none; }
@keyframes tipIn { from { opacity: 0; } }
.g-tip .btn { margin-left: auto; }
@media (max-aspect-ratio: 1/1) { .g-tip { width: min(46vw, 400px); } }

/* "your turn": a banner unfurled across the table */
.g-banner { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); font-family: var(--font-head); font-size: clamp(1.4rem, 4.5vw, 2.5rem); font-weight: 700;
  letter-spacing: 0.18em; padding: 0.35em 2em; color: #fff3d0; text-shadow: 0 2px 0 #000, 0 0 18px #ffb46a88; pointer-events: none; white-space: nowrap; opacity: 0;
  background: linear-gradient(90deg, transparent, var(--gold) 22%, var(--gold-bright) 50%, var(--gold) 78%, transparent) top / 100% 2px no-repeat,
    linear-gradient(90deg, transparent, var(--gold) 22%, var(--gold-bright) 50%, var(--gold) 78%, transparent) bottom / 100% 2px no-repeat,
    linear-gradient(90deg, transparent, #5a0c08ee 18%, #9a1d15f2 50%, #5a0c08ee 82%, transparent); }
.g-banner.show { animation: banner 1.6s ease forwards; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scaleX(0.6); } 15%, 75% { opacity: 1; transform: translate(-50%, -50%) scaleX(1); } 100% { opacity: 0; } }

/* who goes first: under the die, its winner on a red band (and, theirs to
   choose, 先攻 and 後攻); then each word stamped on its lord's row */
.g-roll { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: 94vw;
  text-align: center; pointer-events: none; animation: tipIn 0.3s ease-out; }
.g-roll-who { margin: 0; padding: 0.22em 1.8em; font: 700 clamp(1.1rem, 3.2vw, 1.7rem)/1.25 var(--font-head); letter-spacing: 0.12em; color: #fff3d0;
  text-shadow: 0 2px 0 #000, 0 0 14px #ffb46a88; white-space: nowrap;
  background: linear-gradient(90deg, transparent, var(--gold) 22%, var(--gold-bright) 50%, var(--gold) 78%, transparent) top / 100% 2px no-repeat,
    linear-gradient(90deg, transparent, var(--gold) 22%, var(--gold-bright) 50%, var(--gold) 78%, transparent) bottom / 100% 2px no-repeat,
    linear-gradient(90deg, transparent, #5a0c08ee 16%, #9a1d15f2 50%, #5a0c08ee 84%, transparent); }
.g-roll-sub { margin: 0; font-size: 0.95em; color: var(--ink-dim); text-shadow: 0 1px 2px #000, 0 0 8px #000; }
.g-roll-pick { display: flex; gap: 12px; pointer-events: auto; animation: tipIn 0.3s ease-out; }
.g-roll-pick .btn { flex-direction: column; gap: 0; min-width: 8.6em; font-size: 1.12em; letter-spacing: 0.1em; }
.g-roll-pick .btn small { letter-spacing: 0.01em; }
.g-order { position: absolute; left: 0; top: 0; display: grid; justify-items: center; gap: 6px; pointer-events: none; animation: orderLife 3.6s ease forwards; }
.g-order b { display: grid; place-items: center; padding: 0.1em 0.42em 0.14em 0.56em; font: 700 clamp(2.3rem, 7vw, 4.4rem)/1.1 var(--font-seal); letter-spacing: 0.14em;
  border-radius: 10px; transform: rotate(-4deg); -webkit-mask: url(ui/stamp.svg) center / 130px; mask: url(ui/stamp.svg) center / 130px;
  animation: orderStamp 0.5s cubic-bezier(0.2, 1.6, 0.4, 1) var(--delay, 0s) both; }
.g-order.first b { color: #fff3dc; background: radial-gradient(circle at 30% 25%, #e0503f, #a8241b 55%, #74120c); box-shadow: inset 0 0 0 3px #a8241b, inset 0 0 0 5px #ffe7bdbb; }
.g-order.second b { color: var(--gold-bright); background: radial-gradient(circle at 30% 25%, #4a2c1c, #1a0d09 60%, #0c0605); box-shadow: inset 0 0 0 3px #1a0d09, inset 0 0 0 5px #d6b060cc; }
.g-order { filter: drop-shadow(0 6px 10px #000c); }
.g-order.first { filter: drop-shadow(0 6px 10px #000c) drop-shadow(0 0 18px #ff5a3c66); }
.g-order small { padding: 2px 12px; font: 700 0.92rem/1.4 var(--font-btn); color: var(--ink); background: #1a0d09d9; border: 1px solid var(--line); border-radius: 3px;
  text-shadow: 0 1px 2px #000; white-space: nowrap; animation: tipIn 0.4s ease-out calc(var(--delay, 0s) + 0.35s) both; }
.g-order small:empty { display: none; }
html:lang(en) .g-order b { font-family: var(--font-head); letter-spacing: 0.06em; padding: 0.12em 0.5em; }
@keyframes orderStamp { from { opacity: 0; transform: rotate(-4deg) scale(2.4); } to { opacity: 1; transform: rotate(-4deg) scale(1); } }
@keyframes orderLife { 0%, 84% { opacity: 1; } 100% { opacity: 0; } }

/* a choice the table can't show: a framed panel */
.g-sheet { position: absolute; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%); width: min(94vw, 660px); max-height: 62vh; overflow-y: auto;
  padding: 0 4px; border: 28px solid transparent; border-image: url(ui/panel.svg) 40 fill / 28px stretch; filter: drop-shadow(0 18px 30px #000d); }
.g-sheet.low { bottom: calc(34% + var(--safe-b)); }
.g-sheet h3 { margin: 0 0 10px; }
.g-sheet h3::before { display: none; }
.g-sheet-list { display: flex; flex-direction: column; gap: 4px; }
.g-sheet-list .btn { justify-content: flex-start; text-align: left; }
/* a heading inside a sheet (the graveyard's cards, then the exiled ones) */
.g-sheet-sub { grid-column: 1 / -1; margin: 8px 0 0; font: 700 12px/1.3 var(--font-btn); letter-spacing: 0.04em; color: var(--ink-dim); }
.g-sheet-sub:first-child { margin-top: 0; }
.g-sheet.cards .g-sheet-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.g-sheet.cards .g-sheet-list .btn { padding: 0; border: 0; border-image: none; min-height: 0; filter: drop-shadow(0 4px 6px #000b); justify-content: center; }
.g-sheet.cards .g-sheet-list .btn.on { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
/* a card shown but not to be chosen (looked at, not one that may be taken) */
.g-sheet.cards .g-sheet-list .btn.off { opacity: 0.45; filter: grayscale(0.6); cursor: zoom-in; }
.g-sheet .thumb { display: block; width: 100%; height: auto; border-radius: 5%; }
/* the 伏兵 that has sprung, held over its player's choice of target */
.g-sheet .thumb.trapcard { width: min(34%, 120px); margin: 4px auto 8px; cursor: zoom-in; box-shadow: 0 0 14px rgba(160, 110, 255, .7); }
.g-sheet-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
/* a decision's sheet folds down to its title, to look at the table; folded,
   the whole bar opens it again and its chevron pulses to say so */
.g-sheet-fold { float: right; position: sticky; top: 0; z-index: 1; width: 40px; height: 40px; margin: 0 0 6px 10px; border-color: var(--line); background: #1a0d09cc; }
.g-sheet-fold svg { transition: transform 0.2s; }
.g-sheet.decision h3 { min-height: 40px; }
.g-sheet.decision > .g-sheet-list { clear: right; }
.g-sheet.min { width: max-content; max-width: min(94vw, 560px); max-height: none; overflow: visible; cursor: pointer; padding: 0 2px; border-width: 14px; border-image-width: 14px;
  animation: sheetCall 1.3s ease-in-out infinite alternate; }
.g-sheet.min > :not(h3, .g-sheet-fold) { display: none; }
.g-sheet.min h3 { display: block; margin: 0; line-height: 40px; font-size: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-sheet.min h3::after { display: none; }
.g-sheet.min .g-sheet-fold { margin-bottom: 0; animation: foldCall 1.3s ease-out infinite; }
.g-sheet.min .g-sheet-fold svg { transform: rotate(180deg); }
@keyframes sheetCall { from { filter: drop-shadow(0 10px 18px #000d) drop-shadow(0 0 0 #f2d27a00); } to { filter: drop-shadow(0 10px 18px #000d) drop-shadow(0 0 12px #f2d27acc); } }
@keyframes foldCall { 0% { box-shadow: 0 0 0 0 #f2d27acc; transform: scale(1); } 35% { transform: scale(1.12); } 70%, 100% { box-shadow: 0 0 0 12px #f2d27a00; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .g-sheet.min { animation: none; filter: drop-shadow(0 10px 18px #000d) drop-shadow(0 0 10px #f2d27aaa); }
  .g-sheet.min .g-sheet-fold { animation: none; box-shadow: 0 0 0 2px var(--gold-bright); }
}

/* a card with several uses, brought up close: each use it offers lit where
   it's written on the face; the attack (and playing it) on plaques beside */
.g-act { position: absolute; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; gap: 22px 34px; padding: 16px;
  background: radial-gradient(ellipse at 50% 50%, #0a0503a8, #0a0503e6); animation: tipIn 0.18s ease-out; perspective: 1200px; }
.g-act-lean { transition: transform 0.25s ease-out; transform-style: preserve-3d; }
.g-act-card { position: relative; height: min(76vh, 640px); aspect-ratio: 63 / 88; border-radius: 4.5% / 3.2%; filter: drop-shadow(0 22px 34px #000e) drop-shadow(0 0 22px #f2d27a33);
  animation: actIn 0.32s cubic-bezier(0.2, 1.25, 0.4, 1); }
@keyframes actIn { from { opacity: 0.2; transform: translate(var(--from-x, 0), var(--from-y, 40px)) scale(0.32); } }
.g-act-card canvas { display: block; width: 100%; height: 100%; border-radius: inherit; }
.g-act-spots { position: absolute; inset: 0; }
.g-act-spot { position: absolute; padding: 0; border: 0; border-radius: 6px; background: #f2d27a14; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 0 0 1.5px #c8953fcc, 0 0 10px #f2d27a66; animation: spotBreath 1.2s ease-in-out infinite alternate; transition: background 0.15s, box-shadow 0.15s; }
.g-act-spot:hover, .g-act-spot:focus-visible { outline: none; background: #ffd86a3a; box-shadow: 0 0 0 2.5px #fff0b8, 0 0 22px #ffd86acc, inset 0 0 18px #ffd86a55; animation: none; }
.g-act-spot:active { background: #ffd86a66; }
@keyframes spotBreath { from { box-shadow: 0 0 0 1.5px #c8953f99, 0 0 6px #f2d27a33; } to { box-shadow: 0 0 0 2px #f2d27aee, 0 0 16px #f2d27a99; } }
.g-act-side { display: flex; flex-direction: column; align-items: stretch; gap: 10px; max-width: min(320px, 80vw); }
.g-act-hint { margin: 0; color: var(--gold-bright); font-family: var(--font-head); letter-spacing: 0.04em; text-shadow: 0 1px 2px #000; }
.g-act-hint:empty { display: none; }
.g-act-row { display: flex; flex-direction: column; gap: 8px; }
.g-act-row .btn { min-height: 50px; font-size: 1.05em; justify-content: center; }
.g-act-row .btn.use { font-size: 0.92em; text-align: left; justify-content: flex-start; }
@media (max-aspect-ratio: 1/1) {
  .g-act { flex-direction: column; }
  .g-act-card { height: min(64vh, 560px); max-width: 92vw; height: auto; width: min(92vw, calc(64vh * 63 / 88)); }
  .g-act-side { align-items: center; width: min(92vw, 420px); }
  .g-act-row { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
@media (min-aspect-ratio: 1/1) and (max-height: 500px) { .g-act-card { height: 90vh; } .g-act { gap: 16px; } }

/* the battlefield: the chosen one (a strip of its painting), tap to choose
   another from all of them */
.mat-tile { position: relative; display: flex; align-items: flex-end; width: 100%; min-height: 76px; padding: 8px 12px; overflow: hidden; text-align: left; cursor: pointer; touch-action: manipulation;
  color: var(--ink); font: inherit; border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch; background: none; filter: drop-shadow(0 3px 2px #000a); }
.mat-tile::before { content: ''; position: absolute; inset: -4px; background: var(--art, none) center / cover no-repeat; opacity: 0.85; mask: linear-gradient(90deg, transparent, #000 30%); }
.mat-tile::after { content: ''; position: absolute; inset: -4px; background: linear-gradient(90deg, #1a0d09 25%, #1a0d0900 75%); }
.mat-tile > * { position: relative; z-index: 1; }
.mat-tile:hover { filter: brightness(1.12) drop-shadow(0 3px 2px #000a); }
.mat-tile.on { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 9px #f2d27a88); }
.mat-tile b { display: block; font: 700 1.08em/1.2 var(--font-head); color: var(--gold-bright); letter-spacing: 0.04em; }
.mat-tile small { display: block; color: var(--ink-dim); font-size: 0.8em; }
.mat-tile.random::before { content: '🎲'; inset: auto 12px auto auto; top: 50%; transform: translateY(-50%); background: none; font-size: 1.8em; opacity: 0.8; mask: none; }
.mat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 10px; }
.mat-list .mat-tile { min-height: 96px; }

/* ---------------------------------------------------------- the shop and the opening */
.shop-body { flex-direction: row; align-items: center; gap: 30px; flex-wrap: wrap; justify-content: center; max-width: 960px; }
/* a booster pack of brocade, crimped at both ends */
.pack-art {
  position: relative; width: 190px; aspect-ratio: 2 / 3; display: grid; place-items: center; overflow: hidden;
  background: repeating-linear-gradient(45deg, #ffffff08 0 6px, transparent 6px 12px), repeating-linear-gradient(-45deg, #0000000d 0 6px, transparent 6px 12px),
    linear-gradient(160deg, #7a1410, #c8382b 45%, #8e1b14 70%, #4a0c08);
  filter: drop-shadow(0 22px 26px #000b);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 51% repeat-x, conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 12px 51% repeat-x;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / 12px 51% repeat-x, conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / 12px 51% repeat-x;
}
.pack-art.painted { background: var(--art) center / cover; }
.pack-art::before { content: ''; position: absolute; inset: 14px 10px; border: 1px solid #f2d27aaa; box-shadow: inset 0 0 0 3px #8e1b14, inset 0 0 0 4px #f2d27a66; pointer-events: none; }
.pack-art::after { content: ''; position: absolute; inset: -50%; background: linear-gradient(115deg, #0000 40%, #ffffff40 50%, #0000 60%); animation: sheen 3.2s infinite; }
@keyframes sheen { from { transform: translateX(-60%); } to { transform: translateX(60%); } }
.pack-face { width: 116px; height: 116px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--gold-bright); font: 700 1.6em/1.15 var(--font-seal); letter-spacing: 0.05em; text-shadow: 0 2px 0 #3a0a06;
  background: radial-gradient(circle, #6a100b 0 60%, #4a0a07 61% 63%, transparent 64%), conic-gradient(from 0deg, #fff0b8, #c8953f, #6e4614, #e8c46a, #8a5c1c, #fff0b8);
  box-shadow: 0 6px 18px #000a; }
html:lang(en) .pack-face { font-family: 'Cinzel', serif; font-size: 1.15em; }
/* 三分天下 reads down the seal, but in English it's still Realm Divided */
html:lang(en) .pack-face b:last-child { order: -1; }
.shop-side { display: flex; flex-direction: column; gap: 10px; max-width: 460px; }
.shop-side .row.buttons .btn { flex: 1 1 11em; }
.shop-note, .shop-hint { color: var(--ink-dim); margin: 0; line-height: 1.6; }
.shop-stock { font-size: 1.25em; margin: 0; font-family: var(--font-head); color: var(--gold-bright); }
.op-prompt { position: absolute; left: 50%; transform: translateX(-50%); top: calc(18px + var(--safe-t)); margin: 0; padding: 7px 32px; width: max-content; max-width: calc(100vw - 20px); text-align: center; text-wrap: balance; text-shadow: 0 1px 2px #000;
  background: linear-gradient(var(--gold), var(--gold)) top / 100% 1px no-repeat, linear-gradient(var(--gold), var(--gold)) bottom / 100% 1px no-repeat, linear-gradient(180deg, #3e1e12f2, #1d0e08f2);
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 50%, 100% 100%, 0 100%, 14px 50%); }
.op-actions { position: absolute; left: 0; right: 0; bottom: calc(16px + var(--safe-b)); display: flex; justify-content: center; gap: 10px; }
.op-tags { position: absolute; inset: 0; pointer-events: none; }
.op-tag { position: absolute; left: 0; top: 0; font: 700 0.8em/1.3 var(--font-btn); color: #3a1d05; padding: 2px 10px; border-radius: 3px;
  background: linear-gradient(180deg, #fff1b0, #f2c654 55%, #c8953f); box-shadow: 0 2px 8px #000a, inset 0 0 0 1px #8a5c1c; }
.op-tag.foil { background: linear-gradient(90deg, #ff9ad8, #9ad8ff, #c8ff9a, #ffe08a); }

/* ---------------------------------------------------------- collection and decks */
.filters { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; margin: 0 0 14px; }
.filters input { width: 13em; }
.filters .seg > button { min-height: 36px; font-size: 0.88em; padding: 0 0.35em; }
/* the five forces' seals, in their own colours */
.seg > button[data-v="wei"] { color: #a9c5ec; } .seg > button[data-v="shu"] { color: #a9dbb4; } .seg > button[data-v="wu"] { color: #f3b19d; }
.seg > button[data-v="han"] { color: #f5df94; } .seg > button[data-v="qun"] { color: #cbb6e8; }
.seg > button:is([data-v="wei"], [data-v="shu"], [data-v="wu"], [data-v="han"], [data-v="qun"]) { font-family: var(--font-seal); font-size: 1em; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.card-grid.small { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 9px; }
.card-cell { position: relative; cursor: pointer; border: none; background: none; padding: 0; color: var(--ink); font: inherit; text-align: center; }
/* a card leans towards the mouse and catches the light where it points
   (collection.js tilting: --mx/--my, 0–1 across the card; .lift while it's over) */
@property --mx { syntax: '<number>'; inherits: true; initial-value: 0.5; }
@property --my { syntax: '<number>'; inherits: true; initial-value: 0.5; }
@property --lift { syntax: '<number>'; inherits: true; initial-value: 0; }
.card-cell { --mx: 0.5; --my: 0.5; --lift: 0; transition: --mx 0.6s ease, --my 0.6s ease, --lift 0.45s ease; }
.card-cell.lift { --lift: 1; z-index: 1; transition: --mx 0.08s linear, --my 0.08s linear, --lift 0.2s ease-out; }
.card-cell .tilt { position: relative; display: block; border-radius: 5%; isolation: isolate; box-shadow: 0 calc(8px + 8px * var(--lift)) calc(16px + 12px * var(--lift)) #000b;
  transform: perspective(800px) rotateY(calc((var(--mx) - 0.5) * -24deg * var(--lift))) rotateX(calc((var(--my) - 0.5) * 20deg * var(--lift))) scale(calc(1 + 0.05 * var(--lift))); }
.card-cell canvas { width: 100%; height: auto; display: block; border-radius: 5%; aspect-ratio: 63 / 88; background: #120a06; }
.card-cell.none canvas { filter: grayscale(1) brightness(0.45); }
.card-cell .count { position: absolute; right: 6px; top: 6px; min-width: 1.9em; padding: 1px 7px; font: 900 0.82em/1.4 'Noto Serif', serif; color: var(--gold-bright);
  background: radial-gradient(circle at 40% 30%, #4a2614, #1a0d09); border-radius: 999px; box-shadow: 0 2px 5px #000b, inset 0 0 0 1.5px var(--gold); }
.card-cell .foilmark { position: absolute; left: 6px; top: 6px; font-size: 0.8em; padding: 0 6px; border-radius: 3px; color: #1a0d09; font-weight: 900; background: linear-gradient(90deg, #ff9ad8, #9ad8ff, #c8ff9a, #ffe08a); box-shadow: 0 2px 4px #0008; }
.card-cell :is(.shine, .gleam, .glare) { position: absolute; inset: 0; border-radius: 5%; pointer-events: none; }
.card-cell .glare { mix-blend-mode: overlay; opacity: var(--lift);
  background: radial-gradient(farthest-corner circle at calc(var(--mx) * 100%) calc(var(--my) * 100%), #fffd 6%, #fff5 24%, #0006 95%); }
/* foils, after the 3D card's (cards3d.js): round where the mouse points the rainbow
   tints the card (.shine) and bright streaks in the foil's pattern dodge it (.gleam);
   faint at rest, bright under the mouse */
.card-cell :is(.shine, .gleam) { --at: calc(var(--mx) * 100%) calc(var(--my) * 100%); --glow: radial-gradient(farthest-corner circle at var(--at), #fff 0%, #555 28%, #000 62%);
  clip-path: inset(1.6% round 4%); -webkit-mask-image: linear-gradient(#000 60.4%, #0004 61.2% 93.2%, #000 94%); mask-image: linear-gradient(#000 60.4%, #0004 61.2% 93.2%, #000 94%); }
.card-cell.foil { --rainbow: linear-gradient(180deg, #ff5a5a, #ffd84a, #8cff5a, #4affe0, #5a8cff, #d85aff, #ff5a5a); }
.card-cell .shine { mix-blend-mode: overlay; opacity: calc(0.4 + 0.45 * var(--lift));
  background-image: radial-gradient(farthest-corner circle at var(--at), #80808000 0%, #808080 70%), var(--rainbow);
  background-size: 100% 100%, 300% 300%;
  background-position: center, calc(50% + (var(--mx) - 0.5) * 160%) calc(50% + (var(--my) - 0.5) * 120%); }
/* a slow rainbow down the card and bright lines at 133° */
.card-cell .gleam { mix-blend-mode: color-dodge; opacity: calc(0.35 + 0.65 * var(--lift));
  background-image: var(--glow), var(--rainbow), repeating-linear-gradient(133deg, #000 0% 7%, #999 8.6%, #fff 9.2%, #999 9.8%, #000 11.4% 20%);
  background-size: 100% 100%, 100% 400%, 280% 280%;
  background-position: center, 0% calc(50% - (var(--my) - 0.5) * 220%), calc(50% + (var(--mx) - 0.5) * 170%) calc(50% + (var(--my) - 0.5) * 120%);
  background-blend-mode: multiply, multiply; }
/* 低 graphics: the sheens only under the mouse */
body[data-quality="low"] .card-cell:not(.lift) :is(.shine, .gleam) { display: none; }
.deck-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.deck-tile { position: relative; isolation: isolate; overflow: hidden; display: flex; flex-direction: column; gap: 6px; min-height: 132px; padding: 0 4px;
  border: 26px solid transparent; border-image: url(ui/panel.svg) 40 fill / 26px stretch; filter: drop-shadow(0 6px 10px #000b); }
.deck-tile::before { content: ''; position: absolute; inset: 0; z-index: -1; border-radius: 2px; background: linear-gradient(135deg, var(--c1, #3b2216), var(--c2, #1a0d09)); opacity: 0.75; }
.deck-tile::after { content: attr(data-glyph); position: absolute; right: 0; top: -0.1em; z-index: -1; font: 700 4em/1 var(--font-seal); color: #fff; opacity: 0.1; }
.deck-tile.painted::before { opacity: 1; background: linear-gradient(90deg, var(--c2) 0%, color-mix(in srgb, var(--c2) 78%, transparent) 40%, color-mix(in srgb, var(--c2) 18%, transparent) 80%), var(--art) 70% center / cover; }
.deck-tile.painted::after { display: none; }
.deck-tile.painted b, .deck-tile.painted small, .deck-pick button.painted b, .deck-pick button.painted small { text-shadow: 0 1px 2px #000, 0 0 8px #000d; }
.deck-tile b { font-size: 1.1em; font-family: var(--font-btn); letter-spacing: 0.02em; }
.deck-tile small { color: var(--ink-dim); }
.deck-tile .row { margin-top: auto; }
.editor { display: grid; grid-template-columns: 1fr clamp(340px, 30vw, 440px); gap: 14px; align-items: start; }
.editor-deck { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; max-height: calc(100dvh - 90px); overflow-y: auto; }
.editor-deck.framed { padding: 0 2px; border-width: 24px; border-image-width: 24px; }
.editor-deck input { width: 100%; font-weight: 700; }
.ed-stats { margin: 0; color: var(--ink-dim); font-size: 0.92em; }
.curve { display: flex; align-items: flex-end; gap: 4px; height: 44px; margin: 14px 0 12px; }
/* each cost's bar is a button: it filters the pool to that cost (its count above) */
.curve .cv { flex: 1; height: 100%; display: flex; align-items: flex-end; padding: 0; border: none; background: none; cursor: pointer; border-radius: 2px; touch-action: manipulation; }
.curve .cv:hover i { filter: brightness(1.22); }
.curve .cv[aria-pressed="true"] i { box-shadow: inset 0 1px 0 #fff6, 0 0 0 2px #e0553f, 0 0 8px #e0553f88; }
.curve i::before { content: attr(data-c); position: absolute; top: -1.3em; left: 0; right: 0; text-align: center; font-size: 0.68em; color: var(--ink-dim); }
.curve i { flex: 1; position: relative; min-height: 2px; border-radius: 2px 2px 0 0; background: linear-gradient(90deg, #8a5c1c, #f2d27a 45%, #c8953f); box-shadow: inset 0 1px 0 #fff6, 0 0 6px #f2d27a33; }
.curve i::after { content: attr(data-n); position: absolute; bottom: -1.4em; left: 0; right: 0; text-align: center; font-size: 0.7em; color: var(--ink-dim); }
.ed-cards { list-style: none; margin: 4px 0 0; padding: 0; overflow-y: auto; flex: 1; min-height: 9em; display: flex; flex-direction: column; gap: 3px; }
.ed-cards li.dk { display: flex; border-radius: 3px; font-size: 0.9em;
  background: linear-gradient(90deg, #3a1f12, #22110a); box-shadow: inset 0 0 0 1px #d6b06033; transition: background 0.12s; }
.ed-cards li.dk:hover { background: linear-gradient(90deg, #5a3018, #2a150b); }
.dk-card { display: flex; align-items: center; gap: 6px; width: 100%; padding: 5px 8px; border: none; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; touch-action: manipulation; }
.dk-card .cost { color: var(--gold-bright); font-size: 0.8em; min-width: 3.5em; text-align: right; }
.dk-card .n { font-weight: 900; color: var(--gold-bright); min-width: 1.6em; }
.dk-card .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-problems { color: #ff9a80; margin: 0; font-size: 0.88em; }
/* the panel's rows of buttons: each on one line, to leave the list room */
.editor-deck .row.buttons { gap: 6px; }
.editor-deck .row.buttons .btn { font-size: 0.84em; }

/* ---------------------------------------------------------- deck editor: sorting, groups, mini cards, dragging
   (collection.js DeckEditor and ui/draft.js; the gestures are ui/press.js) */
.sort-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; flex: 1 0 100%; }
.sort-label { color: var(--ink-dim); font-family: var(--font-head); letter-spacing: 0.04em; }
.sort-bar .seg > button { min-height: 36px; font-size: 0.88em; padding: 0 0.35em; }
/* a header over a group of cards: its name, how many, a rule */
.grp { grid-column: 1 / -1; flex: 1 0 100%; display: flex; align-items: baseline; gap: 0.6em; margin: 8px 0 0; font: 700 0.95em/1.3 var(--font-head); letter-spacing: 0.05em; color: var(--gold-bright); }
.grp::after { content: ''; flex: 1; height: 1px; align-self: center; background: linear-gradient(90deg, var(--line), transparent); }
.grp small { color: var(--ink-dim); font: 400 0.9em var(--font); }
.grp small::before { content: '('; } .grp small::after { content: ')'; }
.card-grid > .grp:first-child, .ed-cards > .grp:first-child { margin-top: 0; }
.ed-none, .ed-cards li.empty { grid-column: 1 / -1; margin: 10px 0; color: var(--ink-dim); font-style: italic; text-align: center; list-style: none; }
.ed-tip { margin: 0; color: var(--ink-dim); font-size: 0.78em; text-align: center; }
/* the toolbar over the deck's list: undo, redo, copy, import · how the deck is shown */
.ed-tools { display: flex; align-items: center; gap: 8px; }
.ed-tools .seg { flex: none; flex-wrap: nowrap; }
.ed-tools .ed-views { margin-left: auto; }
.ed-tools .seg > button { display: grid; place-items: center; min-width: 34px; min-height: 30px; padding: 0; border-width: 7px; border-image-width: 7px; }
.ed-tools .seg > button svg { display: block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
/* the deck's spells by force, and a word on its territories */
.ed-forces { margin: 0; color: var(--ink-dim); font-size: 0.88em; }
.ed-forces:empty, .ed-advice:empty { display: none; }
.ed-forces [data-f] { font-family: var(--font-seal); }
.ed-forces [data-f="wei"] { color: #a9c5ec; } .ed-forces [data-f="shu"] { color: #a9dbb4; } .ed-forces [data-f="wu"] { color: #f3b19d; }
.ed-forces [data-f="han"] { color: #f5df94; } .ed-forces [data-f="qun"] { color: #cbb6e8; }
.ed-advice { margin: 0; color: var(--gold-bright); font-size: 0.86em; }
.clear-filters[hidden] { display: none; }
/* a mouse resting on a card: it, larger, beside it (ui/peek.js) */
.peek { position: fixed; z-index: 80; pointer-events: none; border-radius: 5%; box-shadow: 0 16px 34px #000d, 0 0 0 2px #f2d27a88; animation: peekIn 0.12s ease-out; }
.peek canvas { display: block; width: 100%; height: auto; border-radius: 5%; }
@keyframes peekIn { from { opacity: 0; translate: 0 4px; } }
/* a deck as text, to copy or paste (ui/decklist.js) */
.dl-modal { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 12px; background: #0a0503c4; animation: tipIn 0.2s ease-out; }
.dl-panel { width: min(560px, 94vw); max-height: 92vh; max-height: 92dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px;
  border: 28px solid transparent; border-image: url(ui/panel.svg) 40 fill / 28px stretch; filter: drop-shadow(0 18px 30px #000d); overscroll-behavior: contain; }
.dl-panel h2 { margin: 0; font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.06em; }
.dl-hint { margin: 0; color: var(--ink-dim); font-size: 0.86em; line-height: 1.5; }
.dl-text { width: 100%; box-sizing: border-box; min-height: 10em; resize: vertical; font: 16px/1.5 var(--font); color: var(--ink-dark); background: var(--paper) url(ui/paper.svg);
  border: 1px solid #7a5a2a; border-radius: 3px; padding: 0.5em 0.7em; box-shadow: inset 0 2px 4px #0003, 0 0 0 1px #d6b06055; -webkit-user-select: text; user-select: text; }
.dl-panel .row.buttons { justify-content: flex-end; }
/* no more copies can go in: the pool card is dimmed (a tap still says why) */
.card-cell.full canvas { filter: grayscale(0.7) brightness(0.6); }
.card-grid.small, .ed-cards { -webkit-user-select: none; user-select: none; }
/* the deck as mini cards; extra copies peek out behind the first */
.ed-cards[data-view="mini"] { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px 9px; align-content: start; padding: 4px 8px 8px 3px; }
.ed-cards[data-view="mini"] li.dk { background: none; box-shadow: none; }
.ed-cards[data-view="mini"] .dk-card { position: relative; display: block; width: auto; padding: 0; border-radius: 5%; box-shadow: 0 3px 6px #000a; transition: translate 0.12s, box-shadow 0.12s; }
.ed-cards[data-view="mini"] .dk-card:hover, .ed-cards[data-view="mini"] .dk-card:focus-visible { translate: 0 -3px; box-shadow: 0 6px 10px #000c, 0 0 0 1.5px var(--gold); }
.ed-cards[data-view="mini"] li[data-n="2"] .dk-card { box-shadow: 3px -3px 0 #3a2415, 3px -3px 0 1px #d6b06055, 0 3px 6px #000a; }
.ed-cards[data-view="mini"] li:is([data-n="3"], [data-n="4"], [data-n="5"]) .dk-card { box-shadow: 3px -3px 0 #3a2415, 3px -3px 0 1px #d6b06055, 6px -6px 0 #2a190e, 6px -6px 0 1px #d6b06044, 0 3px 6px #000a; }
.dk-card canvas { display: block; width: 100%; height: auto; aspect-ratio: 63 / 88; border-radius: 5%; background: #120a06; }
.ed-cards[data-view="mini"] .dk-card .n { position: absolute; right: -5px; bottom: -5px; min-width: 1.8em; padding: 0 5px; text-align: center; font: 900 0.78em/1.5 'Noto Serif', serif; color: var(--gold-bright);
  background: radial-gradient(circle at 40% 30%, #4a2614, #1a0d09); border-radius: 999px; box-shadow: 0 2px 4px #000b, inset 0 0 0 1.5px var(--gold); }
.ed-cards[data-view="mini"] li[data-n="1"] .n { display: none; }
/* a card held down gives a little, so a hold feels like it's going somewhere */
.pressing { animation: pressDown 0.33s 0.15s ease-out forwards; }
@keyframes pressDown { to { scale: 0.94; filter: brightness(1.18); } }
/* dragging with the mouse: the ghost, and where it may land */
body.dd-active, body.dd-active * { cursor: grabbing !important; }
.dd-ghost { position: fixed; left: 0; top: 0; z-index: 90; width: 76px; pointer-events: none; border-radius: 5%; rotate: -4deg; box-shadow: 0 14px 24px #000c, 0 0 0 2px var(--gold-bright); will-change: transform; }
.dd-ghost canvas { display: block; width: 100%; height: auto; aspect-ratio: 63 / 88; border-radius: 5%; }
.dd-ghost.ok { box-shadow: 0 14px 24px #000c, 0 0 0 3px #9be58a, 0 0 18px #9be58a88; }
.dd-ghost.no { opacity: 0.65; box-shadow: 0 14px 24px #000c, 0 0 0 3px #e0553f; }
[data-drag="pool"] .editor-deck .ed-cards { box-shadow: inset 0 0 0 1px #f2d27a66; border-radius: 4px; }
.editor-deck.dd-over .ed-cards { background: #f2d27a22; box-shadow: inset 0 0 0 2px var(--gold-bright); border-radius: 4px; }
[data-drag="deck"] .editor-pool { outline: 1px dashed #f2d27a66; outline-offset: 4px; border-radius: 6px; }
.editor-pool.dd-over { background: #f2d27a14; outline: 2px dashed var(--gold-bright); }
@media (max-width: 760px) {
  .editor { grid-template-columns: 1fr; }
  .editor-deck { position: static; max-height: none; }
  .seats { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------- help: a paper scroll */
.help-body { position: relative; line-height: 1.75; color: var(--ink-dark); padding: 26px clamp(18px, 4vw, 40px) 30px; margin-top: 14px; margin-bottom: 16px; border-radius: 2px;
  background: var(--paper) url(ui/paper.svg); box-shadow: 0 20px 50px #000c, inset 0 0 50px #8a5c1c40; }
.help-body::before, .help-body::after { content: ''; position: absolute; left: -12px; right: -12px; height: 18px; border-radius: 9px; box-shadow: 0 3px 6px #000a;
  background: radial-gradient(circle at 9px 50%, #f2d27a 0 5px, #8a5c1c 6px 7px, transparent 8px), radial-gradient(circle at calc(100% - 9px) 50%, #f2d27a 0 5px, #8a5c1c 6px 7px, transparent 8px),
    linear-gradient(180deg, #7a4626, #3f1f0e 55%, #26120a); }
.help-body::before { top: -10px; }
.help-body::after { bottom: -10px; }
.help-body h3 { color: var(--cinnabar); }
.help-body h3::before { background: linear-gradient(135deg, #e0553f, #8e1b14); box-shadow: none; }
.help-body h3::after { background: linear-gradient(90deg, #8e1b1455, transparent); }
.help-body b { color: #5a1a0e; }
.help-body ol, .help-body ul { padding-left: 1.4em; }
.forces-help li { margin: 4px 0; }
.forces-help b { padding: 0 6px; border-radius: 3px; margin-right: 6px; }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.glossary dt { font-weight: 900; color: var(--cinnabar); font-family: var(--font-head); }
.glossary dd { margin: 0; }

/* the rules page: a contents row, and figures (the real table, with numbers
   on it) whose legends carry the same numbers; the pictures are made by
   dev/help-shots.* */
.help-toc { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 4px; }
.help-toc a { padding: 1px 12px; border: 1px solid var(--gold-deep); border-radius: 14px; background: #fff7; color: var(--cinnabar); font-size: .9em; text-decoration: none; }
.help-toc a:hover, .help-toc a:focus-visible { background: var(--cinnabar); color: var(--paper); outline: none; }
.help-body h3 { scroll-margin-top: 14px; }
.help-quick { counter-reset: qs; list-style: none; padding-left: 0; }
.help-body .help-quick li { counter-increment: qs; position: relative; padding-left: 2em; margin: 3px 0; }
.help-body .help-quick li::before { content: counter(qs); position: absolute; left: 0; top: .15em; width: 1.4em; height: 1.4em; border-radius: 3px; background: var(--cinnabar); color: var(--paper); font: 900 .85em/1.4em var(--font-head); text-align: center; }
.help-fig { margin: 10px 0 20px; }
.help-fig figcaption { margin: 0 0 6px; font-family: var(--font-head); font-weight: 900; color: var(--cinnabar); }
.help-fig .shot { overflow-x: auto; border: 2px solid var(--gold-deep); border-radius: 4px; background: #120a07; box-shadow: 0 8px 22px #0006; }
.help-fig img { display: block; width: 100%; min-width: 600px; height: auto; }
.help-body .legend { list-style: none; counter-reset: lg; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 8px 22px; }
.help-body .legend li { counter-increment: lg; position: relative; min-height: 28px; padding-left: 38px; }
.help-body .legend li::before { content: counter(lg); position: absolute; left: 0; top: .05em; width: 27px; height: 27px; box-sizing: border-box; border-radius: 50%; background: #b3261e; border: 2px solid var(--gold); box-shadow: 0 0 0 1px #3a0d08; color: #fff3d6; font: 900 15px/23px var(--font-head); text-align: center; }
.help-fig.card { display: grid; grid-template-columns: minmax(0, 390px) 1fr; grid-template-areas: "cap cap" "shot legend"; gap: 0 24px; align-items: start; }
.help-fig.card figcaption { grid-area: cap; }
.help-fig.card .shot { grid-area: shot; }
.help-fig.card img { min-width: 0; }
.help-fig.card .legend { grid-area: legend; grid-template-columns: 1fr; margin: 0; }
@media (max-width: 760px) { .help-fig.card { display: block; } .help-fig.card .legend { margin-top: 12px; } }

/* ---------------------------------------------------------- the zoom, modals, loading, toasts */
.zoom { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; gap: 18px; padding: 16px; background: radial-gradient(ellipse at 50% 40%, #1a0d09cc, #000e); flex-wrap: wrap; overflow-y: auto; overflow-x: hidden; }
/* the card in 3D (viewer.js): the canvas reaches round the card's box so it can turn */
.zoom-card { width: min(82vw, 400px, 56dvh); aspect-ratio: 63 / 88; position: relative; margin: max(12px, 3dvh) 3%; }
.zoom-card .viewer { position: absolute; left: -14%; top: -10%; width: 128%; height: 120%; display: block; outline: none; cursor: grab; }
.zoom-card .viewer:active { cursor: grabbing; }
.zoom-card:has(.viewer:focus-visible)::after { content: ''; position: absolute; inset: -6px; border-radius: 6%; pointer-events: none; box-shadow: 0 0 0 2px var(--gold-bright), 0 0 18px #f2d27a66; }
.zoom-card.flat canvas { width: 100%; height: auto; display: block; border-radius: 4.5%; box-shadow: 0 20px 60px #000; }
.zoom-card.flat.foil::after { content: ''; position: absolute; inset: 0; border-radius: 4.5%; pointer-events: none; mix-blend-mode: color-dodge; opacity: 0.5;
  background: linear-gradient(115deg, #ff94944d, #8affec4d 35%, #ffe48a4d 60%, #e594ff4d 85%); }
.zoom-hint { margin: 10px 0 0; color: var(--ink-dim); font-size: 0.85em; }
.zoom-side { max-width: 380px; position: relative; min-height: 2.6em; padding: 0 30px 0 4px; border: 28px solid transparent; border-image: url(ui/panel.svg) 40 fill / 28px stretch; }
.zoom-close { position: absolute; right: -20px; top: -22px; width: 40px; height: 40px; background: none; border: none; color: var(--gold-bright); font-size: 1.6em; cursor: pointer; }
.zoom-now { color: var(--gold-bright); margin: 0 0 8px; font-weight: 700; }
.zoom-now:empty { display: none; }
.zoom-terms { margin: 0; display: grid; gap: 4px 10px; grid-template-columns: max-content 1fr; font-size: 0.92em; }
.zoom-terms dt { font-weight: 900; color: var(--gold-bright); font-family: var(--font-head); }
.zoom-terms dd { margin: 0; }
.zoom-flavor { margin: 10px 0 0; padding-top: 8px; border-top: 1px solid #d8b56a40; font-style: italic; color: var(--ink-dim); font-size: 0.92em; line-height: 1.5; }
.zoom-terms:empty + .zoom-flavor { margin-top: 0; padding-top: 0; border-top: none; }
.zoom-flavor cite { display: block; margin-top: 4px; text-align: right; font-size: 0.88em; }
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 45%, #0008, #000c); padding: 26px 16px; }
/* a hanging scroll: paper between two rollers */
.modal-box { position: relative; width: min(88vw, 380px); display: flex; flex-direction: column; gap: 10px; text-align: center; padding: 30px 24px 26px; border-radius: 2px;
  color: var(--ink-dark); background: var(--paper) url(ui/paper.svg); box-shadow: 0 24px 60px #000, inset 0 0 40px #8a5c1c40; animation: unroll 0.35s ease-out; }
.modal-box::before, .modal-box::after { content: ''; position: absolute; left: -14px; right: -14px; height: 18px; border-radius: 9px; box-shadow: 0 3px 6px #000a;
  background: radial-gradient(circle at 9px 50%, #f2d27a 0 5px, #8a5c1c 6px 7px, transparent 8px), radial-gradient(circle at calc(100% - 9px) 50%, #f2d27a 0 5px, #8a5c1c 6px 7px, transparent 8px),
    linear-gradient(180deg, #7a4626, #3f1f0e 55%, #26120a); }
.modal-box::before { top: -10px; }
.modal-box::after { bottom: -10px; }
@keyframes unroll { from { clip-path: inset(48% -20px 48% -20px); } to { clip-path: inset(-20px -20px -20px -20px); } }
.modal-box h2 { margin: 0 0 4px; font-family: var(--font-head); color: var(--cinnabar); font-size: 1.9em; letter-spacing: 0.1em; }
/* the ≡ menu's settings: quality and volume, ruled off on the scroll */
.p-settings { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; padding: 10px 0; border-block: 1px solid #8a5c1c55; }
.p-row { display: flex; align-items: center; justify-content: center; gap: 6px 8px; flex-wrap: wrap; }
.p-row .label { min-width: 4.2em; text-align: left; font-family: var(--font-head); font-weight: 700; color: var(--cinnabar); letter-spacing: 0.04em; }
.p-row .seg > button { min-height: 34px; font-size: 0.86em; }
.p-row input[type="range"] { flex: 1 1 110px; min-width: 90px; accent-color: var(--vermilion); }
.p-row output { min-width: 3em; font: 700 0.9em/1 'Noto Serif', serif; color: var(--ink-dark); font-variant-numeric: tabular-nums; }
.p-row .btn.small { min-height: 34px; }
.p-row.p-start { justify-content: flex-start; }
.modal-box p { margin: 0 0 4px; }
.result-seal { align-self: center; display: grid; place-items: center; width: 92px; height: 92px; margin: -6px 0 4px; font: 700 3.6em/1 var(--font-seal);
  color: #fff3dc; border-radius: 8px; transform: rotate(-6deg); background: radial-gradient(circle at 30% 25%, #e0503f, #a8241b 55%, #74120c);
  box-shadow: inset 0 0 0 3px #a8241b, inset 0 0 0 5px #ffe7bdbb; -webkit-mask: url(ui/stamp.svg) center / 120px; mask: url(ui/stamp.svg) center / 120px;
  animation: stamp 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) 0.15s both; }
.result-seal:empty { display: none; }
/* why the game ended (a deck run dry, a concession…), under the verdict */
.result-why { font-weight: 700; color: var(--ink-dark); }
.result-why:empty { display: none; }
.result-seal.lost { background: radial-gradient(circle at 30% 25%, #6a5a4a, #3a2a1e 55%, #1e140c); box-shadow: inset 0 0 0 3px #3a2a1e, inset 0 0 0 5px #e8d8bcaa; }
.result-seal.draw { background: radial-gradient(circle at 30% 25%, #8fe0ad, #2e8a4f 55%, #154a2a); box-shadow: inset 0 0 0 3px #154a2a, inset 0 0 0 5px #f2d27aaa; }
@keyframes stamp { from { opacity: 0; transform: rotate(-6deg) scale(2.2); } to { opacity: 1; transform: rotate(-6deg) scale(1); } }
.loading { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(ellipse at 50% 45%, #2a140c, #0b0605 70%); color: var(--ink-dim); font-family: var(--font-head); letter-spacing: 0.12em; }
.loading .seal { width: 88px; height: 88px; border-radius: 10px; color: #fff1d0; display: grid; place-items: center; font: 700 1.8em/1.05 var(--font-seal);
  writing-mode: vertical-rl; letter-spacing: 0.08em; background: radial-gradient(circle at 30% 25%, #dc4a3c, #a8241b 55%, #7a140e);
  box-shadow: inset 0 0 0 3px #a8241b, inset 0 0 0 4px #ffe7bdaa; -webkit-mask: url(ui/stamp.svg) center / 120px; mask: url(ui/stamp.svg) center / 120px;
  animation: breathe 1.4s ease-in-out infinite alternate; }
@keyframes breathe { to { transform: scale(1.06) rotate(-2deg); } }
/* how much is loaded (js/preload.js sets --p): a gold line in a lacquer groove */
.loading .load-bar { width: min(240px, 62vw); height: 6px; border-radius: 3px; background: #1a0c08; box-shadow: inset 0 1px 2px #000, 0 0 0 1px #6a3a1c88; overflow: hidden; }
.loading .load-bar i { display: block; width: var(--p, 0%); height: 100%; border-radius: inherit; background: linear-gradient(90deg, #a8741c, #f1d27a); box-shadow: 0 0 8px #f1d27a88; transition: width 0.25s ease-out; }
.toasts { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { padding: 0 8px; border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch; filter: drop-shadow(0 8px 14px #000b); animation: tipIn 0.25s ease-out; text-shadow: 0 1px 2px #000; }
.toast.bad { border-image-source: url(ui/plaque-red.svg); }
/* a dropped connection being made again: stays up until it is (or isn't) */
.reconnecting { position: fixed; top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%); z-index: 71; max-width: calc(100vw - 32px); text-align: center; pointer-events: none; border-image-source: url(ui/plaque-red.svg); animation: tipIn 0.25s ease-out, reconnecting 1.6s ease-in-out 0.25s infinite; }
.reconnecting[hidden] { display: none; }
@keyframes reconnecting { 50% { opacity: 0.72; } }
@media (prefers-reduced-motion: reduce) { .reconnecting { animation: none; } }

/* a phone held sideways: little height, so a slimmer HUD */
@media (min-aspect-ratio: 1/1) and (max-height: 500px) {
  .g-player { min-height: 44px; padding: 0 8px; gap: 6px; font-size: 0.85em; max-width: 38vw; border-width: 9px; border-image-width: 9px; }
  .g-player.me, .g-player.opp { left: calc(18px + var(--safe-l)); }
  .g-prompt { font-size: 0.78em; max-width: 27vw; padding: 4px 18px 4px 10px; }
  .g-phase { top: calc(6px + var(--safe-t)); right: calc(104px + var(--safe-r)); font-size: 0.8em; border-width: 8px; border-image-width: 8px; }
  .g-actions .btn { min-width: 6em; min-height: 44px; padding: 0.1em 0.6em; font-size: 0.9em; border-width: 10px; border-image-width: 10px; }
  .g-log { top: calc(48px + var(--safe-t)); max-height: 60vh; }
  .g-sheet { border-width: 20px; border-image-width: 20px; }
  .g-guard { min-width: 56px; height: 56px; font-size: 1em; padding: 0 8px; }
  .g-go { min-height: 36px; padding: 5px 12px; font-size: 0.92em; }
  .g-main { --d: 86px; font-size: 1.02em; padding: 8px; }
  .g-actions { right: calc(10px + var(--safe-r)); bottom: calc(10px + var(--safe-b)); gap: 8px; }
  .g-ready i { width: 32px; height: 32px; font-size: 18px; }
  .g-all { min-width: 44px; height: 44px; font-size: 0.85em; }
  .g-lordhp { width: 40px; height: 40px; }
  .g-lordhp b { font-size: 1.1em; }
}

@media (max-aspect-ratio: 1/1) {
  .g-phase { top: calc(60px + var(--safe-t)); right: calc(10px + var(--safe-r)); font-size: 0.85em; border-width: 8px; border-image-width: 8px; min-width: 5.6em; }
  .g-prompt { font-size: 0.86em; max-width: min(30vw, 280px); }
  .g-actions .btn { min-width: 6.5em; min-height: 48px; padding: 0.1em 0.6em; font-size: 0.95em; }
  /* (the hand is the screen's width: my plaque stands above it) */
  .g-player.me { top: auto; bottom: calc(18.6vh + 8px + var(--safe-b)); left: calc(14px + var(--safe-l)); }
  .g-player.opp { left: calc(14px + var(--safe-l)); top: calc(8px + var(--safe-t)); }
  .g-player { max-width: 58vw; min-height: 46px; padding: 0 8px; gap: 6px; border-width: 10px; border-image-width: 10px; }
  .g-name { font-size: 0.9em; }
  .g-sheet { bottom: calc(18.6vh + 60px + var(--safe-b)); border-width: 20px; border-image-width: 20px; }
  .g-guard { min-width: 58px; height: 58px; font-size: 1.02em; padding: 0 8px; }
  .g-go { min-height: 38px; padding: 5px 12px; font-size: 0.95em; }
  /* (the hand is the screen's width: the turn's seal stands above it, on the right) */
  .g-actions { right: calc(12px + var(--safe-r)); bottom: calc(18.6vh + 12px + var(--safe-b)); }
  .g-main { --d: 96px; }
  .g-all { min-width: 46px; height: 46px; font-size: 0.88em; }
  .g-lordhp { width: 42px; height: 42px; }
  .g-lordhp b { font-size: 1.15em; }
}

/* a phone held upright: the collapsed table. The opponent's hand is a count,
   their portrait sits under the top bar with the prompt below it; my plaque
   is only my counts, beside my portrait */
@media (max-aspect-ratio: 1/1) and (max-width: 559px) {
  .g-prompt { left: 50%; top: calc(var(--opp-lord-bottom, 170px) + 6px); transform: translateX(-50%); width: max-content; max-width: 92vw; text-align: center;
    padding: 4px 22px; font-size: 0.8em; line-height: 1.35; clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 50%, 100% 100%, 0 100%, 12px 50%); }
  .g-player.me .g-name { display: none; }
  .g-player.me { padding: 0 2px; }
  .g-player.opp { max-width: 54vw; }
  .g-actions .btn { min-width: 5.6em; min-height: 44px; font-size: 0.9em; }
  .g-main { --d: 78px; font-size: 0.98em; padding: 8px; }
  .g-ready i { width: 32px; height: 32px; font-size: 18px; }
  .g-tip { left: 50%; transform: translateX(-50%); width: min(92vw, 420px); flex-wrap: nowrap; top: calc(var(--opp-lord-bottom, 170px) + 6px); }
}

/* ---------------------------------------------------------- the shared panels, in this game's frame
   (common/settings.js and room-share.js keep their behavior; only the look
   is this game's: the framed panel, plaques, a paper field) */
html .game-settings[data-theme="sangoku"] { --gs-icon-color: var(--gold-bright); }
html .game-settings[data-theme="sangoku"] .gs-panel { width: min(380px, calc(var(--gs-width, 100vw) - 20px)); padding: 0 4px; border: 28px solid transparent; border-radius: 0;
  border-image: url(ui/panel.svg) 40 fill / 28px stretch; background: none; box-shadow: none; filter: drop-shadow(0 14px 24px #000c); }
html .game-settings[data-theme="sangoku"] h2 { font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.05em; }
html .game-settings[data-theme="sangoku"] :is(.gs-levels button, .gs-mute, .gs-fullscreen, .gs-audio-close, .gs-transport button, .gs-playlist button) {
  min-height: 42px; padding: 0 4px; border: 10px solid transparent; border-radius: 0; border-image: url(ui/plaque.svg) 14 fill / 10px stretch; background: none;
  font-family: var(--font-btn); font-weight: 700; color: var(--ink); text-shadow: 0 1px 0 #000; filter: drop-shadow(0 2px 1px #0009); }
html .game-settings[data-theme="sangoku"] :is(.gs-levels button, .gs-mute, .gs-fullscreen, .gs-playlist button)[aria-pressed="true"],
html .game-settings[data-theme="sangoku"] .gs-playlist button[aria-current="true"] { border-image-source: url(ui/plaque-red.svg); background: none; color: #fff4dc; }
html .game-settings[data-theme="sangoku"] .gs-music { border-top-color: #d6b06044; }
html .room-share-overlay[data-theme="sangoku"] .rs-card { padding: 0 4px; border: 30px solid transparent; border-radius: 0; border-image: url(ui/panel.svg) 40 fill / 30px stretch;
  background: none; box-shadow: none; filter: drop-shadow(0 18px 30px #000d); }
html .room-share-overlay[data-theme="sangoku"] .rs-card h2 { font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.05em; }
html .room-share-overlay[data-theme="sangoku"] .rs-card button { border: 11px solid transparent; border-radius: 0; border-image: url(ui/plaque.svg) 14 fill / 11px stretch; background: none;
  font-family: var(--font-btn); font-weight: 700; color: var(--ink); text-shadow: 0 1px 0 #000; padding: 0 8px; filter: drop-shadow(0 2px 2px #000a); }
html .room-share-overlay[data-theme="sangoku"] .rs-card .rs-share { border-image-source: url(ui/plaque-red.svg); color: #fff4dc; background: none; }
html .room-share-overlay[data-theme="sangoku"] .rs-card .rs-close { width: 44px; padding: 0; border-image-source: url(ui/plaque-ghost.svg); filter: none; color: var(--gold-bright); }
html .room-share-overlay[data-theme="sangoku"] .rs-url { color: var(--ink-dark); background: var(--paper) url(ui/paper.svg); border: 1px solid #7a5a2a; border-radius: 3px; }
html .room-share-overlay[data-theme="sangoku"] .rs-code { color: var(--gold-bright); font-family: 'Noto Serif', serif; letter-spacing: 0.2em; }
html .room-share-overlay[data-theme="sangoku"] .rs-qr { padding: 8px; border-radius: 3px; box-shadow: 0 0 0 1px var(--gold), 0 6px 14px #000a; }

/* ---------------------------------------------------------- the day's reward */
.purse { position: relative; }
.purse-pop { position: absolute; left: calc(18px + 3.4em); bottom: 30%; font: 900 1.25em/1 'Noto Serif', serif; color: var(--gold-bright); pointer-events: none;
  text-shadow: 0 0 10px #f2d27aaa, 0 2px 2px #000; animation: pursePop 2.4s ease-out both; }
@keyframes pursePop { 0% { opacity: 0; translate: 0 10px; scale: 0.6; } 15% { opacity: 1; translate: 0 0; scale: 1.15; } 30% { scale: 1; } 75% { opacity: 1; } 100% { opacity: 0; translate: 0 -26px; } }

/* ---------------------------------------------------------- 出征's two modes */
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 900px; margin: 0 auto 14px; }
.mode-tabs button { font: inherit; text-align: left; color: var(--ink); cursor: pointer; touch-action: manipulation; padding: 6px 12px; min-height: 64px;
  border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch; background: none; filter: drop-shadow(0 3px 2px #000a);
  font-family: var(--font-btn); font-weight: 700; font-size: 1.15em; letter-spacing: 0.04em; text-shadow: 0 1px 2px #000; }
.mode-tabs button small { display: block; font-family: var(--font); font-weight: 500; font-size: 0.68em; color: var(--ink-dim); letter-spacing: 0.01em; margin-top: 2px; }
.mode-tabs button:hover { filter: brightness(1.12) drop-shadow(0 3px 2px #000a); }
.mode-tabs button.on { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 9px #f2d27a88); }
.draft-rules { margin: 0; line-height: 1.7; }
.draft-prizes { margin: 0; color: var(--gold-bright); font-family: var(--font-head); letter-spacing: 0.02em; }
.draft-have { color: var(--ink-dim); font-size: 0.86em; }
.draft-have.bad { color: #ff9a80; }
.draft-saved, .draft-new { display: flex; flex-direction: column; gap: 10px; }
.draft-saved p { margin: 0; font-size: 1.05em; }
.seg > button:disabled { opacity: 0.45; cursor: not-allowed; }
.room-draft { display: flex; flex-direction: column; gap: 8px; }
.seats.many { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seats.many .seat { min-height: 76px; border-width: 18px; border-image-width: 18px; }
.seats.many .seat b { font-size: 1em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item.draft span { color: var(--gold-bright); }
@media (max-width: 760px) { .seats.many { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------------------------------------------------------- 輪抽 */
#draft { --dr-w: 1180px; }
#draft > :not(.sub-head) { max-width: var(--dr-w); margin-left: auto; margin-right: auto; }
.dr-clock { min-width: 3.2em; padding: 4px 12px; text-align: center; font: 900 1.25em/1.2 'Noto Serif', serif; font-variant-numeric: tabular-nums; color: var(--gold-bright);
  border-radius: 999px; background: radial-gradient(circle at 40% 30%, #4a2614, #1a0d09); box-shadow: 0 2px 6px #000b, inset 0 0 0 1.5px var(--gold); }
.dr-clock.short { color: #fff; background: radial-gradient(circle at 40% 30%, #dc4a3c, #7a140e); animation: drTick 1s ease-in-out infinite; }
@keyframes drTick { 50% { scale: 1.08; } }
/* the table: the seats in order, the packs passing between them */
.dr-table { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 0; margin: 0 auto 14px; justify-content: center; }
.dr-seat { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 5.5em; max-width: 13em; padding: 2px 8px;
  border: 10px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 10px stretch; filter: drop-shadow(0 2px 2px #0009); text-shadow: 0 1px 2px #000; }
.dr-seat b { font-family: var(--font-btn); font-size: 0.95em; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-seat small { color: var(--ink-dim); font-size: 0.78em; min-height: 1.2em; }
.dr-seat.me { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 8px #f2d27a88); }
.dr-seat.bot b::before { content: '⚙ '; color: var(--ink-dim); font-size: 0.8em; }
/* a historical figure (Jev, Decisions): its hero's seal instead of the gear */
.dr-seat.figure b::before { content: attr(data-glyph) ' '; color: var(--gold-bright); font-family: var(--font-seal); font-size: 0.9em; }
/* the packs waiting in front of a seat: a little wrapper with their count */
.dr-packs { display: inline-flex; align-items: center; gap: 4px; color: var(--gold-bright) !important; font-weight: 700; }
.dr-packs:not(:empty)::before { content: ''; width: 0.7em; height: 1em; border-radius: 2px; background: linear-gradient(135deg, #fff1b8, #c8953f 45%, #7a4626); box-shadow: 0 1px 2px #000a; }
.dr-seat.busy { animation: drBusy 1.6s ease-in-out infinite; }
.dr-seat.away { opacity: 0.6; }
.dr-seat.away b::after { content: ' 🔌'; font-size: 0.8em; }
@keyframes drBusy { 50% { filter: drop-shadow(0 0 7px #f2d27a66); } }
.dr-seat + .dr-seat::before { content: '→'; position: absolute; left: -22px; top: 50%; translate: 0 -50%; width: 22px; text-align: center; color: var(--gold); font-weight: 900; opacity: 0.85; }
.dr-table[data-dir="right"] .dr-seat + .dr-seat::before { content: '←'; }
.dr-hint { margin: 0 0 10px; text-align: center; font-family: var(--font-head); font-size: 1.08em; letter-spacing: 0.03em; color: var(--ink); text-shadow: 0 1px 3px #000; }
/* the pack in front of you */
.dr-pack { grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); min-height: 120px; }
.dr-pack.waiting { place-items: center; }
.dr-pack .card-cell { transition: --mx 0.6s ease, --my 0.6s ease, --lift 0.45s ease, translate 0.22s ease, opacity 0.22s ease, scale 0.22s ease; }
.dr-pack .card-cell.chosen .tilt { box-shadow: 0 0 0 3px var(--gold-bright), 0 0 22px #f2d27aaa, 0 14px 26px #000b; }
.dr-pack .card-cell.chosen { --lift: 1; z-index: 2; }
.dr-pack .card-cell.chosen::after { content: '選'; position: absolute; right: -8px; top: -10px; display: grid; place-items: center; width: 40px; height: 40px; font: 700 1.3em/1 var(--font-seal); color: #fff3dc;
  border-radius: 6px; rotate: 8deg; background: radial-gradient(circle at 30% 25%, #dc4a3c, #a8241b 55%, #7a140e); box-shadow: inset 0 0 0 2px #a8241b, inset 0 0 0 3px #ffe7bdaa, 0 3px 6px #000a;
  -webkit-mask: url(ui/stamp.svg) center / 60px; mask: url(ui/stamp.svg) center / 60px; animation: stamp 0.3s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
.dr-pack .card-cell.taken { translate: 0 -40px; scale: 0.8; opacity: 0; pointer-events: none; }
.dr-pick-bar { position: sticky; bottom: calc(8px + var(--safe-b)); z-index: 5; display: flex; justify-content: center; gap: 10px; margin: 14px 0 6px; }
.dr-pick-bar .btn { min-width: 8em; }
.dr-pick h3 small { font-family: var(--font); font-size: 0.8em; color: var(--ink-dim); }
.dr-forces { margin: 0 0 8px; color: var(--ink-dim); font-size: 0.95em; letter-spacing: 0.03em; }
.dr-forces:empty { display: none; }
.dr-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.dr-mini { position: relative; width: 62px; padding: 0; border: none; background: none; cursor: pointer; border-radius: 4px; box-shadow: 0 3px 6px #000a; transition: translate 0.12s; }
.dr-mini:hover { translate: 0 -3px; }
.dr-mini canvas { display: block; width: 100%; height: auto; aspect-ratio: 63 / 88; border-radius: 4px; background: #120a06; }
.dr-mini.foil::after { content: ''; position: absolute; inset: 0; border-radius: 4px; mix-blend-mode: color-dodge; opacity: 0.55; pointer-events: none;
  background: repeating-linear-gradient(133deg, #000 0 6%, #ff9ad8 8%, #9ad8ff 10%, #000 12% 20%); }
.dr-build .editor-deck .gen-pick { max-width: none; }
.dr-build .editor-deck [data-ed="save"] { width: 100%; }
/* the bracket */
.dr-now { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; margin-bottom: 18px; border-width: 26px; border-image-width: 26px; }
.dr-now-head { margin: 0; font-family: var(--font-head); font-size: 1.25em; color: var(--gold-bright); letter-spacing: 0.03em; }
.dr-now-sub { margin: 0; color: var(--ink-dim); }
.dr-now-sub:empty { display: none; }
.dr-rounds { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(200px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 6px; }
.dr-round { display: flex; flex-direction: column; gap: 8px; justify-content: space-around; }
.dr-round h3 { margin: 0 0 2px; }
.dr-round:not(.now) h3 { opacity: 0.75; }
.dr-match { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 2px 6px; margin: 0; border: 12px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 12px stretch;
  filter: drop-shadow(0 2px 2px #0009); text-shadow: 0 1px 2px #000; }
.dr-match.mine { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 8px #f2d27a77); }
.dr-match.tbd { color: var(--ink-dim); font-style: italic; text-align: center; opacity: 0.6; }
.dr-match.live::before { content: ''; position: absolute; right: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: #e0553f; box-shadow: 0 0 8px #e0553f; animation: drTick 1s ease-in-out infinite; }
.dr-stakes { color: var(--gold); font-family: var(--font-head); font-size: 0.8em; letter-spacing: 0.04em; }
.dr-side { font-family: var(--font-btn); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-side.won { color: var(--gold-bright); font-weight: 700; }
.dr-side.won::after { content: ' 勝'; font-family: var(--font-seal); color: #e0553f; }
.dr-side.lost { color: var(--ink-dim); text-decoration: line-through; text-decoration-color: #8e1b1499; }
.dr-how { color: var(--ink-dim); font-size: 0.78em; }
.dr-how:empty { display: none; }
.dr-match .btn { align-self: flex-start; margin-top: 2px; }
/* the end: your place, then everyone's */
.dr-trophy { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; max-width: 560px; margin: 10px auto; }
.dr-trophy h2 { margin: 0; font-family: var(--font-head); font-size: 2.1em; letter-spacing: 0.1em; color: var(--gold-bright); text-shadow: 0 2px 0 #2a1208, 0 0 18px #f2d27a55; }
.dr-prize { margin: 0; font: 700 1.2em/1.4 var(--font-head); color: var(--gold-bright); }
.dr-kept { margin: 0; color: var(--ink-dim); }
.result-seal.silver { background: radial-gradient(circle at 30% 25%, #f4f4f0, #b8b8c0 55%, #6a6a78); color: #2a2a34; box-shadow: inset 0 0 0 3px #6a6a78, inset 0 0 0 5px #ffffffbb; }
.dr-trophy .result-seal { margin: 0; }
.dr-places { list-style: none; width: 100%; margin: 6px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dr-places li { display: grid; grid-template-columns: 2em 1fr auto 3.6em; align-items: center; gap: 10px; padding: 4px 10px; border-radius: 3px; text-align: left;
  background: linear-gradient(90deg, #3a1f12, #22110a); box-shadow: inset 0 0 0 1px #d6b06033; }
.dr-places li.me { background: linear-gradient(90deg, #5a3018, #2a150b); box-shadow: inset 0 0 0 1px var(--gold), 0 0 10px #f2d27a44; }
.dr-places i { font: 700 1.1em/1 var(--font-seal); font-style: normal; color: #e0553f; text-align: center; }
.dr-places b { font-family: var(--font-btn); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-places span { color: var(--ink-dim); font-size: 0.88em; }
.dr-places em { font-style: normal; color: var(--gold-bright); font-weight: 700; text-align: right; }
@media (max-width: 520px) {
  .dr-pack { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .dr-table { gap: 4px 18px; }
  .dr-seat { min-width: 4.4em; padding: 0 4px; border-width: 8px; border-image-width: 8px; }
  .dr-seat + .dr-seat::before { left: -18px; width: 18px; }
  .dr-rounds { grid-auto-columns: minmax(170px, 1fr); }
  .mode-tabs button { font-size: 1.02em; min-height: 58px; padding: 4px 8px; }
}
@media (max-width: 760px) { .seats.many .seat b { white-space: normal; } }
@media (max-width: 760px), (max-height: 520px) {
  /* a phone either way up: the deck (and 出戰) above the pool, its list kept short */
  .dr-build .editor { display: flex; flex-direction: column-reverse; }
  .dr-build .editor-deck { position: static; max-height: none; }
  .dr-build .ed-cards { max-height: 34vh; }
  .dr-build .ed-cards[data-view="mini"] { max-height: 46vh; }
}
/* the picks so far, under their headers */
.dr-picks .grp { margin-top: 6px; }
.op-clock { position: absolute; right: calc(16px + var(--safe-r)); top: calc(16px + var(--safe-t)); }
.dr-kick { position: absolute; right: -10px; top: -12px; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: none; border-radius: 50%; cursor: pointer;
  font: 700 12px/1 'Noto Serif', serif; color: #fff3dc; background: radial-gradient(circle at 35% 30%, #8e3a2c, #4a160e); box-shadow: 0 2px 4px #000a, inset 0 0 0 1px #d6b06088; opacity: 0.75; }
.dr-kick:hover, .dr-kick:focus-visible { opacity: 1; }
.dr-seat.bot .dr-kick { display: none; }
.seat .btn.kick { position: absolute; right: -10px; top: -12px; }
.wait .btn.kick { vertical-align: middle; }

/* ---------------- speech bubbles (js/ui/speech.js): what the generals say,
   on paper by their portraits; the wheel a player speaks from */
.g-bubble { position: absolute; left: 0; top: 0; max-width: min(300px, 58vw); padding: 8px 14px 9px; pointer-events: none;
  font-family: var(--font-head); font-size: 1em; line-height: 1.38; color: var(--ink-dark); border-radius: 14px;
  background: var(--paper) url(ui/paper.svg); box-shadow: 0 8px 18px #000b, inset 0 0 0 1px #8a5c1c88, inset 0 0 18px #8a5c1c2a;
  transform-origin: 0 100%; scale: 0.55; opacity: 0; transition: scale 0.2s cubic-bezier(.3, 1.6, .5, 1), opacity 0.18s ease-out; }
.g-bubble p { margin: 0; overflow-wrap: anywhere; }
.g-bubble::after { content: ''; position: absolute; left: var(--tail, 18px); bottom: -6px; width: 13px; height: 13px; transform: rotate(45deg);
  background: var(--paper); box-shadow: 1px 1px 0 #8a5c1c88; }
.g-bubble.below { transform-origin: 0 0; }
.g-bubble.below::after { bottom: auto; top: -6px; box-shadow: -1px -1px 0 #8a5c1c88; }
.g-bubble.left { transform-origin: 100% 100%; }
.g-bubble.left.below { transform-origin: 100% 0; }
.g-bubble.mine { box-shadow: 0 8px 18px #000b, inset 0 0 0 1.5px var(--gold-deep), inset 0 0 18px #8a5c1c2a; }
.g-bubble.own-words { font-family: var(--font); font-size: 0.92em; }
.g-bubble.show { scale: 1; opacity: 1; }
.g-bubble.gone { scale: 0.92; opacity: 0; transition-duration: 0.45s; }
@media (prefers-reduced-motion: reduce) { .g-bubble { transition: opacity 0.2s; scale: 1; } }
.g-log p.say { color: #5a2410; }
.g-log p.say::before { background: var(--vermilion); }
.g-sheet .g-persona { margin: 6px 0 0; text-align: center; font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.04em; }

.g-say-layer { position: absolute; inset: 0; z-index: 45; touch-action: none; }
.g-say-layer.wheel { background: radial-gradient(circle at 50% 70%, #0a050355, #0a0503a8); animation: tipIn 0.15s ease-out; }
.g-say-layer.input, .g-say-layer.book { background: #0a0503a8; animation: tipIn 0.15s ease-out; touch-action: pan-y; }
.g-wheel { position: absolute; width: 0; height: 0; }
.g-wheel-item { position: absolute; left: 0; top: 0; width: var(--w, 124px); height: var(--h, 54px); padding: 0 3px; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 1px;
  border: 10px solid transparent; border-image: url(ui/plaque.svg) 14 fill / 10px stretch; background: none; color: var(--ink); cursor: pointer; touch-action: manipulation;
  font: inherit; font-family: var(--font-head); font-size: 0.8em; line-height: 1.25; text-align: center; filter: drop-shadow(0 4px 4px #000b);
  transform: translate(-50%, -50%) translate(var(--x), var(--y)); animation: wheelIn 0.22s cubic-bezier(.3, 1.4, .5, 1) backwards; animation-delay: var(--d); }
.g-wheel-item small { color: var(--gold-bright); font-size: 0.82em; letter-spacing: 0.08em; }
.g-wheel-item span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.g-wheel-item:hover, .g-wheel-item:focus-visible { border-image-source: url(ui/plaque-on.svg); filter: drop-shadow(0 0 9px #f2d27a88); }
@keyframes wheelIn { from { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } }
.g-wheel-mid { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.g-wheel-write, .g-wheel-more { display: grid; place-items: center; padding: 0; border-radius: 50%; cursor: pointer; touch-action: manipulation; color: #fff3dc; font: 700 1.5em/1 var(--font-head);
  border: 2px solid var(--gold); background: radial-gradient(circle at 35% 30%, #c4402e, #6e150e); box-shadow: 0 4px 10px #000b, inset 0 0 0 2px #00000033; }
.g-wheel-write { width: 64px; height: 64px; }
.g-wheel-more { width: 36px; height: 36px; font-size: 1.1em; background: radial-gradient(circle at 35% 30%, #4a2a18, #1a0d09); }
.g-wheel-write:hover, .g-wheel-more:hover, .g-wheel-write:focus-visible, .g-wheel-more:focus-visible { border-color: var(--gold-bright); filter: brightness(1.15); }
@media (max-width: 560px), (max-height: 520px) { .g-wheel-item { font-size: 0.72em; } .g-wheel-write { width: 54px; height: 54px; } }
.g-wheel-item span { -webkit-line-clamp: 2; }
html:lang(en) .g-wheel-item span, html:lang(en) .g-bubble { font-family: var(--font); }

.g-say-form { position: absolute; left: 50%; top: max(14%, calc(64px + var(--safe-t))); transform: translateX(-50%); width: min(460px, 92vw); padding: 0 2px;
  border: 24px solid transparent; border-image: url(ui/panel.svg) 40 fill / 24px stretch; filter: drop-shadow(0 12px 22px #000c); }
.g-say-form label { display: grid; gap: 6px; }
.g-say-form label span { font-family: var(--font-head); color: var(--gold-bright); letter-spacing: 0.05em; }
.g-say-form input { width: 100%; font: inherit; font-size: 16px; padding: 9px 10px; color: var(--ink-dark); background: var(--paper) url(ui/paper.svg); border: 1px solid #7a5a2a; border-radius: 3px; }
.g-say-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.g-saybook { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(680px, 94vw); max-height: 80vh; max-height: 80dvh; display: flex; flex-direction: column;
  padding: 0 2px; border: 26px solid transparent; border-image: url(ui/panel.svg) 40 fill / 26px stretch; filter: drop-shadow(0 14px 26px #000d); }
.g-saybook header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.g-saybook header h3 { margin: 0; }
.g-saybook-list { overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px 2px; }
.g-saybook-list h4 { margin: 10px 0 5px; font-family: var(--font-head); font-size: 0.9em; color: var(--gold-bright); letter-spacing: 0.08em; }
.g-saybook-row { display: flex; flex-wrap: wrap; gap: 6px; }
.g-saybook-row button { font: inherit; font-size: 0.86em; line-height: 1.3; text-align: left; padding: 5px 10px; border-radius: 12px; cursor: pointer; touch-action: manipulation;
  color: var(--ink-dark); background: var(--paper) url(ui/paper.svg); border: 1px solid #8a5c1c88; box-shadow: 0 2px 3px #0007; }
.g-saybook-row button:hover, .g-saybook-row button:focus-visible { border-color: var(--vermilion); box-shadow: 0 0 0 2px #b3261e55, 0 2px 3px #0007; }
@media (max-width: 560px) { .g-saybook, .g-say-form { border-width: 18px; border-image-width: 18px; } }

/* 出征: a historical figure for the computer */
.seg button.brain-off { opacity: 0.62; }
.brain-note { margin: -2px 0 2px; color: var(--ink-dim); font-size: 0.86em; font-style: italic; }
.cpu-hero { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.cpu-hero .gen-tile { width: auto; flex: 1 1 260px; }
/* 隨機 is a tally like the rows above it: chosen = red, not the gold of a lone toggle */
.cpu-hero > .btn[aria-pressed="true"] { border-image-source: url(ui/plaque-red.svg); color: #fff4dc; filter: drop-shadow(0 0 6px #f2d27a66); }
.g-say-btn { position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 50%; cursor: pointer; touch-action: manipulation;
  color: var(--gold-bright); border: 2px solid var(--gold); background: radial-gradient(circle at 35% 30%, #4a2a18, #1a0d09); box-shadow: 0 3px 6px #000b, inset 0 0 0 1px #00000055; }
.g-say-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.g-say-btn:hover, .g-say-btn:focus-visible, .g-say-btn[aria-expanded="true"] { border-color: var(--gold-bright); filter: brightness(1.2); }
