@font-face {
  font-family: "RTS WenKai";
  src: url("./assets/fonts/LXGWWenKaiLite-Game-Regular.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "RTS WenKai";
  src: url("./assets/fonts/LXGWWenKaiLite-Game-Medium.woff2") format("woff2");
  font-style: normal;
  font-weight: 500 900;
  font-display: swap;
}

@layer legacy {
:root {
  color-scheme: dark;
  --ink: #121915;
  --paper: #e9dfc4;
  --paper-dim: #b8ad91;
  --jade: #438262;
  --jade-bright: #77c99b;
  --red: #9c4d4f;
  --gold: #d5ad58;
  --panel: rgba(22, 31, 26, .92);
  --line: rgba(230, 211, 164, .2);
  --shadow: 0 18px 55px rgba(0, 0, 0, .36);
  font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; background: #111914; color: var(--paper); }
body {
  background:
    radial-gradient(circle at 15% 0%, rgba(95, 141, 105, .16), transparent 32rem),
    radial-gradient(circle at 90% 18%, rgba(164, 92, 73, .12), transparent 28rem),
    linear-gradient(135deg, #111915, #1c2821 52%, #121814);
}
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.menu-screen { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 72px 0 80px; }
.brand-block { text-align: center; margin-bottom: 32px; }
.brand-block h1 { margin: 7px 0 4px; font: 800 clamp(50px, 9vw, 86px)/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif; letter-spacing: .15em; color: #f2dfae; text-shadow: 0 5px 30px rgba(213, 173, 88, .2); }
.brand-block p { color: var(--paper-dim); margin: 0; letter-spacing: .08em; }
.eyebrow { color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }

.setup-card, .scope-note, .modal-card { background: linear-gradient(145deg, rgba(40, 54, 45, .95), rgba(22, 31, 26, .96)); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.setup-card { padding: 26px; margin-top: 18px; }
.section-heading { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.section-heading > span { color: var(--gold); border: 1px solid rgba(213, 173, 88, .35); border-radius: 999px; padding: 5px 8px; font-size: 11px; }
.section-heading h2 { margin: 0 0 4px; font-size: 20px; }
.section-heading p { margin: 0; color: var(--paper-dim); font-size: 13px; }

.hero-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.ruleset-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ruleset-option { position: relative; display: grid; gap: 5px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); cursor: pointer; }
.ruleset-option input { position: absolute; opacity: 0; }
.ruleset-option:has(input:checked) { border-color: var(--gold); background: rgba(72,126,91,.22); box-shadow: inset 0 0 0 1px rgba(213,173,88,.18); }
.ruleset-option.territory:has(input:checked) { background: rgba(141,75,58,.22); }
.ruleset-option small { color: var(--paper-dim); }
.hero-option { position: relative; display: grid; grid-template-columns: 52px 1fr; grid-template-rows: auto auto; align-items: center; gap: 1px 12px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.025); cursor: pointer; transition: .18s ease; }
.hero-option:hover { transform: translateY(-2px); border-color: rgba(213, 173, 88, .45); }
.hero-option input { position: absolute; opacity: 0; }
.hero-option:has(input:checked) { background: rgba(72, 126, 91, .22); border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(213, 173, 88, .18); }
.hero-option .seal { grid-row: 1 / 3; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; font: 700 25px "RTS WenKai", "LXGW WenKai", "KaiTi", serif; color: #fff5d7; background: #526b5b; }
.hero-option.caocao .seal { background: #55688f; }
.hero-option.sunquan .seal { background: #9d713d; }
.hero-option strong { font-size: 16px; }
.hero-option small { color: var(--paper-dim); }
.hero-description { margin: 14px 2px 0; color: #d9c997; font-size: 13px; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-card { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: rgba(0,0,0,.12); }
.mode-card.featured { border-color: rgba(106, 184, 132, .4); }
.mode-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: rgba(213, 173, 88, .12); color: var(--gold); font-size: 21px; }
.mode-card h3 { margin: 12px 0 4px; }
.mode-card p { min-height: 40px; margin: 0 0 14px; color: var(--paper-dim); font-size: 13px; line-height: 1.55; }
.mode-card label, .seed-field { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; margin-top: 8px; color: var(--paper-dim); font-size: 12px; }
select, input { min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: rgba(0,0,0,.25); color: var(--paper); padding: 9px 10px; }
.primary-button, .secondary-button, .mode-card button, .tool-grid button, .danger-button, .text-button { border: 1px solid transparent; border-radius: 10px; padding: 10px 13px; cursor: pointer; transition: .16s ease; }
.primary-button { width: 100%; margin-top: 14px; background: var(--jade); font-weight: 800; box-shadow: 0 8px 20px rgba(67, 130, 98, .24); }
.primary-button:hover { background: #4e9972; }
.secondary-button, .mode-card > button:not(.primary-button) { width: 100%; background: rgba(213, 173, 88, .1); border-color: rgba(213, 173, 88, .35); }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 7px; margin-top: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .15em; }
.join-row button { background: var(--red); }
.seed-field { grid-template-columns: auto 150px 1fr; margin-top: 18px; padding-top: 15px; border-top: 1px solid var(--line); }
.seed-field small { color: #817d70; }
.scope-note { display: flex; gap: 16px; margin-top: 18px; padding: 16px 20px; color: var(--paper-dim); font-size: 12px; line-height: 1.6; }
.scope-note strong { color: var(--gold); white-space: nowrap; }

.modal-card { position: fixed; z-index: 20; top: 50%; left: 50%; width: min(440px, calc(100% - 32px)); padding: 30px; text-align: center; transform: translate(-50%, -50%); }
.modal-card::before { content: ""; position: fixed; inset: -100vh -100vw; z-index: -1; background: rgba(4,7,5,.75); backdrop-filter: blur(6px); }
.modal-card h2 { margin: 8px 0; }
.modal-card p { color: var(--paper-dim); line-height: 1.6; }
.room-code { display: block; margin: 20px auto; color: #ffe6a7; font-size: 40px; font-weight: 900; letter-spacing: .22em; }
.text-button { background: transparent; color: var(--paper-dim); border-color: var(--line); }

.game-screen { min-height: 100vh; padding: 12px; }
.desktop-battle-layout { display: grid; grid-template-columns: minmax(360px, 540px) minmax(280px, 340px); gap: 18px; align-items: start; justify-content: center; width: min(920px, 100%); margin: 0 auto; }
.phone-battle { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; justify-self: end; width: min(100%, calc((100vh - 24px) * 9 / 16), 540px); aspect-ratio: 9 / 16; overflow: hidden; border: 1px solid rgba(230,211,164,.36); border-radius: 24px; background: #17231d; box-shadow: 0 24px 70px rgba(0,0,0,.48); }
.battle-header { z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; padding: 10px 12px 8px; border-bottom: 1px solid var(--line); background: rgba(16,24,20,.98); }
.player-summary { min-width: 0; }
.player-summary.self { text-align: right; }
.name-line { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 11px; }
.player-summary.self .name-line { flex-direction: row-reverse; }
.name-line span { color: var(--paper-dim); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hq-bar { position: relative; height: 15px; overflow: hidden; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; background: rgba(0,0,0,.4); }
.hq-bar span { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #9d4c50, #d17370); transition: width .2s; }
.player-summary.self .hq-bar span { margin-left: auto; background: linear-gradient(90deg, #3d8b64, #72c58b); }
.hq-bar em { position: absolute; inset: 0; text-align: center; color: white; font: 700 9px/14px system-ui; text-shadow: 0 1px 2px #000; }
.battle-clock { text-align: center; }
.battle-clock strong { display: block; font-size: 15px; }
.battle-clock span { display: block; margin-top: 2px; color: var(--gold); font-size: 10px; }
.player-resource-hud,
.player-hero-hud { display: none; }

.battle-stage { position: relative; display: grid; min-height: 0; place-items: center; overflow: hidden; background: #111914; }
#battle-canvas { position: absolute; top: 0; left: 50%; display: block; width: auto; height: 100%; aspect-ratio: 5 / 9; touch-action: none; cursor: pointer; transform: translateX(-50%); }
.selection-panel { position: absolute; z-index: 5; right: 9px; bottom: 9px; left: 9px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid rgba(230,211,164,.3); border-radius: 12px; background: rgba(18,27,22,.94); box-shadow: var(--shadow); }
.selection-panel h3 { margin: 0 0 2px; color: #e8d496; font-size: 11px; }
.selection-panel p { margin: 0; color: var(--paper-dim); font-size: 9px; line-height: 1.35; }
.selection-panel button { align-self: stretch; padding: 6px 10px; }
.drag-sell-hint { align-self: stretch; display: grid; place-items: center; padding: 6px 10px; border-radius: 8px; background: rgba(111,55,45,.88); color: #fff0d3; font-size: 9px; white-space: nowrap; }

.playtest-console { position: sticky; top: 12px; display: grid; gap: 10px; max-height: calc(100vh - 24px); overflow: auto; padding-right: 3px; }
.console-heading { padding: 5px 4px 2px; }
.console-heading h2 { margin: 4px 0 2px; color: #f0dda8; font: 700 24px "RTS WenKai", "LXGW WenKai", "KaiTi", serif; }
.console-heading p { margin: 0; color: #777d72; font-size: 10px; }
.playtest-console section { padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); box-shadow: 0 8px 25px rgba(0,0,0,.15); }
.playtest-console h3 { margin: 0 0 9px; color: #d9c691; font-size: 12px; letter-spacing: .08em; }
.playtest-console p { margin: 5px 0; color: var(--paper-dim); font-size: 11px; line-height: 1.5; }
.network-badge { display: inline-block; margin-top: 7px; padding: 4px 7px; border-radius: 999px; color: #8ed6aa; background: rgba(58,126,82,.2); font-size: 10px; }
.network-badge.offline { color: #ef9292; background: rgba(154,66,66,.24); }
.augment-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.augment-tags span { padding: 4px 6px; border: 1px solid rgba(213,173,88,.22); border-radius: 6px; color: var(--paper-dim); font-size: 9px; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool-grid button { padding: 7px; border-color: var(--line); background: rgba(255,255,255,.04); font-size: 10px; }
button:disabled { cursor: not-allowed; opacity: .35; }
.danger-button { background: rgba(158,67,67,.18); border-color: rgba(215,102,102,.35); color: #f0adad; }
.battle-log { display: grid; gap: 6px; max-height: 280px; margin: 0; padding: 0; list-style: none; }
.battle-log li { color: var(--paper-dim); font-size: 9px; line-height: 1.35; }
.battle-log time { margin-right: 5px; color: var(--gold); }
.exit-actions { display: flex; gap: 6px; }
.exit-actions button { flex: 1; font-size: 10px; }

.command-deck { z-index: 2; display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 6px; align-items: stretch; padding: 8px; border-top: 1px solid var(--line); background: rgba(15,23,19,.98); }
.summon-button { border: 1px solid rgba(213,173,88,.46); border-radius: 13px; background: linear-gradient(145deg, #72552e, #48371f); color: #fff0c2; cursor: pointer; }
.summon-button strong, .summon-button small { display: block; }
.summon-button strong { margin-top: 3px; font-size: 19px; }
.summon-button small { color: #d5c294; font-size: 9px; }
.card-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.command-card { min-height: 62px; padding: 5px 2px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(160deg, #34453a, #1d2822); color: var(--paper); cursor: grab; touch-action: none; }
.command-card.selected { border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 6px 18px rgba(213,173,88,.18); }
.command-card.dragging { opacity: .48; cursor: grabbing; }
.command-deck.sell-target { outline: 2px dashed rgba(194,105,82,.7); outline-offset: -5px; }
.command-deck.sell-target::before { content: "拖到这里出售"; position: absolute; z-index: 8; right: 12px; top: -27px; padding: 5px 9px; border-radius: 8px; background: rgba(83,37,31,.94); color: #f6ddae; font-size: 9px; pointer-events: none; }
.command-deck.sell-target-valid { outline-color: #e8c36d; background-color: rgba(103,65,35,.98); }
.command-card .card-icon, .command-card strong, .command-card small { display: block; }
.command-card .card-icon { margin-bottom: 2px; font-size: 17px; }
.command-card strong { font-size: 10px; }
.command-card small { margin-top: 2px; color: var(--paper-dim); font-size: 8px; }
.empty-card { color: rgba(255,255,255,.18); }
.interaction-hint { grid-column: 1 / -1; margin: 0; color: #747a70; text-align: center; font-size: 8px; }
.command-deck.territory-mode { grid-template-columns: minmax(120px, 220px); justify-content: center; }
.command-deck.territory-mode .card-row { display: none; }

.augment-panel { position: absolute; z-index: 30; inset: 0; display: grid; place-content: center; padding: 12px; background: rgba(6,9,7,.88); backdrop-filter: blur(5px); }
.augment-heading { text-align: center; }
.augment-heading h2 { margin: 5px 0 12px; }
.augment-card-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; width: min(100%, 510px); }
.augment-card { min-height: 210px; padding: 13px 10px; border: 1px solid rgba(213,173,88,.33); border-radius: 13px; background: linear-gradient(160deg, #34463a, #1c2822); color: var(--paper); text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.augment-card:hover { transform: translateY(-5px); border-color: var(--gold); }
.augment-card.locked { border-color: #8ed8aa; box-shadow: 0 0 0 2px rgba(99,187,132,.24); }
.augment-card > span { color: var(--gold); font-size: 10px; letter-spacing: .15em; }
.augment-card h3 { margin: 12px 0 8px; font: 700 19px "RTS WenKai", "LXGW WenKai", "KaiTi", serif; }
.augment-card p { color: #e8ddb9; font-size: 10px; line-height: 1.55; }
.augment-card small { display: block; margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--line); color: #bcae8c; font-size: 9px; line-height: 1.45; }
.augment-panel > .secondary-button { width: 150px; margin: 10px auto 0; padding: 8px; }

.waiting-overlay { position: absolute; inset: 0; display: grid; place-content: center; gap: 5px; background: rgba(9,14,11,.75); text-align: center; }
.waiting-overlay strong { color: var(--gold); font-size: 22px; }
.waiting-overlay span { color: var(--paper-dim); }
.toast { position: absolute; z-index: 10; left: 50%; bottom: 16px; max-width: 84%; padding: 9px 14px; border: 1px solid rgba(116,194,144,.38); border-radius: 999px; background: rgba(22,49,34,.94); color: #c7efd4; font-size: 11px; transform: translateX(-50%); box-shadow: var(--shadow); }
.toast.error { border-color: rgba(213,99,99,.42); background: rgba(73,30,31,.95); color: #f4b7b7; }

@media (max-width: 900px) {
  .desktop-battle-layout { grid-template-columns: minmax(0, 540px); }
  .phone-battle { justify-self: center; }
  .playtest-console { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; overflow: visible; }
  .console-heading, .playtest-console .exit-actions { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .menu-screen { width: min(100% - 20px, 980px); padding-top: 35px; }
  .brand-block h1 { font-size: 52px; }
  .setup-card { padding: 17px; }
  .hero-picker { grid-template-columns: 1fr; }
  .ruleset-picker { grid-template-columns: 1fr; }
  .hero-option { grid-template-columns: 42px 1fr; padding: 10px 12px; }
  .hero-option .seal { width: 39px; height: 39px; }
  .mode-grid { grid-template-columns: 1fr; }
  .seed-field { grid-template-columns: 1fr 1fr; }
  .seed-field small { grid-column: 1 / -1; }
  .game-screen { padding: 6px; }
  .desktop-battle-layout { gap: 10px; }
  .phone-battle { width: min(100%, calc((100vh - 12px) * 9 / 16)); border-radius: 17px; }
  .battle-header { grid-template-columns: 1fr 76px 1fr; gap: 5px; padding: 8px; }
  .name-line span { display: none; }
  .battle-clock strong { font-size: 12px; }
  .playtest-console { grid-template-columns: 1fr; }
  .console-heading, .playtest-console .exit-actions { grid-column: auto; }
  .playtest-console section { padding: 9px; }
  .command-deck { grid-template-columns: 82px 1fr; padding: 6px; }
  .card-row { grid-template-columns: repeat(3, 1fr); }
  .command-card { min-height: 56px; }
  .augment-card { min-height: 175px; padding: 9px 7px; }
  .augment-card h3 { margin: 7px 0; font-size: 16px; }
  .augment-card p { margin: 4px 0; font-size: 9px; }
  .augment-card small { margin-top: 7px; padding-top: 7px; font-size: 8px; }
}

}

/* High-contrast xuan-paper direction: white space first, ink second, faction color last. */
:root {
  color-scheme: light;
  --rice-paper: #f3f0e7;
  --rice-paper-light: #fffdf7;
  --ink-black: #171716;
  --ink-soft: #565550;
  --paper: #1d1d1b;
  --paper-dim: #696862;
  --gold: #242422;
  --panel: rgba(255, 253, 247, .92);
  --line: rgba(24, 24, 22, .2);
  --shadow: 0 14px 38px rgba(28, 28, 25, .12);
  --ally-blue: #3f7fe8;
  --enemy-red: #d94b4b;
  font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

html,
body {
  background: #efede5;
  color: var(--ink-black);
}

body {
  background:
    radial-gradient(ellipse at -5% 18%, rgba(24, 24, 22, .13), transparent 24rem),
    radial-gradient(ellipse at 104% 78%, rgba(24, 24, 22, .09), transparent 30rem),
    repeating-linear-gradient(5deg, rgba(32, 32, 30, .018) 0 1px, transparent 1px 7px),
    linear-gradient(115deg, #f8f6ef, #ebe8df 58%, #f5f2e9);
}

button,
input,
select {
  font-family: inherit;
}

button {
  text-shadow: none;
}

button:hover:not(:disabled) {
  filter: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline-color: var(--ink-black);
}

.menu-screen::before,
.menu-screen::after {
  opacity: .12;
  filter: blur(2px);
}

.menu-screen::before {
  background: radial-gradient(ellipse, rgba(22, 22, 21, .72), rgba(22, 22, 21, .13) 48%, transparent 72%);
}

.menu-screen::after {
  background: radial-gradient(ellipse, rgba(22, 22, 21, .5), rgba(22, 22, 21, .08) 54%, transparent 74%);
}

.brand-block h1 {
  color: var(--ink-black);
  text-shadow: 2px 3px 0 rgba(20, 20, 19, .1);
}

.brand-block p,
.hero-description,
.section-heading p,
.mode-card p,
.ruleset-option small,
.hero-option small,
.scope-note,
.seed-field,
.seed-field small,
.modal-card p,
.interaction-hint,
.console-heading p,
.playtest-console p,
.battle-log li {
  color: var(--paper-dim);
}

.eyebrow {
  color: var(--ink-soft);
}

.setup-card,
.scope-note,
.modal-card {
  border: 1px solid rgba(23, 23, 22, .22);
  border-radius: 2px;
  background:
    linear-gradient(92deg, rgba(24, 24, 22, .025), transparent 14%),
    repeating-linear-gradient(3deg, rgba(35, 35, 32, .015) 0 1px, transparent 1px 6px),
    rgba(255, 253, 247, .9);
  box-shadow: var(--shadow);
}

.setup-card::before,
.scope-note::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 4px;
  background: linear-gradient(180deg, transparent, #1c1c1b 12%, #1c1c1b 84%, transparent);
  opacity: .82;
}

.setup-card::after,
.modal-card::after {
  display: none;
}

.section-heading > span {
  border: 0;
  border-radius: 0;
  background: var(--ink-black);
  color: var(--rice-paper-light);
}

.section-heading h2,
.mode-card h3,
.console-heading h2,
.playtest-console h3,
.augment-heading h2 {
  color: var(--ink-black);
}

.ruleset-option,
.hero-option,
.mode-card {
  border: 1px solid rgba(25, 25, 23, .16);
  border-radius: 1px;
  background: rgba(255, 255, 252, .54);
  box-shadow: none;
}

.mode-card.featured,
.ruleset-option:has(input:checked),
.ruleset-option.territory:has(input:checked),
.ruleset-option.cr:has(input:checked),
.hero-option:has(input:checked) {
  border-color: rgba(20, 20, 19, .46);
  background: rgba(255, 255, 252, .92);
  box-shadow: inset 4px 0 0 var(--ink-black);
}

.hero-option:hover,
.mode-card:hover {
  border-color: rgba(20, 20, 19, .45);
}

.hero-option .seal,
.hero-option.caocao .seal,
.hero-option.sunquan .seal {
  border: 1px solid var(--ink-black);
  background: var(--rice-paper-light);
  color: var(--ink-black);
  box-shadow: inset 0 0 0 3px rgba(25, 25, 23, .06);
}

.mode-icon {
  border: 1px solid rgba(24, 24, 22, .28);
  background: transparent;
  color: var(--ink-black);
  filter: grayscale(1);
}

select,
input {
  border: 1px solid rgba(24, 24, 22, .3);
  border-radius: 1px;
  background: rgba(255, 254, 249, .92);
  color: var(--ink-black);
}

.primary-button,
.secondary-button,
.mode-card button,
.tool-grid button,
.exit-actions button,
.danger-button,
.text-button {
  border: 1px solid rgba(22, 22, 21, .48);
  border-radius: 1px;
  background: rgba(255, 254, 249, .86);
  color: var(--ink-black);
  box-shadow: none;
}

.primary-button,
.primary-button:hover,
.join-row button {
  border-color: var(--ink-black);
  background: var(--ink-black);
  color: var(--rice-paper-light);
}

.modal-card::before {
  background: rgba(24, 24, 22, .48);
  backdrop-filter: blur(3px);
}

.room-code {
  color: var(--ink-black);
}

.game-screen {
  background: transparent;
}

.phone-battle {
  border: 1px solid #242422;
  border-radius: 5px;
  background: var(--rice-paper-light);
  box-shadow: 0 0 0 3px rgba(255, 253, 247, .9), 0 0 0 4px rgba(24, 24, 22, .24), 0 24px 58px rgba(24, 24, 22, .18);
}

.phone-battle::before {
  inset: 4px;
  border: 1px solid rgba(24, 24, 22, .13);
  box-shadow: none;
}

.phone-battle::after {
  background:
    radial-gradient(ellipse at 8% 48%, rgba(25, 25, 23, .035), transparent 22%),
    repeating-linear-gradient(4deg, rgba(30, 30, 28, .012) 0 1px, transparent 1px 7px);
  mix-blend-mode: multiply;
}

.battle-header {
  border-bottom: 1px solid rgba(24, 24, 22, .28);
  background: rgba(255, 253, 247, .96);
  box-shadow: none;
}

.name-line strong,
.name-line span,
.battle-clock strong,
.battle-clock span {
  color: var(--ink-black);
}

.battle-clock {
  border-color: rgba(24, 24, 22, .28);
  background: rgba(255, 253, 247, .9);
}

.hq-bar {
  border-color: rgba(24, 24, 22, .42);
  background: #f4f2eb;
  box-shadow: none;
}

.hq-bar span {
  background: var(--enemy-red);
}

.player-summary.self .hq-bar span {
  background: var(--ally-blue);
}

.battle-stage {
  background: #f4f2eb;
  box-shadow: none;
}

#battle-canvas {
  filter: contrast(1.09) brightness(1.035);
}

.selection-panel {
  border: 1px solid rgba(24, 24, 22, .46);
  border-radius: 1px;
  background: rgba(255, 253, 247, .96);
  color: var(--ink-black);
  box-shadow: 0 8px 20px rgba(24, 24, 22, .15);
}

.selection-panel h3,
.selection-panel p {
  color: var(--ink-black);
}

.selection-panel .danger-button,
.drag-sell-hint {
  border-radius: 1px;
  background: var(--ink-black);
  color: var(--rice-paper-light);
}

.command-deck {
  border-top: 1px solid rgba(24, 24, 22, .38);
  background:
    repeating-linear-gradient(4deg, rgba(30, 30, 28, .015) 0 1px, transparent 1px 7px),
    rgba(255, 253, 247, .97);
  box-shadow: 0 -6px 18px rgba(24, 24, 22, .08);
}

.summon-button {
  border: 1px solid rgba(24, 24, 22, .55);
  border-radius: 1px;
  background:
    linear-gradient(90deg, rgba(24, 24, 22, .14) 0 var(--summon-progress), transparent var(--summon-progress) 100%),
    rgba(255, 253, 247, .96);
  color: var(--ink-black);
  box-shadow: none;
}

.summon-button::before {
  color: rgba(24, 24, 22, .055);
}

.summon-button[data-affordable="true"] {
  border-color: var(--ink-black);
  box-shadow: inset 3px 0 0 var(--ink-black);
}

.command-card {
  border: 1px solid rgba(24, 24, 22, .25);
  border-radius: 1px;
  background: rgba(255, 254, 249, .82);
  color: var(--ink-black);
  box-shadow: none;
}

.command-card::after {
  inset: 3px;
  border-color: rgba(24, 24, 22, .06);
}

.command-card:hover:not(:disabled),
.command-card.selected,
.command-card.merge-target {
  border-color: var(--ink-black);
}

.command-card.selected {
  background: #f2f0e8;
  box-shadow: inset 3px 0 0 var(--ink-black), 0 7px 14px rgba(24, 24, 22, .12);
}

.command-card .card-building-art,
.command-card .card-icon {
  filter: drop-shadow(0 1px 1px rgba(24, 24, 22, .24));
}

.command-card .card-icon {
  border-color: var(--ink-black);
  background: var(--rice-paper-light);
  color: var(--ink-black);
  box-shadow: none;
}

.command-card small,
.interaction-hint {
  color: var(--paper-dim);
}

.cr-action-row button {
  border: 1px solid rgba(24, 24, 22, .55);
  border-radius: 1px;
  background: rgba(255, 253, 247, .96);
  color: var(--ink-black);
  box-shadow: inset 0 -3px 0 rgba(24, 24, 22, .08);
}

.cr-action-row button:hover:not(:disabled) {
  filter: none;
}

.phone-battle.cr-mode .battle-clock {
  border: 1px solid rgba(24, 24, 22, .62);
  border-radius: 2px;
  background: rgba(255, 253, 247, .94);
  box-shadow: 0 4px 12px rgba(24, 24, 22, .12);
  backdrop-filter: blur(3px);
}

.phone-battle.cr-mode .battle-clock strong {
  color: var(--ink-black);
  text-shadow: none;
}

.phone-battle.cr-mode .player-resource-hud span {
  border: 1px solid rgba(24, 24, 22, .25);
  border-radius: 1px;
  background: rgba(255, 253, 247, .78);
}

.phone-battle.cr-mode .player-resource-hud small {
  color: var(--paper-dim);
}

.phone-battle.cr-mode .player-resource-hud strong {
  color: var(--ink-black);
}

.augment-panel,
.waiting-overlay {
  background:
    radial-gradient(ellipse at center, rgba(255, 253, 247, .95), rgba(239, 237, 229, .9) 62%, rgba(24, 24, 22, .18)),
    rgba(244, 242, 235, .88);
  backdrop-filter: blur(4px);
}

.augment-card {
  border: 1px solid rgba(24, 24, 22, .38);
  border-radius: 1px;
  background:
    repeating-linear-gradient(5deg, rgba(30, 30, 28, .018) 0 1px, transparent 1px 7px),
    rgba(255, 253, 247, .96);
  color: var(--ink-black);
  box-shadow: 0 12px 26px rgba(24, 24, 22, .12);
}

.augment-card:hover,
.augment-card.locked {
  border-color: var(--ink-black);
  box-shadow: inset 4px 0 0 var(--ink-black), 0 12px 26px rgba(24, 24, 22, .14);
}

.augment-card > span,
.augment-card h3,
.augment-card p {
  color: var(--ink-black);
}

.augment-card small {
  border-top-color: rgba(24, 24, 22, .18);
  color: var(--paper-dim);
}

.toast,
.toast.error {
  border: 1px solid var(--ink-black);
  border-radius: 1px;
  background: rgba(24, 24, 22, .94);
  color: var(--rice-paper-light);
  box-shadow: 0 8px 20px rgba(24, 24, 22, .18);
}

.console-heading {
  border-bottom: 3px solid var(--ink-black);
}

.console-heading h2 {
  color: var(--ink-black);
  text-shadow: none;
}

.playtest-console {
  scrollbar-color: #777570 #e4e1d8;
}

.playtest-console section {
  border: 0;
  border-bottom: 1px solid rgba(24, 24, 22, .18);
  border-left: 3px solid rgba(24, 24, 22, .76);
  border-radius: 0;
  background: rgba(255, 253, 247, .74);
  box-shadow: none;
}

.playtest-console h3 {
  color: var(--ink-black);
}

.tool-grid button,
.exit-actions button,
.danger-button,
.text-button,
.network-badge,
.network-badge.offline {
  border-color: rgba(24, 24, 22, .3);
  background: rgba(255, 253, 247, .72);
  color: var(--ink-black);
}

.network-badge,
.network-badge.offline,
.augment-tags span {
  border-radius: 1px;
}

.battle-log time {
  color: var(--ink-black);
}

.map-controls button {
  border-color: rgba(24, 24, 22, .48);
  background: rgba(255, 253, 247, .9);
  color: var(--ink-black);
  box-shadow: 0 4px 10px rgba(24, 24, 22, .12);
}

.phone-battle.territory-mode,
.phone-battle.territory-mode .battle-stage {
  background: #f1efe8;
}

.phone-battle.territory-mode .name-line,
.phone-battle.territory-mode .battle-clock {
  border-color: rgba(24, 24, 22, .48);
  background: rgba(255, 253, 247, .9);
  box-shadow: 0 4px 12px rgba(24, 24, 22, .12);
}

.phone-battle.territory-mode .name-line strong,
.phone-battle.territory-mode .name-line span,
.phone-battle.territory-mode .battle-clock strong,
.phone-battle.territory-mode .battle-clock span {
  color: var(--ink-black);
}

@layer legacy {
/* Monochrome ink-wash art direction: neutral UI, faction color only for ally/enemy state. */
:root {
  --rice-paper: #e7e6e1;
  --rice-paper-light: #f4f3ef;
  --ink-black: #202020;
  --ink-soft: #555553;
  --cinnabar: #777774;
  --cinnabar-bright: #a3a39f;
  --bronze: #a6a6a1;
  --bronze-dark: #4d4d4b;
  --jade: #8f8f8b;
  --smoke-blue: #666663;
  --paper: #efeee9;
  --paper-dim: #b9b9b5;
  --gold: #d6d5d0;
  --panel: rgba(36, 36, 35, .96);
  --line: rgba(235, 235, 230, .28);
  --shadow: 0 18px 52px rgba(0, 0, 0, .46);
  --ally-blue: #3f7fe8;
  --enemy-red: #d94b4b;
}

html,
body {
  background: #181818;
  color: var(--paper);
}

body {
  background:
    radial-gradient(ellipse at 14% 8%, rgba(235, 235, 230, .1), transparent 32rem),
    radial-gradient(ellipse at 88% 18%, rgba(130, 130, 126, .12), transparent 29rem),
    repeating-linear-gradient(7deg, rgba(255, 255, 255, .012) 0 1px, transparent 1px 5px),
    linear-gradient(145deg, #171717, #30302f 54%, #1b1b1b);
}

.menu-screen::before {
  background: radial-gradient(ellipse, rgba(235, 235, 230, .34), rgba(36, 36, 36, .7) 58%, transparent 72%);
}

.menu-screen::after {
  background: radial-gradient(ellipse, rgba(160, 160, 156, .26), rgba(36, 36, 36, .68) 60%, transparent 74%);
}

.brand-block h1 {
  color: #f2f1ec;
  text-shadow: 0 3px 0 #444442, 0 8px 32px rgba(0, 0, 0, .54);
}

.brand-block p,
.hero-description,
.section-heading p,
.mode-card p,
.ruleset-option small,
.hero-option small,
.scope-note,
.seed-field,
.seed-field small,
.modal-card p,
.interaction-hint,
.console-heading p,
.playtest-console p,
.battle-log li {
  color: var(--paper-dim);
}

.eyebrow,
.scope-note strong,
.room-code,
.section-heading h2,
.mode-card h3,
.console-heading h2,
.playtest-console h3,
.augment-heading h2 {
  color: #e7e6e1;
}

.setup-card,
.scope-note,
.modal-card {
  border-color: rgba(235, 235, 230, .32);
  background:
    linear-gradient(105deg, rgba(255, 255, 255, .055), transparent 24%),
    repeating-linear-gradient(3deg, rgba(255, 255, 255, .016) 0 1px, transparent 1px 4px),
    linear-gradient(145deg, rgba(61, 61, 59, .98), rgba(29, 29, 28, .99));
  box-shadow: inset 0 0 0 2px rgba(18, 18, 18, .48), var(--shadow);
}

.setup-card::after,
.modal-card::after {
  border-color: rgba(235, 235, 230, .1);
}

.section-heading > span {
  border-color: #a8a8a3;
  background: rgba(95, 95, 92, .58);
  color: #f4f3ef;
}

.ruleset-option,
.hero-option,
.mode-card {
  border-color: rgba(235, 235, 230, .2);
  background: linear-gradient(155deg, rgba(235, 235, 230, .06), rgba(0, 0, 0, .16));
}

.mode-card.featured,
.ruleset-option:has(input:checked),
.ruleset-option.territory:has(input:checked),
.ruleset-option.cr:has(input:checked),
.hero-option:has(input:checked) {
  border-color: #c3c2bd;
  background: linear-gradient(150deg, rgba(205, 205, 200, .17), rgba(70, 70, 68, .24));
  box-shadow: inset 0 0 0 1px rgba(245, 245, 240, .12), 0 5px 18px rgba(0, 0, 0, .2);
}

.hero-option:hover,
.mode-card:hover {
  border-color: #bdbdb8;
}

.hero-option .seal,
.hero-option.caocao .seal,
.hero-option.sunquan .seal {
  border-color: rgba(245, 245, 240, .58);
  background: #6f6f6c;
  color: #f7f6f2;
  box-shadow: inset 0 0 0 3px rgba(20, 20, 20, .25), 0 3px 8px rgba(0, 0, 0, .34);
}

.hero-option.caocao .seal { background: #555553; }
.hero-option.sunquan .seal { background: #8d8d89; }

.mode-icon {
  border-color: rgba(235, 235, 230, .34);
  background: rgba(118, 118, 114, .24);
  filter: grayscale(1);
}

select,
input {
  border-color: rgba(235, 235, 230, .3);
  background: rgba(16, 16, 16, .56);
  color: #efeee9;
}

.primary-button,
.secondary-button,
.mode-card button,
.tool-grid button,
.exit-actions button,
.danger-button,
.text-button {
  border-color: rgba(235, 235, 230, .34);
  background: linear-gradient(#565653, #30302f);
  color: #f4f3ef;
  box-shadow: inset 0 1px rgba(255, 255, 255, .12), 0 7px 18px rgba(0, 0, 0, .25);
}

.primary-button {
  border-color: #c7c7c2;
  background: linear-gradient(#90908c, #565653);
}

.primary-button:hover {
  background: linear-gradient(#a5a5a1, #62625f);
}

.join-row button {
  background: linear-gradient(#686865, #3b3b39);
}

.modal-card::before {
  background: rgba(5, 5, 5, .78);
}

.phone-battle {
  border-color: #8d8d89;
  background: var(--ink-black);
  box-shadow: 0 0 0 2px #292928, 0 0 0 4px rgba(220, 220, 215, .18), 0 26px 72px rgba(0, 0, 0, .56);
}

.phone-battle::before {
  border-color: rgba(235, 235, 230, .26);
  box-shadow: inset 0 0 22px rgba(20, 20, 20, .3);
}

.phone-battle::after {
  background:
    radial-gradient(ellipse at 15% 55%, rgba(245, 245, 240, .07), transparent 28%),
    radial-gradient(ellipse at 88% 32%, rgba(30, 30, 30, .09), transparent 30%);
}

.battle-header {
  border-bottom-color: #555553;
  background:
    linear-gradient(90deg, rgba(90, 90, 87, .24), transparent 35%, transparent 65%, rgba(160, 160, 156, .18)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .016) 0 1px, transparent 1px 6px),
    linear-gradient(#343432, #202020);
}

.name-line strong,
.battle-clock strong,
.battle-clock span {
  color: #f0efea;
}

.name-line span {
  color: #b7b7b3;
}

.battle-clock {
  border-color: rgba(235, 235, 230, .28);
  background: rgba(16, 16, 16, .3);
}

.hq-bar {
  border-color: rgba(235, 235, 230, .3);
  background: rgba(8, 8, 8, .72);
}

.hq-bar span {
  background: linear-gradient(90deg, #a9383b, var(--enemy-red));
}

.player-summary.self .hq-bar span {
  background: linear-gradient(90deg, #285fba, var(--ally-blue));
}

.battle-stage {
  background: linear-gradient(#d0cfca, #9a9a96);
  box-shadow: inset 0 0 28px rgba(30, 30, 30, .42);
}

#battle-canvas {
  filter: contrast(1.04);
}

.selection-panel {
  border-color: #8f8f8b;
  background:
    repeating-linear-gradient(4deg, rgba(36, 36, 36, .035) 0 1px, transparent 1px 4px),
    linear-gradient(100deg, rgba(239, 238, 233, .98), rgba(201, 201, 196, .98));
  color: #242424;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .32), inset 0 0 0 2px rgba(60, 60, 58, .16);
}

.selection-panel h3,
.selection-panel p {
  color: #383836;
}

.selection-panel .danger-button,
.drag-sell-hint {
  background: linear-gradient(#595957, #343432);
  color: #f4f3ef;
}

.command-deck {
  border-top-color: #555553;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .016) 0 1px, transparent 1px 7px),
    linear-gradient(#393937, #202020);
}

.summon-button {
  border-color: #c8c7c2;
  background:
    linear-gradient(90deg, rgba(220, 220, 215, .58) 0 var(--summon-progress), transparent var(--summon-progress) 100%),
    linear-gradient(145deg, #777773, #4e4e4c 58%, #30302f);
  color: #f7f6f2;
  box-shadow: inset 0 0 0 2px rgba(25, 25, 25, .38), inset 0 1px rgba(255, 255, 255, .18), 0 5px 14px rgba(0, 0, 0, .3);
}

.summon-button::before {
  color: rgba(245, 245, 240, .08);
}

.summon-button[data-blocked="true"] {
  filter: grayscale(1);
}

.summon-button[data-affordable="true"] {
  border-color: #eeeeea;
  box-shadow: inset 0 0 0 2px rgba(25, 25, 25, .38), inset 0 1px rgba(255, 255, 255, .22), 0 0 13px rgba(235, 235, 230, .2);
}

.command-card {
  border-color: rgba(235, 235, 230, .34);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .035), transparent 18%, transparent 82%, rgba(0, 0, 0, .12)),
    linear-gradient(#5c5c59, #333331);
  color: #f0efea;
}

.command-card:hover:not(:disabled),
.command-card.selected,
.command-card.merge-target {
  border-color: #e3e2dd;
}

.command-card.selected {
  background: linear-gradient(#747470, #444442);
  box-shadow: 0 7px 18px rgba(0, 0, 0, .36), 0 0 14px rgba(230, 230, 225, .16);
}

.command-card.merge-target {
  box-shadow: inset 0 0 0 2px rgba(235, 235, 230, .24), 0 0 16px rgba(235, 235, 230, .24);
}

.command-card .card-building-art,
.command-card .card-icon {
  filter: grayscale(1) drop-shadow(0 2px 2px rgba(0, 0, 0, .42));
}

.command-card .card-icon {
  border-color: rgba(235, 235, 230, .58);
  background: #70706d;
  color: #f5f4ef;
  box-shadow: inset 0 0 0 2px rgba(25, 25, 25, .3);
}

.command-card small {
  color: #bdbdb8;
}

.command-deck.sell-target {
  outline-color: rgba(235, 235, 230, .48);
}

.command-deck.sell-target::before,
.command-deck.sell-target-valid {
  background-color: rgba(65, 65, 63, .97);
  color: #f4f3ef;
}

.augment-panel {
  background:
    radial-gradient(ellipse at center, rgba(235, 235, 230, .17), transparent 55%),
    rgba(22, 22, 21, .86);
  backdrop-filter: blur(4px);
}

.augment-card {
  border-color: rgba(60, 60, 58, .72);
  background:
    repeating-linear-gradient(90deg, rgba(60, 60, 58, .06) 0 1px, transparent 1px 13px),
    linear-gradient(100deg, #dddcd7, #aaa9a4);
  color: #242424;
  box-shadow: inset 0 0 0 2px rgba(50, 50, 48, .18), 0 14px 32px rgba(0, 0, 0, .34);
}

.augment-card:hover,
.augment-card.locked {
  border-color: #f2f1ec;
}

.augment-card > span,
.augment-card h3,
.augment-card p {
  color: #30302f;
}

.augment-card small {
  border-top-color: rgba(45, 45, 43, .25);
  color: #555553;
}

.augment-card.locked {
  box-shadow: inset 0 0 0 3px rgba(70, 70, 68, .22), 0 12px 28px rgba(0, 0, 0, .3);
}

.toast,
.toast.error {
  border-color: rgba(235, 235, 230, .54);
  background: rgba(42, 42, 40, .95);
  color: #efeee9;
}

.playtest-console {
  scrollbar-color: #6e6e6b #202020;
}

.playtest-console section {
  border-color: rgba(235, 235, 230, .25);
  background:
    linear-gradient(105deg, rgba(255, 255, 255, .025), transparent 24%),
    linear-gradient(145deg, rgba(48, 48, 46, .97), rgba(27, 27, 26, .98));
}

.danger-button,
.text-button,
.network-badge,
.network-badge.offline {
  border-color: rgba(235, 235, 230, .3);
  background: rgba(75, 75, 72, .24);
  color: #deddd8;
}

.battle-log time {
  color: #d6d5d0;
}

.phone-battle.territory-mode {
  background: #8f8f8b;
}

.phone-battle.territory-mode .name-line,
.phone-battle.territory-mode .battle-clock,
.phone-battle.cr-mode .battle-clock {
  border-color: rgba(235, 235, 230, .46);
  background: rgba(24, 24, 23, .84);
}

.phone-battle.territory-mode .name-line strong,
.phone-battle.territory-mode .name-line span,
.phone-battle.territory-mode .battle-clock strong,
.phone-battle.territory-mode .battle-clock span,
.phone-battle.cr-mode .battle-clock strong {
  color: #f4f3ef;
}

.phone-battle.territory-mode .summon-button {
  border-color: #d9d8d3;
  background: radial-gradient(circle at 50% 42%, rgba(175, 175, 170, .96) 0 48%, rgba(48, 48, 46, .97) 50% 100%);
  color: #f7f6f2;
}

.map-controls button {
  border-color: rgba(235, 235, 230, .42);
  background: rgba(30, 30, 29, .84);
  color: #f0efea;
}

.map-controls button:nth-child(2) {
  color: #c6c6c1;
}

.cr-action-row button {
  border-color: rgba(235, 235, 230, .42);
  background: linear-gradient(180deg, #d7d6d1, #8b8b87);
  color: #242424;
}

.phone-battle.cr-mode .player-resource-hud span {
  border-color: rgba(235, 235, 230, .32);
  background: rgba(18, 18, 17, .58);
}

.phone-battle.cr-mode .player-resource-hud small {
  color: #bdbdb8;
}

.phone-battle.cr-mode .player-resource-hud strong {
  color: #f1f0eb;
}

}

@layer legacy {
/* Ink-wash 3D presentation layer */
:root {
  --rice-paper: #d8cfb5;
  --rice-paper-light: #eee4c9;
  --ink-black: #24231c;
  --ink-soft: #4b493e;
  --cinnabar: #9b563f;
  --cinnabar-bright: #bc6a4e;
  --bronze: #c6a15a;
  --bronze-dark: #765c2f;
  --jade: #65784e;
  --smoke-blue: #53677f;
  --paper: #eee4c9;
  --paper-dim: #c7b994;
  --gold: #d8b96c;
  --panel: rgba(35, 34, 28, .94);
  --line: rgba(198, 161, 90, .34);
  --shadow: 0 18px 52px rgba(21, 19, 14, .42);
  color-scheme: dark;
  font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

html, body {
  background: #20251f;
}

body {
  background:
    radial-gradient(ellipse at 15% 10%, rgba(216, 207, 181, .12), transparent 34rem),
    radial-gradient(ellipse at 86% 16%, rgba(155, 86, 63, .12), transparent 30rem),
    repeating-linear-gradient(7deg, rgba(255,255,255,.012) 0 1px, transparent 1px 5px),
    linear-gradient(145deg, #1d241f, #303329 54%, #1e221d);
}

button, input, select { font-family: inherit; }
button { text-shadow: 0 1px 0 rgba(0,0,0,.36); }
button:hover:not(:disabled) { filter: brightness(1.12); }
button:active:not(:disabled) { transform: translateY(1px) scale(.985); }
button:focus-visible, input:focus-visible, select:focus-visible { outline-color: var(--bronze); }

.menu-screen { position: relative; }
.menu-screen::before,
.menu-screen::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 42vw;
  height: 34vh;
  opacity: .18;
  filter: blur(1px);
  pointer-events: none;
}
.menu-screen::before {
  top: 3vh;
  left: -7vw;
  background: radial-gradient(ellipse, rgba(216,207,181,.38), rgba(36,35,28,.72) 58%, transparent 72%);
  border-radius: 50% 46% 54% 42%;
  transform: rotate(-8deg);
}
.menu-screen::after {
  right: -9vw;
  bottom: 3vh;
  background: radial-gradient(ellipse, rgba(155,86,63,.3), rgba(36,35,28,.7) 60%, transparent 74%);
  border-radius: 42% 55% 45% 58%;
  transform: rotate(11deg);
}

.brand-block h1 {
  color: #ead59b;
  font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  font-weight: 900;
  letter-spacing: .2em;
  text-shadow: 0 3px 0 #4a3323, 0 8px 32px rgba(0,0,0,.5);
}
.brand-block p { color: #cbbd99; font-size: 14px; }
.eyebrow { color: var(--bronze); font-family: Inter, system-ui, sans-serif; }

.setup-card, .scope-note, .modal-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(198,161,90,.48);
  border-radius: 7px;
  background:
    linear-gradient(105deg, rgba(255,255,255,.06), transparent 24%),
    repeating-linear-gradient(3deg, rgba(255,255,255,.018) 0 1px, transparent 1px 4px),
    linear-gradient(145deg, rgba(63,57,43,.97), rgba(31,31,26,.98));
  box-shadow: inset 0 0 0 2px rgba(36,35,28,.55), var(--shadow);
}
.setup-card::after, .modal-card::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(216,185,108,.12);
  pointer-events: none;
}
.section-heading > span {
  border-color: var(--bronze);
  border-radius: 2px;
  color: var(--rice-paper-light);
  background: rgba(155,86,63,.34);
}
.section-heading h2, .mode-card h3 { font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; color: #ead9aa; }

.hero-option {
  border-radius: 4px;
  border-color: rgba(198,161,90,.28);
  background: linear-gradient(160deg, rgba(216,207,181,.09), rgba(0,0,0,.14));
}
.hero-option:hover { border-color: var(--bronze); }
.hero-option:has(input:checked) {
  border-color: var(--bronze);
  background: linear-gradient(150deg, rgba(155,86,63,.35), rgba(101,120,78,.22));
  box-shadow: inset 0 0 16px rgba(198,161,90,.12), 0 5px 18px rgba(0,0,0,.2);
}
.hero-option .seal {
  border: 1px solid rgba(235,215,163,.58);
  border-radius: 50% 47% 52% 45%;
  background: var(--jade);
  box-shadow: inset 0 0 0 3px rgba(30,35,27,.22), 0 3px 8px rgba(0,0,0,.3);
}
.hero-option.caocao .seal { background: var(--smoke-blue); }
.hero-option.sunquan .seal { background: var(--cinnabar); }

.mode-card {
  border-radius: 4px;
  border-color: rgba(198,161,90,.25);
  background: linear-gradient(135deg, rgba(20,20,17,.32), rgba(216,207,181,.035));
}
.mode-icon {
  border: 1px solid rgba(198,161,90,.4);
  border-radius: 50%;
  background: rgba(155,86,63,.22);
}
select, input {
  border-color: rgba(198,161,90,.38);
  border-radius: 3px;
  background: rgba(20,20,17,.48);
}
.primary-button, .secondary-button, .mode-card button, .tool-grid button, .danger-button, .text-button {
  border-radius: 3px;
}
.primary-button {
  border: 1px solid #cfaf68;
  background: linear-gradient(#aa5f45, #784231);
  color: #fff1cf;
  box-shadow: inset 0 1px rgba(255,255,255,.16), 0 7px 18px rgba(0,0,0,.24);
}

.phone-battle {
  isolation: isolate;
  border: 2px solid #8f713b;
  border-radius: 9px;
  background: var(--ink-black);
  box-shadow: 0 0 0 2px #2b281f, 0 0 0 4px rgba(198,161,90,.27), 0 26px 72px rgba(0,0,0,.52);
}
.phone-battle::before {
  content: "";
  position: absolute;
  z-index: 40;
  inset: 5px;
  border: 1px solid rgba(225,196,124,.33);
  box-shadow: inset 0 0 22px rgba(29,25,18,.28);
  pointer-events: none;
}
.phone-battle::after {
  content: "";
  position: absolute;
  z-index: 39;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 55%, rgba(236,226,197,.07), transparent 28%),
    radial-gradient(ellipse at 88% 32%, rgba(36,35,28,.09), transparent 30%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.battle-header {
  min-height: 60px;
  padding: 9px 12px 8px;
  border-bottom: 2px solid var(--bronze-dark);
  background:
    linear-gradient(90deg, rgba(155,86,63,.28), transparent 35%, transparent 65%, rgba(101,120,78,.25)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 6px),
    linear-gradient(#342d22, #201f1a);
  box-shadow: 0 4px 14px rgba(0,0,0,.34);
}
.name-line { font-size: 12px; font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; }
.name-line strong { color: #f2dfac; font-size: 14px; }
.name-line span { color: #c9bb94; font-family: Inter, system-ui, sans-serif; font-size: 9px; }
.battle-clock {
  min-width: 92px;
  padding: 3px 8px;
  border-right: 1px solid rgba(198,161,90,.42);
  border-left: 1px solid rgba(198,161,90,.42);
  background: rgba(16,16,13,.28);
}
.battle-clock strong { color: #f3d785; font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; font-size: 16px; }
.hq-bar {
  height: 14px;
  border-color: rgba(220,191,119,.38);
  border-radius: 2px;
  background: rgba(12,12,10,.68);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.42);
}
.hq-bar span { background: linear-gradient(90deg, #6f302b, #b65d47, #d28a66); }
.player-summary.self .hq-bar span { background: linear-gradient(90deg, #344d31, #677c4f, #9aae75); }

.battle-stage {
  background: linear-gradient(#bdb59f, #8f927e);
  box-shadow: inset 0 0 28px rgba(36,35,28,.42);
}
#battle-canvas { filter: saturate(.92) contrast(1.03); }

.selection-panel {
  right: 12px;
  bottom: 10px;
  left: 12px;
  border: 1px solid var(--bronze);
  border-radius: 3px;
  background:
    repeating-linear-gradient(4deg, rgba(36,35,28,.035) 0 1px, transparent 1px 4px),
    linear-gradient(100deg, rgba(235,224,194,.97), rgba(202,188,150,.97));
  color: var(--ink-black);
  box-shadow: 0 8px 24px rgba(0,0,0,.32), inset 0 0 0 2px rgba(94,72,39,.17);
}
.selection-panel h3 { color: #6d3c2d; font-size: 13px; }
.selection-panel p { color: #494337; font-size: 10px; }
.selection-panel .danger-button { color: #fff0d3; background: linear-gradient(#9f513d, #6f372d); }

.command-deck {
  position: relative;
  min-height: 105px;
  padding: 8px 9px 7px;
  border-top: 2px solid var(--bronze-dark);
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.018) 0 1px, transparent 1px 7px),
    linear-gradient(#383024, #211f19);
  box-shadow: 0 -5px 16px rgba(0,0,0,.3);
}
.summon-button {
  --summon-progress: 0%;
  position: relative;
  overflow: hidden;
  border: 1px solid #d6b66a;
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(215,181,91,.72) 0 var(--summon-progress), transparent var(--summon-progress) 100%),
    linear-gradient(145deg, #8c4b3b, #65382f 58%, #4a2b25);
  color: #fff0c6;
  box-shadow: inset 0 0 0 2px rgba(73,35,27,.38), inset 0 1px rgba(255,255,255,.18), 0 5px 14px rgba(0,0,0,.3);
  font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}
.summon-button::before {
  content: "令";
  position: absolute;
  right: -5px;
  bottom: -16px;
  color: rgba(243,221,165,.09);
  font: 900 72px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}
.summon-button[data-blocked="true"] { cursor: pointer; opacity: .72; filter: saturate(.72); }
.summon-button[data-affordable="true"] { border-color: #f0cf76; box-shadow: inset 0 0 0 2px rgba(73,35,27,.38), inset 0 1px rgba(255,255,255,.22), 0 0 13px rgba(225,188,88,.24); }

.command-card {
  position: relative;
  overflow: hidden;
  min-height: 68px;
  border: 1px solid rgba(198,161,90,.44);
  border-radius: 3px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.035), transparent 18%, transparent 82%, rgba(0,0,0,.12)),
    linear-gradient(#5a4933, #342c22);
  color: #f0dfb0;
  box-shadow: inset 0 0 0 2px rgba(28,25,19,.28);
}
.command-card::after {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(234,211,151,.09);
  pointer-events: none;
}
.command-card:hover:not(:disabled) { transform: translateY(-2px); border-color: #d7b767; }
.command-card.selected {
  border-color: #f0cc71;
  transform: translateY(-6px);
  background: linear-gradient(#76563a, #463426);
  box-shadow: 0 7px 18px rgba(0,0,0,.36), 0 0 14px rgba(214,182,106,.22);
}
.command-card.merge-target {
  border-color: #f0cc71;
  box-shadow: inset 0 0 0 2px rgba(240,204,113,.3), 0 0 16px rgba(240,204,113,.34);
}
.command-card .card-building-art {
  display: block;
  width: 50px;
  height: 44px;
  margin: -2px auto 1px;
  overflow: visible;
  color: #fff0c6;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.42));
}
.command-card .card-building-model { fill: var(--building-color); }
.command-card .building-icon-svg { vector-effect: non-scaling-stroke; }
.command-card .card-icon {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  margin: 0 auto 3px;
  border: 1px solid rgba(237,211,145,.66);
  border-radius: 50%;
  background: var(--cinnabar);
  color: #fff0cb;
  font: 800 14px "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  box-shadow: inset 0 0 0 2px rgba(73,35,27,.3);
}
.command-card strong { font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; font-size: 11px; }
.command-card small { color: #beaF88; font-size: 8px; }
.interaction-hint { color: #9f9478; font-size: 9px; }

.augment-panel {
  background:
    radial-gradient(ellipse at center, rgba(232,221,190,.2), transparent 55%),
    rgba(25,24,20,.82);
  backdrop-filter: blur(4px) sepia(.2);
}
.augment-heading h2 { color: #f1d997; font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; }
.augment-card {
  border: 1px solid rgba(198,161,90,.72);
  border-radius: 4px;
  background:
    repeating-linear-gradient(90deg, rgba(80,60,36,.07) 0 1px, transparent 1px 13px),
    linear-gradient(100deg, #d5c69f, #aa9871);
  color: var(--ink-black);
  text-shadow: none;
  box-shadow: inset 0 0 0 2px rgba(68,52,31,.2), 0 14px 32px rgba(0,0,0,.34);
}
.augment-card:hover { border-color: #f0cc71; transform: translateY(-5px) rotate(-.4deg); }
.augment-card:nth-child(2):hover { transform: translateY(-5px) rotate(.35deg); }
.augment-card > span { color: #874a37; }
.augment-card h3 { color: #342b20; font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; }
.augment-card p { color: #3f382d; }
.augment-card small { border-top-color: rgba(79,59,34,.28); color: #5f503c; }
.augment-card.locked { border-color: #6f8659; box-shadow: inset 0 0 0 3px rgba(77,103,62,.25), 0 12px 28px rgba(0,0,0,.3); }

.toast {
  bottom: 18px;
  border-color: rgba(222,192,116,.62);
  border-radius: 3px;
  background: rgba(42,38,28,.94);
  color: #f0dba6;
  font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.playtest-console {
  scrollbar-color: #725e36 #22251f;
}
.console-heading h2 { color: #ead6a0; font-size: 27px; }
.console-heading p { color: #91886f; }
.playtest-console section {
  border-color: rgba(198,161,90,.32);
  border-radius: 4px;
  background:
    linear-gradient(105deg, rgba(255,255,255,.025), transparent 24%),
    linear-gradient(145deg, rgba(46,47,39,.96), rgba(27,29,24,.97));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.28), 0 8px 24px rgba(0,0,0,.2);
}
.playtest-console h3 { color: #dfc681; font-family: "RTS WenKai", "LXGW WenKai", "KaiTi", serif; font-size: 14px; }
.playtest-console p { color: #bbb08e; }
.tool-grid button, .exit-actions button {
  border-color: rgba(198,161,90,.32);
  background: linear-gradient(#3d3a30, #292821);
}
.danger-button { border-color: rgba(182,89,65,.54); color: #f0b09d; background: rgba(125,58,46,.24); }
.text-button { border-color: rgba(198,161,90,.3); }
.network-badge { border: 1px solid rgba(120,154,101,.32); border-radius: 2px; background: rgba(76,105,65,.24); color: #acd097; }
.augment-tags span { border-radius: 2px; }
.battle-log li { font-size: 10px; }

.modal-card { color: #eadcaf; }
.room-code { color: #f2d787; font-family: Inter, system-ui, sans-serif; }

@media (max-width: 640px) {
  .battle-header { min-height: 54px; padding: 7px 8px; }
  .battle-clock { min-width: 76px; padding-inline: 3px; }
  .battle-clock strong { font-size: 13px; }
  .command-deck { min-height: 96px; }
  .command-card { min-height: 60px; }
  .command-card .card-building-art { width: 45px; height: 40px; }
}

/* 占城like：地图主界面 */
.desktop-battle-layout.territory-mode {
  grid-template-columns: minmax(420px, 650px) minmax(270px, 320px);
  width: min(1000px, 100%);
}
.phone-battle.territory-mode {
  display: block;
  width: min(100%, calc((100vh - 12px) * 9 / 16), 650px);
  background: #787c63;
}
.phone-battle.territory-mode .battle-stage {
  position: absolute;
  inset: 0;
  display: block;
}
.phone-battle.territory-mode .battle-header {
  position: absolute;
  z-index: 20;
  top: 10px;
  right: 10px;
  left: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}
.phone-battle.territory-mode .player-summary {
  min-width: 0;
}
.phone-battle.territory-mode .name-line {
  display: grid;
  gap: 1px;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 6px 8px;
  border: 1px solid rgba(241,216,151,.48);
  border-radius: 9px;
  background: rgba(20,24,18,.78);
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  backdrop-filter: blur(4px);
  text-align: left;
}
.phone-battle.territory-mode .player-summary.self .name-line {
  justify-items: end;
  margin-left: auto;
  text-align: right;
}
.phone-battle.territory-mode .name-line strong {
  overflow: hidden;
  color: #fff0bd;
  font: 800 11px/1.15 Inter, system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.phone-battle.territory-mode .name-line span {
  display: block;
  color: #cbd8a3;
  font: 700 9px/1.1 Inter, system-ui, sans-serif;
}
.phone-battle.territory-mode .hq-bar {
  display: none;
}
.phone-battle.territory-mode .battle-clock {
  min-width: 88px;
  padding: 6px 9px 5px;
  border: 1px solid rgba(241,216,151,.55);
  border-radius: 9px;
  background: rgba(26,25,19,.84);
  box-shadow: 0 4px 14px rgba(0,0,0,.34);
  backdrop-filter: blur(4px);
}
.phone-battle.territory-mode .battle-clock strong {
  color: #fff0bd;
  font: 900 13px/1.1 Inter, system-ui, sans-serif;
}
.phone-battle.territory-mode .battle-clock span {
  margin-top: 3px;
  color: #d2e5a5;
  font: 800 9px/1 Inter, system-ui, sans-serif;
}
.phone-battle.territory-mode .command-deck {
  position: absolute;
  z-index: 22;
  bottom: 16px;
  left: 50%;
  display: block;
  width: 88px;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%);
  pointer-events: none;
}
.phone-battle.territory-mode .summon-button {
  width: 88px;
  height: 88px;
  padding: 8px;
  border: 3px solid #c9a351;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(192,148,62,.95) 0 48%, rgba(56,43,25,.96) 50% 100%);
  box-shadow: 0 0 0 3px rgba(25,28,20,.88), 0 8px 22px rgba(0,0,0,.48);
  color: #fff3c5;
  font: 800 12px/1.05 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  pointer-events: auto;
}
.phone-battle.territory-mode .summon-button strong {
  margin-top: 4px;
  font: 900 16px/1 Inter, system-ui, sans-serif;
}
.phone-battle.territory-mode .interaction-hint,
.phone-battle.territory-mode .card-row {
  display: none;
}
.phone-battle.territory-mode .selection-panel {
  right: 58px;
  bottom: 114px;
  left: 10px;
}
.phone-battle.territory-mode .toast {
  bottom: 118px;
}
.map-controls {
  position: absolute;
  z-index: 21;
  right: 10px;
  bottom: 112px;
  display: grid;
  gap: 5px;
}
.map-controls button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(239,215,151,.5);
  border-radius: 50%;
  background: rgba(24,28,21,.82);
  color: #f1dda0;
  font: 800 18px/1 Inter, system-ui, sans-serif;
  box-shadow: 0 4px 12px rgba(0,0,0,.32);
  backdrop-filter: blur(4px);
}
.map-controls button:nth-child(2) {
  color: #bcd99b;
  font-size: 15px;
}
.phone-battle.territory-mode #battle-canvas {
  cursor: grab;
}
.phone-battle.territory-mode #battle-canvas.panning-map {
  cursor: grabbing;
}

@media (max-width: 900px) {
  .desktop-battle-layout.territory-mode {
    grid-template-columns: minmax(0, 650px);
  }
  .desktop-battle-layout.territory-mode .phone-battle {
    justify-self: center;
  }
}

.ruleset-option.cr:has(input:checked) {
  border-color: rgba(196, 151, 73, .9);
  box-shadow: inset 0 0 0 1px rgba(241, 205, 118, .35);
}

.cr-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 1;
}

.cr-action-row button {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid rgba(134, 91, 35, .55);
  background: linear-gradient(180deg, #f1d98d, #bd8334);
  color: #2d2115;
  font-weight: 800;
}

.cr-action-row button strong { display: block; font-size: 12px; }
.cr-action-row button[data-insufficient-funds="true"]:not(:disabled) {
  cursor: pointer;
  border-color: rgba(91, 91, 86, .72);
  background: linear-gradient(180deg, rgba(151, 153, 151, .88), rgba(83, 86, 84, .94));
  opacity: 1;
  filter: none;
}
.cr-action-row button:disabled { filter: grayscale(.65); opacity: .58; }

.phone-battle.cr-mode .command-deck {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr);
  grid-template-rows: 80px;
  gap: 8px;
  min-height: 94px;
  padding: 7px 9px 6px;
  align-items: center;
}

.phone-battle.cr-mode {
  grid-template-rows: minmax(0, 1fr) auto;
}

.phone-battle.cr-mode .battle-header {
  position: absolute;
  z-index: 25;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  display: block;
  width: max-content;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  transform: translateX(-50%);
  pointer-events: none;
}

.phone-battle.cr-mode .player-summary { display: none; }
.phone-battle.cr-mode .battle-clock span { display: none; }

.phone-battle.cr-mode .battle-clock {
  min-width: 112px;
  padding: 7px 15px 6px;
  border: 1px solid rgba(241, 216, 151, .62);
  border-radius: 999px;
  background: rgba(23, 22, 17, .84);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .36);
  backdrop-filter: blur(5px);
}

.phone-battle.cr-mode .battle-clock strong {
  color: #fff0bd;
  font: 900 32px/1 Inter, system-ui, sans-serif;
  letter-spacing: .03em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, .62);
}

.phone-battle.cr-mode .player-resource-hud {
  --gold-progress: 0%;
  position: relative;
  z-index: 1;
  grid-column: 3;
  grid-row: 1;
  display: grid;
  width: 48px;
  min-width: 48px;
  min-height: 52px;
  grid-template-rows: auto auto;
  justify-self: end;
  place-content: center;
  place-items: center;
  gap: 3px;
  overflow: hidden;
  padding: 5px 4px;
  border: 1px solid rgba(24, 24, 22, .44);
  border-radius: 9px;
  background: rgba(255, 253, 247, .94);
  box-shadow: inset 0 -3px 0 rgba(24, 24, 22, .08);
}

.phone-battle.cr-mode .player-resource-hud::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--gold-progress);
  background: linear-gradient(180deg, rgba(207, 160, 62, .68), rgba(165, 105, 31, .9));
  transition: height 120ms linear;
}

.phone-battle.cr-mode .player-resource-hud strong {
  position: relative;
  z-index: 2;
  color: #24211b;
  font: 900 15px/1 Inter, system-ui, sans-serif;
  white-space: nowrap;
}

.phone-battle.cr-mode .player-resource-hud small {
  position: relative;
  z-index: 2;
  color: #245438;
  font: 900 10px/1 Inter, system-ui, sans-serif;
  letter-spacing: .03em;
  white-space: nowrap;
}

.phone-battle.cr-mode .player-hero-hud {
  --hero-progress: 0%;
  position: relative;
  z-index: 1;
  display: grid;
  width: 48px;
  min-width: 48px;
  min-height: 52px;
  grid-template-rows: auto auto;
  place-content: center;
  place-items: center;
  overflow: hidden;
  padding: 5px 4px;
  border: 1px solid rgba(24, 24, 22, .44);
  border-radius: 9px;
  background: rgba(255, 253, 247, .94);
  box-shadow: inset 0 -3px 0 rgba(24, 24, 22, .08);
}

.phone-battle.cr-mode .player-hero-hud::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--hero-progress);
  background: linear-gradient(180deg, rgba(125, 181, 239, .64), rgba(47, 115, 211, .88));
  transition: height 120ms linear;
}

.phone-battle.cr-mode .player-hero-hud span,
.phone-battle.cr-mode .player-hero-hud strong {
  position: relative;
  z-index: 2;
  color: #24211b;
  white-space: nowrap;
}

.phone-battle.cr-mode .player-hero-hud span {
  font: 800 12px/1.05 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.phone-battle.cr-mode .player-hero-hud strong {
  margin-top: 4px;
  font: 900 13px/1 Inter, system-ui, sans-serif;
}

.phone-battle.cr-mode .card-row { display: none; }
.phone-battle.cr-mode .interaction-hint { display: none; }
.phone-battle.cr-mode .cr-action-row { display: contents; }

.phone-battle.cr-mode .selection-panel {
  z-index: 27;
  right: auto;
  bottom: 26%;
  left: 50%;
  width: min(210px, calc(100% - 24px));
  min-height: 72px;
  grid-template-columns: minmax(0, 1fr);
  padding: 10px 14px;
  transform: translateX(-50%);
  pointer-events: none;
}

.phone-battle.cr-mode .selection-panel h3 {
  margin-bottom: 5px;
  font-size: 14px;
  line-height: 1.2;
}

.phone-battle.cr-mode .selection-panel p {
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-line;
}

.phone-battle.cr-mode .toast {
  z-index: 30;
  top: auto;
  bottom: calc(26% + 18px);
  width: max-content;
  max-width: min(230px, calc(100% - 24px));
  margin: 0;
  text-align: center;
  white-space: normal;
  pointer-events: none;
}

.phone-battle.cr-mode .cr-left-action {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  min-width: 0;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}

.phone-battle.cr-mode .cr-action-row button {
  --recruit-cooldown-progress: 0%;
  position: relative;
  z-index: 0;
  min-width: 0;
  min-height: 52px;
  padding: 6px 5px;
  border-radius: 9px;
  color: #24211b;
  overflow: hidden;
  isolation: isolate;
  transition: transform 70ms ease-out, filter 70ms ease-out, box-shadow 70ms ease-out;
}

.phone-battle.cr-mode .cr-action-row button:active:not(:disabled) {
  transform: translateY(2px) scale(.96);
  filter: brightness(.78);
  box-shadow:
    inset 0 4px 8px rgba(24, 24, 22, .42),
    inset 0 0 0 1px rgba(24, 24, 22, .28);
}

.phone-battle.cr-mode #research-button { width: 100%; }

.research-panel .augment-card.quality-1 { border-color: rgba(73, 143, 214, .9); }
.research-panel .augment-card.quality-2 { border-color: rgba(153, 91, 201, .9); }
.research-panel .augment-card.quality-3 { border-color: rgba(221, 176, 83, .9); box-shadow: 0 0 22px rgba(221, 176, 83, .16); }
.research-panel .augment-card.quality-1 .research-quality-label { color: #3f86cf; }
.research-panel .augment-card.quality-2 .research-quality-label { color: #9254c7; }
.research-panel .augment-card.quality-3 .research-quality-label { color: #d47b27; }

.phone-battle.cr-mode #recruit-button {
  grid-column: 3;
  grid-row: 1;
  width: calc(100% - 54px);
  justify-self: start;
}

.phone-battle.cr-mode .cr-action-row button::before {
  content: "";
  position: absolute;
  z-index: -1;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--recruit-cooldown-progress);
  background: linear-gradient(180deg, rgba(151, 153, 151, .88), rgba(83, 86, 84, .94));
  transition: height 120ms linear;
  pointer-events: none;
}

.phone-battle.cr-mode #recruit-button[data-cooling-down="true"]:disabled {
  opacity: 1;
  filter: none;
}

.phone-battle.cr-mode .summon-button {
  grid-column: 2;
  grid-row: 1;
  z-index: 0;
  width: 70px;
  height: 78px;
  justify-self: center;
  padding: 10px 7px 8px;
  border: 0;
  border-radius: 0;
  clip-path: polygon(18% 0, 82% 0, 100% 14%, 100% 86%, 82% 100%, 18% 100%, 0 86%, 0 14%);
  background: linear-gradient(180deg, #f4e8bd, #dcbf72);
  color: #24211b;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .32));
  box-shadow: none;
  cursor: default;
  opacity: 1;
  pointer-events: none;
  white-space: normal;
}

.phone-battle.cr-mode .summon-button::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--summon-progress);
  background: linear-gradient(180deg, rgba(207, 160, 62, .68), rgba(165, 105, 31, .9));
  transition: height 120ms linear;
}

.phone-battle.cr-mode .summon-button::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 4px;
  border: 1px solid rgba(70, 47, 20, .62);
  clip-path: inherit;
  pointer-events: none;
}

.phone-battle.cr-mode .summon-button .summon-token-label,
.phone-battle.cr-mode .summon-button strong {
  position: relative;
  z-index: 2;
  display: block;
  color: #24211b;
  text-shadow: 0 1px rgba(255, 255, 255, .28);
}

.phone-battle.cr-mode .summon-button .summon-token-label {
  font: 800 13px/1.1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.phone-battle.cr-mode .summon-button strong {
  margin-top: 5px;
  font: 900 29px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.phone-battle.cr-mode .summon-button:disabled {
  opacity: 1;
  filter: drop-shadow(0 5px 6px rgba(0, 0, 0, .32));
}

@media (prefers-reduced-motion: reduce) {
  .phone-battle.cr-mode .summon-button::before,
  .phone-battle.cr-mode .cr-action-row button::before,
  .phone-battle.cr-mode .player-resource-hud::before,
  .phone-battle.cr-mode .player-hero-hud::before { transition: none; }
}

.cr-stage-clock,
.cr-scoreboard {
  display: none;
}

.phone-battle.cr-mode .battle-header {
  display: none;
}

.phone-battle.cr-mode .cr-stage-clock {
  position: absolute;
  z-index: 18;
  top: 45%;
  left: 50%;
  display: grid;
  width: max-content;
  min-width: 76px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  row-gap: 2px;
  text-align: center;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

.phone-battle.cr-mode .cr-stage-clock strong {
  color: var(--ink-black);
  font: 900 16px/1.05 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .08em;
}

.phone-battle.cr-mode .cr-stage-clock time {
  margin-top: 0;
  color: var(--ink-black);
  font: 900 22px/1 Inter, system-ui, sans-serif;
  letter-spacing: .02em;
}

.phone-battle.cr-mode .cr-scoreboard {
  position: absolute;
  z-index: 19;
  top: 42%;
  right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 8px 4px;
  color: var(--ink-black);
  transform: translateY(-50%);
  pointer-events: none;
}

.phone-battle.cr-mode .cr-mineboard {
  right: auto;
  left: 10px;
}

.cr-tally-label {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  color: var(--ink-black);
  font: 900 16px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .08em;
  white-space: nowrap;
  transform: translateX(-50%);
}

.cr-scoreboard span,
.cr-scoreboard i {
  display: block;
  font-style: normal;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 2px rgba(255, 253, 247, .95), 0 1px 0 #fffdf7;
}

.cr-scoreboard strong {
  font: 900 30px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.cr-scoreboard .enemy-score { color: var(--enemy-red); }
.cr-scoreboard .local-score { color: var(--ally-blue); }
.cr-scoreboard i { margin: 4px 0 5px; color: var(--ink-black); font: 900 22px/1 Inter, system-ui, sans-serif; }

.cr-phase-announcement,
.cr-score-announcement {
  position: absolute;
  z-index: 31;
  left: 50%;
  display: grid;
  min-width: 190px;
  padding: 13px 24px 11px;
  border: 2px solid rgba(24, 24, 22, .72);
  background: rgba(255, 253, 247, .92);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .8), 0 8px 22px rgba(24, 24, 22, .18);
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.cr-phase-announcement {
  top: 50%;
  background: #fffdf7;
}
.cr-score-announcement.enemy-half { top: 29%; }
.cr-score-announcement.local-half { top: 71%; }

.cr-phase-announcement strong,
.cr-score-announcement strong {
  font: 900 30px/1.05 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .12em;
}

.cr-phase-announcement span {
  margin-top: 7px;
  color: rgba(24, 24, 22, .72);
  font: 800 14px/1.1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .18em;
}

.cr-score-announcement[data-faction="blue"] { color: var(--ally-blue); }
.cr-score-announcement[data-faction="red"] { color: var(--enemy-red); }

@media (max-width: 640px) {
  .phone-battle.territory-mode {
    width: min(100%, calc((100dvh - 12px) * 9 / 16));
  }
  .phone-battle.territory-mode .battle-header {
    top: 7px;
    right: 7px;
    left: 7px;
    gap: 5px;
  }
  .phone-battle.territory-mode .name-line {
    padding: 5px 6px;
  }
  .phone-battle.territory-mode .battle-clock {
    min-width: 76px;
    padding: 5px 6px;
  }
  .map-controls {
    right: 7px;
  }
}
}

#research-panel.research-panel {
  background: rgba(18, 17, 14, .42);
  backdrop-filter: none;
}

/* Desktop CR battle guide */
.playtest-console .battle-guide {
  display: grid;
  gap: 6px;
  padding: 10px 12px 11px;
}

.battle-guide h3 {
  margin-bottom: 0;
  text-align: center;
}

.counter-cycle {
  position: relative;
  width: min(186px, 100%);
  height: 158px;
  margin: 0 auto;
}

.counter-cycle svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.counter-cycle svg > path {
  fill: none;
  stroke: rgba(24, 24, 22, .68);
  stroke-width: 2.3;
  stroke-linecap: round;
  marker-end: url(#counter-arrow);
  vector-effect: non-scaling-stroke;
}

.counter-cycle marker path {
  fill: rgba(24, 24, 22, .76);
}

.counter-node {
  position: absolute;
  z-index: 2;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid rgba(24, 24, 22, .76);
  border-radius: 50%;
  background: rgba(255, 253, 247, .96);
  color: var(--ink-black);
  box-shadow: 0 3px 0 rgba(24, 24, 22, .12);
  font: 900 21px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.counter-node.rider { top: 0; left: 50%; transform: translateX(-50%); }
.counter-node.blade { top: 50%; right: 0; transform: translateY(-50%); }
.counter-node.bow { bottom: 0; left: 50%; transform: translateX(-50%); }
.counter-node.spear { top: 50%; left: 0; transform: translateY(-50%); }

.counter-core {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 70px;
  min-height: 48px;
  place-content: center;
  border: 1px solid rgba(24, 24, 22, .34);
  background: rgba(255, 253, 247, .76);
  text-align: center;
  transform: translate(-50%, -50%);
}

.counter-core strong {
  font: 900 17px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.counter-core small {
  margin-top: 4px;
  color: rgba(24, 24, 22, .7);
  font: 800 10px/1 Inter, system-ui, sans-serif;
}

.playtest-console .counter-caption {
  margin: -2px 0 0;
  color: var(--ink-black);
  text-align: center;
  font: 800 11px/1.3 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.battle-guide-rules {
  display: grid;
  gap: 4px;
}

.battle-guide-rules article {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  padding: 5px 8px;
  border-left: 3px solid rgba(24, 24, 22, .7);
  background: rgba(255, 253, 247, .58);
}

.battle-guide-rules strong {
  color: var(--ink-black);
  font: 900 13px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.battle-guide-rules span {
  color: rgba(24, 24, 22, .72);
  font: 700 9.5px/1.3 system-ui, sans-serif;
}

.battle-guide-rules .merge-rule span { white-space: nowrap; }

.playtest-console .recruit-timing {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 9px 10px;
  border: 2px solid rgba(24, 24, 22, .72);
  background: rgba(255, 253, 247, .82);
  color: var(--ink-black);
  text-align: center;
}

.recruit-timing strong {
  font: 900 16px/1.1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
}

.recruit-timing span {
  color: rgba(24, 24, 22, .72);
  font: 700 11px/1.4 system-ui, sans-serif;
}

.playtest-console .battle-log {
  max-height: 60px;
  overflow: auto;
}

/* Match result actions */
.rematch-button {
  position: absolute;
  z-index: 24;
  left: 50%;
  bottom: 19%;
  min-width: 92px;
  padding: 7px 16px 8px;
  border: 2px solid rgba(24, 24, 22, .78);
  border-radius: 3px;
  background:
    repeating-linear-gradient(2deg, rgba(24, 24, 22, .04) 0 1px, transparent 1px 4px),
    rgba(255, 253, 247, .94);
  color: var(--ink-black);
  box-shadow: 0 4px 0 rgba(24, 24, 22, .18), 0 8px 18px rgba(24, 24, 22, .2);
  font: 900 16px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  transform: translateX(-50%);
  cursor: pointer;
}

.rematch-button:hover:not(:disabled) { transform: translate(-50%, -1px); }
.rematch-button:active:not(:disabled) { transform: translate(-50%, 1px); }
.rematch-button:disabled { cursor: wait; opacity: .62; }
.rematch-button[hidden] { display: none; }

.exit-actions #pause-button {
  border-color: rgba(24, 24, 22, .5);
  background: rgba(255, 253, 247, .72);
  color: var(--ink-black);
}

/* Home screen directly inherits the active battle's xuan-paper art direction. */
.menu-screen {
  width: 100%;
  min-height: 100vh;
  margin: 0;
  padding: 12px;
}

.home-layout {
  display: grid;
  grid-template-columns: minmax(360px, 540px) minmax(280px, 340px);
  gap: 18px;
  align-items: start;
  justify-content: center;
  width: min(920px, 100%);
  margin: 0 auto;
}

.home-phone {
  position: relative;
  isolation: isolate;
  justify-self: end;
  width: min(100%, calc((100vh - 24px) * 9 / 16), 540px);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid #242422;
  border-radius: 5px;
  background:
    radial-gradient(ellipse at 9% 49%, rgba(24, 24, 22, .045), transparent 24%),
    radial-gradient(ellipse at 91% 31%, rgba(24, 24, 22, .035), transparent 24%),
    repeating-linear-gradient(4deg, rgba(30, 30, 28, .012) 0 1px, transparent 1px 7px),
    var(--rice-paper-light);
  color: var(--ink-black);
  box-shadow: 0 0 0 3px rgba(255, 253, 247, .9), 0 0 0 4px rgba(24, 24, 22, .24), 0 24px 58px rgba(24, 24, 22, .18);
}

.home-phone::before {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: 20;
  border: 1px solid rgba(24, 24, 22, .13);
  pointer-events: none;
}

.home-phone::after {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 20% 7% 14%;
  background:
    linear-gradient(rgba(24, 24, 22, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(24, 24, 22, .045) 1px, transparent 1px);
  background-size: 100% 12.5%, 12.5% 100%;
  mask-image: linear-gradient(180deg, transparent, #000 19%, #000 76%, transparent);
  pointer-events: none;
}

.home-sun { display: none; }

.home-mountain {
  position: absolute;
  right: -8%;
  left: -8%;
  z-index: -1;
  display: block;
  background: linear-gradient(180deg, rgba(24, 24, 22, .015), rgba(24, 24, 22, .14));
  filter: blur(.35px);
}

.home-mountain-back {
  top: 38%;
  height: 32%;
  clip-path: polygon(0 72%, 8% 56%, 17% 65%, 30% 34%, 38% 56%, 49% 21%, 57% 49%, 70% 31%, 83% 64%, 92% 50%, 100% 69%, 100% 100%, 0 100%);
  opacity: .34;
}

.home-mountain-front {
  bottom: -1%;
  height: 30%;
  clip-path: polygon(0 46%, 10% 28%, 21% 42%, 35% 20%, 47% 55%, 62% 32%, 75% 48%, 88% 17%, 100% 34%, 100% 100%, 0 100%);
  opacity: .34;
}

.home-cloud {
  position: absolute;
  z-index: 1;
  display: block;
  width: 34%;
  height: 4%;
  border-top: 2px solid rgba(24, 24, 22, .11);
  border-radius: 50%;
  filter: blur(.6px);
}

.home-cloud-one { top: 27%; left: -5%; transform: rotate(-8deg); }
.home-cloud-two { top: 49%; right: -6%; transform: rotate(7deg); }

.home-brand {
  position: absolute;
  z-index: 3;
  top: 10%;
  right: 8%;
  left: 8%;
  text-align: center;
}

.home-brand::after {
  content: "";
  display: block;
  width: 42%;
  height: 3px;
  margin: 15px auto 0;
  background: var(--ink-black);
  opacity: .9;
}

.home-brand > span {
  color: var(--ink-soft);
  font: 800 clamp(8px, 1.2vw, 11px)/1 Inter, system-ui, sans-serif;
  letter-spacing: .28em;
}

.home-brand h1 {
  margin: 12px 0 5px;
  color: var(--ink-black);
  font: 900 clamp(42px, 7.1vw, 72px)/.95 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .12em;
  text-indent: .12em;
  text-shadow: none;
}

.home-brand p {
  margin: 8px 0 0;
  color: var(--ink-soft);
  font: 800 clamp(11px, 1.55vw, 15px)/1.2 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .18em;
}

.home-rank-card {
  position: absolute;
  z-index: 4;
  top: 30%;
  left: 50%;
  display: grid;
  width: 72%;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 6px 13px;
  align-items: center;
  padding: 14px 18px 12px;
  border: 0;
  border-bottom: 1px solid rgba(24, 24, 22, .18);
  border-left: 3px solid rgba(24, 24, 22, .78);
  border-radius: 0;
  background:
    repeating-linear-gradient(3deg, rgba(35, 35, 32, .012) 0 1px, transparent 1px 6px),
    rgba(255, 253, 247, .76);
  box-shadow: none;
  transform: translateX(-50%);
}

.home-rank-card::before,
.home-rank-card::after { display: none; }

.rank-seal {
  display: grid;
  grid-row: 1 / 3;
  width: 52px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--ink-black);
  border-radius: 50%;
  background: rgba(255, 253, 247, .94);
  color: var(--ink-black);
  font: 900 28px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  transform: none;
}

.rank-copy { display: grid; gap: 2px; }
.rank-copy small { color: var(--ink-soft); font: 800 9px/1 Inter, system-ui, sans-serif; letter-spacing: .18em; }
.rank-copy strong { color: var(--ink-black); font: 900 clamp(21px, 3.4vw, 31px)/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif; letter-spacing: .12em; }

.rank-stars {
  display: flex;
  grid-column: 1 / -1;
  gap: 9px;
  justify-content: center;
  margin-top: 4px;
}

.rank-stars span {
  color: rgba(255, 253, 247, .92);
  font-size: clamp(26px, 4.2vw, 38px);
  line-height: 1;
  -webkit-text-stroke: 1.5px rgba(24, 24, 22, .72);
  text-shadow: none;
  transition: color .18s ease, transform .18s ease;
}

.rank-stars span.filled {
  color: var(--ally-blue);
  -webkit-text-stroke-color: #225ab0;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
  transform: translateY(-1px);
}

.home-rank-card > p {
  grid-column: 1 / -1;
  margin: 1px 0 0;
  color: var(--ink-soft);
  text-align: center;
  font: 800 10px/1.2 Inter, system-ui, sans-serif;
  letter-spacing: .04em;
}

.home-standard {
  position: absolute;
  z-index: 2;
  top: 53%;
  left: 50%;
  display: grid;
  width: 34%;
  place-items: center;
  transform: translateX(-50%);
}

.home-standard i { display: none; }

.home-standard b {
  position: relative;
  display: grid;
  width: 82px;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(24, 24, 22, .76);
  border-radius: 50%;
  background:
    linear-gradient(0deg, rgba(63, 127, 232, .38) 0 34%, rgba(255, 253, 247, .94) 34% 100%);
  color: var(--ink-black);
  box-shadow: 0 4px 0 rgba(24, 24, 22, .08);
  font: 900 45px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  transform: none;
}

.home-standard b::after {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1px solid rgba(24, 24, 22, .24);
  border-radius: 50%;
}

.home-standard span {
  margin-top: 9px;
  color: var(--ink-soft);
  font: 900 11px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .12em;
  white-space: nowrap;
}

.home-start-button {
  position: absolute;
  z-index: 6;
  bottom: 11%;
  left: 50%;
  display: grid;
  width: 60%;
  min-height: 64px;
  place-content: center;
  gap: 5px;
  border: 1px solid var(--ink-black);
  border-radius: 1px;
  background: var(--ink-black);
  color: var(--rice-paper-light);
  box-shadow: none;
  text-align: center;
  transform: translateX(-50%);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease;
}

.home-start-button::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255, 253, 247, .28);
  pointer-events: none;
}

.home-start-button:hover {
  background: #353532;
  filter: none;
  transform: translate(-50%, -1px);
}

.home-start-button:active {
  background: #151514;
  transform: translate(-50%, 1px);
}

.home-start-button span {
  font: 900 clamp(22px, 3.8vw, 34px)/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .1em;
  text-indent: .1em;
}

.home-start-button small {
  color: rgba(255, 253, 247, .68);
  font: 800 9px/1 Inter, system-ui, sans-serif;
  letter-spacing: .08em;
}

.home-save-note {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 6.2%;
  left: 0;
  margin: 0;
  color: var(--ink-soft);
  text-align: center;
  font: 700 9px/1 Inter, system-ui, sans-serif;
  letter-spacing: .08em;
}

.home-settings {
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 4px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink-black);
  box-shadow: none;
  scrollbar-color: #777570 #e4e1d8;
}

.settings-heading {
  padding: 8px 4px 13px;
  border-bottom: 3px solid var(--ink-black);
}

.settings-heading .eyebrow { color: var(--ink-soft); }

.settings-heading h2 {
  margin: 6px 0 4px;
  color: var(--ink-black);
  font: 900 28px/1 "RTS WenKai", "LXGW WenKai", "KaiTi", serif;
  letter-spacing: .08em;
}

.settings-heading p {
  margin: 0;
  color: var(--paper-dim);
  font-size: 11px;
  line-height: 1.55;
}

.home-settings .setup-card {
  margin-top: 12px;
  padding: 14px 13px;
  overflow: visible;
  border: 0;
  border-bottom: 1px solid rgba(24, 24, 22, .18);
  border-left: 3px solid rgba(24, 24, 22, .76);
  border-radius: 0;
  background: rgba(255, 253, 247, .74);
  box-shadow: none;
}

.home-settings .setup-card::before,
.home-settings .setup-card::after { display: none; }

.home-settings .section-heading { gap: 10px; margin-bottom: 12px; }
.home-settings .section-heading > span {
  padding: 4px 7px;
  border: 1px solid var(--ink-black);
  border-radius: 0;
  background: var(--ink-black);
  color: var(--rice-paper-light);
}
.home-settings .section-heading h2 { color: var(--ink-black); font-size: 17px; }
.home-settings .section-heading p { color: var(--paper-dim); font-size: 11px; line-height: 1.4; }

.home-settings .ruleset-picker { grid-template-columns: 1fr; gap: 7px; }
.home-settings .ruleset-option {
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(24, 24, 22, .36);
  border-radius: 1px;
  background: rgba(255, 253, 247, .82);
  color: var(--ink-black);
  box-shadow: none;
}
.home-settings .ruleset-option strong { color: var(--ink-black); }
.home-settings .ruleset-option small { color: var(--paper-dim); font-size: 10px; }
.home-settings .ruleset-option:has(input:checked),
.home-settings .ruleset-option.territory:has(input:checked),
.home-settings .ruleset-option.cr:has(input:checked) {
  border-color: var(--ink-black);
  background: rgba(255, 253, 247, .96);
  box-shadow: inset 4px 0 0 var(--ally-blue);
}

.home-settings .hero-picker { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.home-settings .hero-option {
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 1px 6px;
  padding: 8px 6px;
  border: 1px solid rgba(24, 24, 22, .34);
  border-radius: 1px;
  background: rgba(255, 253, 247, .82);
  color: var(--ink-black);
  box-shadow: none;
}
.home-settings .hero-option:hover { border-color: var(--ink-black); transform: none; }
.home-settings .hero-option:has(input:checked) {
  border-color: var(--ink-black);
  background: rgba(255, 253, 247, .96);
  box-shadow: inset 3px 0 0 var(--ally-blue);
}
.home-settings .hero-option .seal,
.home-settings .hero-option.caocao .seal,
.home-settings .hero-option.sunquan .seal {
  width: 29px;
  height: 29px;
  border: 1px solid var(--ink-black);
  border-radius: 50%;
  background: rgba(255, 253, 247, .95);
  color: var(--ink-black);
  box-shadow: none;
  font-size: 17px;
}
.home-settings .hero-option:has(input:checked) .seal {
  background: linear-gradient(0deg, rgba(63, 127, 232, .34) 0 35%, rgba(255, 253, 247, .95) 35%);
}
.home-settings .hero-option strong { color: var(--ink-black); font-size: 12px; }
.home-settings .hero-option small { color: var(--paper-dim); font-size: 9px; }
.home-settings .hero-description { margin-top: 9px; color: var(--ink-soft); font-size: 10px; }

.home-settings .mode-grid { grid-template-columns: 1fr; gap: 8px; }
.home-settings .mode-card {
  padding: 12px;
  border: 1px solid rgba(24, 24, 22, .34);
  border-radius: 1px;
  background: rgba(255, 253, 247, .82);
  color: var(--ink-black);
  box-shadow: none;
}
.home-settings .mode-card.featured { border-color: var(--ink-black); }
.home-settings .mode-icon {
  float: left;
  display: grid;
  width: 30px;
  height: 30px;
  margin-right: 9px;
  place-items: center;
  border: 1px solid var(--ink-black);
  border-radius: 50%;
  background: rgba(255, 253, 247, .95);
  color: var(--ink-black);
  font-size: 16px;
}
.home-settings .mode-card h3 { margin: 4px 0 2px; color: var(--ink-black); font-size: 14px; }
.home-settings .mode-card p { min-height: 0; margin: 8px 0 9px; color: var(--paper-dim); font-size: 10px; }
.home-settings .mode-card label { margin-top: 6px; color: var(--ink-soft); font-size: 10px; }

.home-settings select,
.home-settings input {
  padding: 7px 8px;
  border: 1px solid rgba(24, 24, 22, .42);
  border-radius: 1px;
  background: rgba(255, 253, 247, .92);
  color: var(--ink-black);
  font-size: 10px;
}

.home-settings .secondary-button,
.home-settings .mode-card button {
  border: 1px solid rgba(24, 24, 22, .48);
  border-radius: 1px;
  background: rgba(255, 253, 247, .9);
  color: var(--ink-black);
  box-shadow: none;
}

.home-settings .join-row button {
  border-color: var(--ink-black);
  background: var(--ink-black);
  color: var(--rice-paper-light);
}

.home-settings .seed-field {
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 12px;
  padding-top: 11px;
  border-top-color: rgba(24, 24, 22, .18);
  color: var(--ink-soft);
}
.home-settings .seed-field small { color: var(--paper-dim); font-size: 9px; }

@media (max-width: 760px) {
  .menu-screen { padding: 10px; }
  .home-layout { grid-template-columns: minmax(0, 1fr); }
  .home-phone { justify-self: center; width: min(100%, calc((100vh - 20px) * 9 / 16), 540px); }
  .home-settings { width: min(100%, 540px); max-height: none; justify-self: center; }
}

@media (max-width: 430px) {
  .home-rank-card { width: 78%; grid-template-columns: 46px minmax(0, 1fr); padding: 11px 14px 10px; }
  .rank-seal { width: 44px; font-size: 24px; }
  .home-standard b { width: 72px; font-size: 38px; }
  .home-start-button { min-height: 56px; }
  .home-settings { padding-top: 2px; }
}

/* Mobile setup and battle guide use one unobtrusive help entry per screen. */
.mobile-help-button,
.mobile-panel-close,
.mobile-help-backdrop {
  display: none;
}

@media (max-width: 760px) {
  body.mobile-panel-active { overflow: hidden; }

  .mobile-help-button {
    position: absolute;
    z-index: 60;
    top: max(9px, env(safe-area-inset-top));
    left: max(9px, env(safe-area-inset-left));
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 2px solid rgba(24, 24, 22, .76);
    border-radius: 50%;
    background: rgba(255, 253, 247, .92);
    color: var(--ink-black);
    box-shadow: 0 4px 12px rgba(24, 24, 22, .2);
    font: 900 22px/1 Inter, system-ui, sans-serif;
  }

  .mobile-help-button:focus-visible,
  .mobile-panel-close:focus-visible {
    outline: 3px solid var(--ally-blue);
    outline-offset: 2px;
  }

  .home-settings:not(.mobile-panel-open),
  .playtest-console:not(.mobile-panel-open) {
    display: none;
  }

  .mobile-panel-backdrop:not([hidden]) {
    position: fixed;
    z-index: 90;
    inset: 0;
    display: block;
    background: rgba(12, 13, 11, .58);
    backdrop-filter: blur(3px);
  }

  .home-settings.mobile-panel-open,
  .playtest-console.mobile-panel-open {
    position: fixed;
    z-index: 91;
    inset: auto;
    top: 50%;
    left: 50%;
    width: min(calc(100vw - 24px), calc((100dvh - 24px) * 9 / 16), 540px);
    max-width: 540px;
    max-height: min(calc(100dvh - 24px), calc((100vw - 24px) * 16 / 9));
    overscroll-behavior: contain;
    border: 2px solid rgba(24, 24, 22, .76);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, .42);
    transform: translate(-50%, -50%);
  }

  .home-settings.mobile-panel-open {
    display: block;
    overflow-y: auto;
    padding: 10px 12px 14px;
    background: var(--rice-paper-light);
    scrollbar-gutter: stable;
  }

  .playtest-console.mobile-panel-open {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    align-content: stretch;
    gap: 7px;
    overflow: hidden;
    padding: 9px 10px 10px;
    background: #22251f;
  }

  .playtest-console.mobile-panel-open .console-heading,
  .playtest-console.mobile-panel-open .exit-actions {
    grid-column: auto;
  }

  .mobile-panel-close {
    position: absolute;
    z-index: 4;
    top: 8px;
    right: 8px;
    display: grid;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(24, 24, 22, .6);
    border-radius: 50%;
    background: rgba(255, 253, 247, .95);
    color: var(--ink-black);
    box-shadow: 0 4px 12px rgba(24, 24, 22, .2);
    font: 800 21px/1 Inter, system-ui, sans-serif;
  }

  .home-settings.mobile-panel-open .mobile-panel-close {
    position: sticky;
    top: 0;
    float: right;
    margin: 0 0 -32px auto;
  }

  .home-settings.mobile-panel-open .settings-heading {
    padding: 2px 40px 8px 2px;
    border-bottom-width: 2px;
  }

  .home-settings.mobile-panel-open .settings-heading .eyebrow,
  .home-settings.mobile-panel-open .settings-heading p {
    display: none;
  }

  .home-settings.mobile-panel-open .settings-heading h2 {
    margin: 0;
    font-size: 22px;
  }

  .home-settings.mobile-panel-open .setup-card {
    margin-top: 8px;
    padding: 10px;
  }

  .home-settings.mobile-panel-open .section-heading {
    margin-bottom: 8px;
  }

  .playtest-console.mobile-panel-open .console-heading {
    min-height: 33px;
    padding: 1px 40px 7px 2px;
    border-bottom: 1px solid rgba(255, 253, 247, .24);
  }

  .playtest-console.mobile-panel-open .console-heading .eyebrow,
  .playtest-console.mobile-panel-open .console-heading p {
    display: none;
  }

  .playtest-console.mobile-panel-open .console-heading h2 {
    margin: 0;
    color: var(--rice-paper-light);
    font-size: 22px;
    line-height: 1.2;
  }

  .playtest-console.mobile-panel-open .battle-guide {
    min-height: 0;
    gap: 4px;
    overflow-y: auto;
    padding: 7px 8px 8px;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .playtest-console.mobile-panel-open .battle-guide h3 {
    margin-bottom: 0;
    font-size: 13px;
  }

  .playtest-console.mobile-panel-open .counter-cycle {
    width: min(132px, 100%);
    height: 112px;
  }

  .playtest-console.mobile-panel-open .counter-node {
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .playtest-console.mobile-panel-open .counter-core {
    width: 58px;
    min-height: 42px;
  }

  .playtest-console.mobile-panel-open .counter-core strong {
    font-size: 15px;
  }

  .playtest-console.mobile-panel-open .counter-core small {
    margin-top: 2px;
    font-size: 8px;
  }

  .playtest-console.mobile-panel-open .counter-caption {
    margin-top: -1px;
    font-size: 9.5px;
  }

  .playtest-console.mobile-panel-open .battle-guide-rules {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(34px, auto));
    grid-auto-flow: column;
    gap: 4px;
  }

  .playtest-console.mobile-panel-open .battle-guide-rules article {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 4px;
    min-height: 34px;
    padding: 4px 5px;
  }

  .playtest-console.mobile-panel-open .battle-guide-rules strong {
    font-size: 11px;
  }

  .playtest-console.mobile-panel-open .battle-guide-rules span {
    font-size: 8px;
    line-height: 1.25;
  }

  .playtest-console.mobile-panel-open .battle-guide-rules .merge-rule span {
    white-space: normal;
  }

  .playtest-console.mobile-panel-open .recruit-timing {
    gap: 2px;
    padding: 6px 7px;
    border-width: 1px;
  }

  .playtest-console.mobile-panel-open .recruit-timing strong {
    font-size: 13px;
  }

  .playtest-console.mobile-panel-open .recruit-timing span {
    font-size: 9px;
    line-height: 1.3;
  }

  .playtest-console.mobile-panel-open .recruit-timing br {
    display: none;
  }

  .playtest-console.mobile-panel-open .battle-log-panel {
    display: none;
  }

  .playtest-console.mobile-panel-open .exit-actions {
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .playtest-console.mobile-panel-open .exit-actions button {
    min-height: 34px;
    padding: 6px 8px;
  }
}
