:root { color-scheme: dark; --ink:#111819; --gold:#c7ad70; --paper:#eee3c8; --red:#a83c32; --muted:#b5b09e; font-family:"STKaiti","KaiTi","Kaiti SC","SimSun","Songti SC",sans-serif; }
* { box-sizing:border-box; }
html,body,#app { width:100%; height:100%; margin:0; overflow:hidden; }
body { background:var(--ink); color:var(--paper); overscroll-behavior:none; }
button,select { font:inherit; font-size:16px; color:var(--paper); background:#29302c; border:1px solid #746548; border-radius:3px; min-height:44px; padding:9px 14px; touch-action:manipulation; cursor:pointer; }
button:hover:not(:disabled) { background:#404334; border-color:var(--gold); }
button:disabled { opacity:.45; cursor:default; }
button:focus-visible,select:focus-visible,canvas:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
button.primary { background:var(--red); border-color:#c57758; }
button.active,button[aria-pressed="true"] { border-color:var(--gold); box-shadow:inset 0 0 0 1px var(--gold); background:#44402d; }
h1,h2,h3,p { margin:0; }
h2 { font-size:22px; font-weight:normal; color:var(--gold); letter-spacing:3px; }
h3 { font-size:17px; color:var(--gold); font-weight:normal; }
p { line-height:1.65; }
small,.muted { font-size:13px; color:var(--muted); }
[hidden] { display:none !important; }
.screen { height:100%; height:100dvh; position:relative; }
.intro { isolation:isolate; }
.intro canvas { position:absolute; inset:0; width:100%; height:100%; z-index:-1; }
.intro-content { position:absolute; inset:0; text-align:center; }
.intro-content>header,.intro-content>.story,.intro-actions { position:absolute; }
#intro-title { display:flex; flex-direction:column; align-items:center; justify-content:center; }
.eyebrow { font-size:13px; letter-spacing:4px; color:var(--gold); }
.intro h1 { font-weight:normal; line-height:1.1; letter-spacing:.16em; padding-left:.16em; color:#e5c988; text-shadow:0 3px 20px #000; margin:4px 0 0; }
.intro .eyebrow { letter-spacing:.14em; line-height:1.3; white-space:nowrap; text-shadow:0 2px 6px #000; }
/* 字幕式序言：只显示最新两句，居中放在插画下方留白区。 */
.story { display:flex; flex-direction:column; justify-content:center; align-items:center; text-shadow:0 2px 4px #000,0 0 12px #000; color:#fff5df; overflow:hidden;
  background:radial-gradient(ellipse at center,#030914cc 0%,#03091488 55%,transparent 75%); }
.story-column { display:contents; }
.story p { line-height:1.3; margin:.15em 0; letter-spacing:.06em; display:none; }
.story p.visible { display:block; animation:story-in .7s ease-out; }
@keyframes story-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:none; } }
.intro-actions { display:flex; justify-content:center; align-items:stretch; }
.intro-actions button { min-width:128px; max-width:100%; padding:4px 16px; font-size:20px; letter-spacing:8px; }
.setup { display:grid; place-items:center; padding:20px; background:radial-gradient(ellipse at top,#384039,#111819 70%); }
.setup-card { width:min(580px,100%); max-height:100%; overflow:auto; border:1px solid #6b5d43; padding:clamp(18px,4vw,36px); background:#18201eee; box-shadow:0 20px 80px #0008; }
.setup-card h2 { margin-bottom:24px; }
fieldset { margin:18px 0; border:0; padding:0; }
legend { margin-bottom:10px; color:var(--gold); }
.choices { display:flex; gap:8px; flex-wrap:wrap; }
.choices button { flex:1; }
.setup-note { margin:12px 0 20px; color:var(--muted); font-size:14px; }
.game { display:grid; grid-template-rows:auto minmax(0,1fr) auto; padding-top:env(safe-area-inset-top); }
.hud { padding:8px max(10px,env(safe-area-inset-left)); border-bottom:1px solid #615339; background:#1c2421; }
.hud-top { display:flex; gap:10px; align-items:center; justify-content:space-between; }
.brand { color:var(--gold); letter-spacing:3px; white-space:nowrap; font-size:20px; }
.stats { display:flex; gap:8px 20px; flex-wrap:wrap; margin:6px 0; font-variant-numeric:tabular-nums; font-size:15px; }
.stat strong { color:var(--gold); font-weight:normal; }
.ticker { overflow:hidden; white-space:nowrap; color:#d9bda0; font-size:13px; height:24px; line-height:24px; }
.ticker span { display:inline-block; padding-left:100%; animation:dispatch 25s linear infinite; }
@keyframes dispatch { to { transform:translateX(-100%); } }
.battle { display:grid; grid-template-columns:minmax(0,1fr); min-height:0; position:relative; }
.map-host { min-width:0; min-height:0; position:relative; overflow:hidden; touch-action:none; }
.map-host canvas { display:block; width:100%; height:100%; touch-action:none; }
.pause-label { position:absolute; top:8px; left:50%; transform:translateX(-50%); background:#0c1214e8; color:var(--gold); padding:8px 20px; border:1px solid #756341; pointer-events:none; white-space:nowrap; }
.left-panel,.right-panel { display:none; min-height:0; overflow:auto; background:#18201e; padding:18px; }
.left-panel p { margin:10px 0; }
.element-list { display:flex; gap:6px; flex-wrap:wrap; margin:14px 0; }
.element-badge { padding:5px 8px; border:1px solid #655b47; background:#242e29; }
.right-panel h3 { margin:18px 0 8px; }
.troops p,.log p { font-size:14px; border-bottom:1px solid #353c32; padding:8px 0; }
.log { max-height:45vh; overflow:auto; }
.toolbar { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:6px max(10px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)); border-top:1px solid #615339; background:#1c2421; }
.toolbar .hint { font-size:12px; color:var(--muted); flex:1; }
.toast { position:absolute; left:50%; bottom:72px; transform:translateX(-50%); z-index:8; background:#4b2824f5; border:1px solid #bd775a; padding:10px 16px; text-align:center; width:max-content; max-width:90%; pointer-events:none; }
.build-panel { position:absolute; z-index:4; bottom:0; left:0; right:0; max-height:55%; overflow:auto; padding:12px 14px max(12px,env(safe-area-inset-bottom)); background:#19211ff8; border-top:2px solid var(--gold); box-shadow:0 -10px 35px #0009; }
.panel-heading { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:10px; }
.tower-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; margin:8px 0; }
.tower-choice { text-align:left; font-size:14px; padding:8px; }
.tower-choice span { display:block; font-size:12px; color:var(--muted); margin-top:4px; }
.tower-detail { font-size:14px; line-height:1.65; }
.tower-detail p { margin:8px 0; }
.actions { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
dialog { width:min(540px,calc(100% - 24px)); max-height:calc(100dvh - 24px); overflow:auto; background:#1b2421; color:var(--paper); border:1px solid var(--gold); border-radius:4px; padding:24px; box-shadow:0 18px 80px #000a; }
dialog::backdrop { background:#020707bb; }
dialog p { margin:14px 0; }
.pick-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
.pick-list button { text-align:left; min-height:72px; }
.pick-list small { display:block; margin-top:5px; }
.report-stats { font-size:20px; line-height:2; color:var(--gold); }
@media (min-width:960px) and (min-height:500px) {
  .game { grid-template-rows:auto minmax(0,1fr) auto; }
  .battle { --left-width:clamp(180px,18vw,230px); grid-template-columns:var(--left-width) minmax(0,1fr) clamp(200px,20vw,250px); }
  .left-panel,.right-panel { display:block; }
  .left-panel { border-right:1px solid #615339; }
  .right-panel { border-left:1px solid #615339; }
  .left-panel,.right-panel { padding:12px; }
  .hud { padding:6px 16px; }
  .hud-top button { min-height:40px; padding:5px 12px; }
  .stats { gap:24px; margin:4px 0; }
  .ticker { height:20px; line-height:20px; }
  .build-panel { left:0; right:auto; top:0; bottom:0; width:var(--left-width); max-height:100%; border-top:0; border-right:1px solid var(--gold); box-shadow:none; }
  .tower-list { grid-template-columns:1fr; }
  .toolbar .mobile-hint { display:none; }
}
@media (max-width:959px), (max-height:499px) {
  .desktop-hint { display:none; }
  .hud-top button { min-height:40px; padding:5px 10px; }
  .brand { font-size:17px; }
  .stats { font-size:13px; gap:4px 12px; }
  .mobile-troops { font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--muted); }
  .build-panel { max-height:38%; padding:6px 10px max(6px,env(safe-area-inset-bottom)); }
  .panel-heading { margin-bottom:0; }
  .panel-heading h2 { font-size:18px; }
  .panel-heading button { padding:4px 10px; }
  .tower-list { margin:4px 0; max-height:94px; overflow:auto; }
  .tower-choice { padding:4px 6px; min-height:44px; }
  .tower-choice span { display:none; }
  .tower-detail { display:flex; gap:8px; font-size:12px; }
  .tower-detail p { flex:1; min-width:0; }
  .tower-detail p { margin:2px 0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .build-panel .actions { margin-top:4px; }
  .build-panel .actions button { min-height:44px; padding:5px 10px; font-size:14px; }
}
@media (min-width:960px) and (min-height:500px) { .mobile-troops { display:none; } }
/* 手机短横屏把军情移到右侧，让竖长地图仍能使用全部屏高。 */
@media (orientation:landscape) and (max-height:499px) and (min-width:560px) {
  .game { grid-template-columns:minmax(0,1fr) 260px; grid-template-rows:minmax(0,1fr) auto; }
  .battle { grid-column:1; grid-row:1 / -1; }
  .hud { grid-column:2; grid-row:1; min-height:0; overflow:auto; border-left:1px solid #615339; border-bottom:0; }
  .hud-top { flex-wrap:wrap; }
  .stats { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:14px 0; }
  .mobile-troops { white-space:normal; line-height:1.6; }
  .toolbar { grid-column:2; grid-row:2; flex-wrap:wrap; }
  .toolbar .hint { flex-basis:100%; }
  .build-panel { max-height:85%; }
}
@media (prefers-reduced-motion:reduce) { .story p.visible { animation:none; } .ticker span { animation:none; padding-left:0; } }

/* 联机与设置共用触屏尺寸；排行榜保留横向滚动，昵称始终自动换行。 */
input { font:inherit; color:var(--paper); background:#111a18; border:1px solid #746548; border-radius:3px; min-width:0; min-height:44px; padding:8px; }
input:focus-visible,summary:focus-visible { outline:2px solid var(--gold); outline-offset:2px; }
.field { display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin:12px 0; }
.field input { flex:1; width:100%; }
.field input[type="range"] { min-width:160px; padding:0; accent-color:var(--gold); }
.error { color:#ffc09f; min-height:1.5em; font-size:14px; }
.audio-settings { margin-top:18px; border-top:1px solid #615339; padding-top:8px; }
summary { cursor:pointer; min-height:44px; padding:10px 4px; color:var(--gold); }
.mute-control { display:flex; align-items:center; gap:12px; min-height:48px; }
.mute-control input { width:24px; height:24px; min-height:24px; accent-color:var(--gold); }
.network-status { color:#e5c988; font-size:13px; line-height:1.5; overflow-wrap:anywhere; }
.network-intel { color:#ffc09f; font-size:13px; line-height:1.5; overflow-wrap:anywhere; }
.board-list { display:grid; gap:8px; margin:12px 0; }
.board-row { display:grid; gap:5px; border:1px solid #514e3b; padding:8px; overflow-wrap:anywhere; }
.board-row.self { border-color:var(--gold); }
.board-row small { line-height:1.6; }
.board-row button { justify-self:start; min-height:44px; padding:5px 9px; font-size:14px; }
progress { width:100%; height:8px; accent-color:#85b183; }
.board-tabs { margin:14px 0; }
.table-scroll { max-width:100%; overflow:auto; margin:14px 0; }
table { width:100%; border-collapse:collapse; font-variant-numeric:tabular-nums; }
th,td { padding:10px 6px; text-align:left; border-bottom:1px solid #514e3b; white-space:nowrap; }
td:nth-child(2) { white-space:normal; overflow-wrap:anywhere; min-width:70px; }
.online-panel { background:#18201e; min-height:0; overflow:auto; padding:0 12px; border-bottom:1px solid #615339; }
.online-panel h3 { margin:12px 0 8px; }
.send-list { display:grid; gap:6px; margin:10px 0; }
.send-list button { text-align:left; }
.send-list small { display:block; margin-top:5px; line-height:1.5; }
.online-game .right-panel { display:none; }
@media (min-width:960px) and (min-height:500px) {
  .online-panel { grid-column:3; grid-row:1; border-left:1px solid #615339; border-bottom:0; }
  .online-panel>summary { display:none; }
  .online-game .map-host { grid-column:2; grid-row:1; }
}
@media (max-width:959px), (max-height:499px) {
  .online-game .battle { grid-template-rows:auto minmax(0,1fr); }
  .online-panel { grid-row:1; max-height:38dvh; }
  .online-game .map-host { grid-row:2; }
  .online-panel[open] { border-bottom:2px solid var(--gold); }
}
