/* 三国群雄志 — styles */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: 'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  background: #1d150e; color: #e8dcc0;
  overflow: hidden; user-select: none; -webkit-user-select: none;
}
button {
  font-family: inherit; cursor: pointer; color: #e8dcc0;
  background: #3a2d1e; border: 1px solid #6b5634; border-radius: 6px;
  padding: 8px 14px; font-size: 14px; transition: all .15s;
}
button:hover { background: #4d3c27; border-color: #caa84e; }
button:disabled { opacity: .45; cursor: default; }
button:active:not(:disabled) { transform: scale(.96); }
button.primary { background: #6e1f1f; border-color: #b8563c; }
button.primary:hover { background: #8a2828; border-color: #e2a05c; }
button.big { font-size: 20px; padding: 14px 44px; letter-spacing: 6px; border-radius: 10px; }
.hidden { display: none !important; }
.muted { color: #8d8068; font-size: 13px; }
small { color: #b3a584; font-weight: normal; }

/* ── screens ── */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* title */
#screen-title { align-items: center; justify-content: center; text-align: center;
  background: radial-gradient(ellipse at 50% 30%, #3a2a18 0%, #1d150e 70%); overflow: hidden; }
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.title-inner { position: relative; animation: title-in 1.1s ease-out both; }
@keyframes title-in { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
.title-deco { font-size: 44px; opacity: .8; }
#screen-title h1 { font-size: clamp(52px, 12vw, 110px); font-weight: 900; letter-spacing: 10px;
  color: #e8dcc0; text-shadow: 0 4px 24px rgba(202,138,42,.35); }
#screen-title h1 span { color: #d9a441; }
.subtitle { letter-spacing: 8px; color: #8d8068; font-size: 12px; margin-top: 4px; }
.tagline { margin-top: 18px; color: #c4b491; font-size: 16px; letter-spacing: 3px; }
.title-btns { margin-top: 42px; display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.credits { position: absolute; bottom: 14px; left: 0; width: 100%; color: #6a5e49; font-size: 11px;
  text-align: center; pointer-events: none; }

/* faction select */
#screen-faction { align-items: center; justify-content: flex-start;
  padding: 6vh 0 60px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% 20%, #34261533 0%, transparent 60%), #1d150e; }
.fs-title { font-size: clamp(28px, 6vw, 48px); letter-spacing: 14px; margin-bottom: 30px; color: #d9a441; }
#faction-cards { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; padding: 0 16px; }
.fcard { width: 240px; border: 2px solid var(--fc); border-radius: 14px; padding: 26px 22px;
  background: linear-gradient(180deg, #2a2014, #221a10); cursor: pointer; text-align: center;
  transition: transform .15s, box-shadow .15s; }
.fcard:hover { transform: translateY(-6px); box-shadow: 0 12px 32px rgba(0,0,0,.5), 0 0 22px var(--fc); }
.fcard h2 { color: var(--fc); font-size: 30px; letter-spacing: 4px; }
.fcard .ruler { margin: 8px 0 12px; color: #c4b491; }
.fcard p { font-size: 14px; color: #a89875; line-height: 1.7; }
.fcard .diff { margin-top: 14px; font-size: 12px; color: #8d8068; }

/* ── game screen ── */
#topbar { display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: #251c11; border-bottom: 1px solid #4d3c27; font-size: 14px; z-index: 5; }
#top-faction { font-weight: 900; font-size: 17px; letter-spacing: 2px; }
#top-stats { color: #b3a584; }
.spacer { flex: 1; }

#map-wrap { flex: 1; position: relative; overflow: hidden;
  background:
    radial-gradient(ellipse at 70% 20%, #2e2316 0%, transparent 55%),
    radial-gradient(ellipse at 20% 80%, #2a2013 0%, transparent 55%), #221a10; }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.road { fill: none; stroke: #6b5634; stroke-width: 2.5; stroke-dasharray: 7 6; opacity: .55; }
.city { cursor: pointer; }
.city rect { stroke-width: 2; transition: filter .12s; }
.city:hover .plaque { stroke-width: 3.5; filter: brightness(1.3); }
.city.selected .plaque { stroke: #ffe28a !important; stroke-width: 3.5;
  filter: drop-shadow(0 0 8px rgba(255,226,138,.8)); }
.city.mine .plaque { filter: drop-shadow(0 0 5px rgba(255,220,140,.35)); }
.cname { fill: #f0e6cc; font-size: 16px; font-weight: 900; text-anchor: middle; pointer-events: none;
  letter-spacing: 1px; }
.ctroops { fill: #c9b98e; font-size: 11.5px; text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: rgba(20,14,8,.8); stroke-width: 3px; }
.cidle { fill: #1d150e; font-size: 10px; font-weight: 900; text-anchor: middle; pointer-events: none; }

/* legend */
#map-legend { position: absolute; bottom: 12px; right: 12px; display: flex; flex-direction: column;
  gap: 3px; background: rgba(26,19,11,.78); border: 1px solid #4d3c27; border-radius: 9px;
  padding: 7px 10px; font-size: 11.5px; color: #c4b491; z-index: 4; pointer-events: none; }
#map-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
#map-legend .me { color: #f0e6cc; font-weight: 900; }

/* tutorial — full-screen overlay traps all input until dismissed */
#tutorial { position: absolute; inset: 0; z-index: 9; background: rgba(12,8,4,.45);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 20px; }
.tut-card { width: 420px; max-width: calc(100vw - 30px); background: rgba(32,24,14,.97);
  border: 1px solid #caa84e; border-radius: 12px; padding: 16px 18px;
  box-shadow: 0 10px 32px rgba(0,0,0,.6); }
.tut-card b { color: #d9a441; letter-spacing: 3px; }
.tut-card p { font-size: 13.5px; line-height: 2; margin: 8px 0 12px; color: #d4c6a2; }
.tut-card small { color: #8d8068; }
.tut-card button { width: 100%; }

/* city panel */
#city-panel { position: absolute; top: 12px; left: 12px; width: 300px; max-width: calc(100vw - 24px);
  max-height: calc(100% - 24px); overflow-y: auto;
  background: rgba(32,24,14,.96); border: 1px solid #6b5634; border-radius: 12px; padding: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6); z-index: 6; }
.cp-head { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid; padding-bottom: 8px; }
.cp-head b { font-size: 20px; }
.cp-close { margin-left: auto; padding: 2px 9px; }
.cp-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; margin: 10px 0;
  font-size: 14px; color: #d4c6a2; }
.cp-gens { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.gen-chip { background: #34281a; border: 1px solid #5d4a2e; border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.gen-chip.acted { opacity: .45; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions button small { display: block; font-size: 10px; }
.actions .primary { grid-column: 1 / -1; }
.cp-msg { color: #e2a05c; font-size: 13px; min-height: 18px; margin-top: 8px; }

/* log */
#log-panel { height: 110px; overflow-y: auto; background: #1a130c; border-top: 1px solid #4d3c27;
  padding: 8px 14px; font-size: 13px; line-height: 1.8; color: #a89875; }
#log div:first-child { color: #e8dcc0; }

/* ── modal ── */
#modal { position: fixed; inset: 0; background: rgba(10,7,4,.75); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal-content { background: #2a2014; border: 1px solid #6b5634; border-radius: 14px;
  padding: 22px; width: 420px; max-width: 100%; max-height: 86vh; overflow-y: auto;
  box-shadow: 0 18px 48px rgba(0,0,0,.7); }
#modal-content h3 { color: #d9a441; letter-spacing: 2px; margin-bottom: 12px; }
.m-sec { margin: 12px 0; font-size: 14px; }
.m-sec > b { display: block; color: #c4b491; margin-bottom: 6px; }
.opt { display: block; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.opt:hover { background: #34281a; }
.opt:has(input:checked) { background: #3d2e1a; outline: 1px solid #8a6f3a; }
.opt input { accent-color: #d9a441; width: 15px; height: 15px; vertical-align: -2px; margin-right: 4px; }
input[type=range]::-webkit-slider-runnable-track { background: #3a2d1e; height: 5px; border-radius: 3px; }
input[type=range]::-moz-range-track { background: #3a2d1e; height: 5px; border-radius: 3px; }
input[type=range] { background: transparent; }
.m-btns { display: flex; gap: 10px; margin-top: 16px; }
.m-btns button { flex: 1; padding: 11px; font-size: 15px; }
.vs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 10px 0; }
.vs-grid b { display: block; margin-bottom: 6px; }
.vs-grid .gen-chip { display: block; margin-bottom: 5px; }
#mtroops { width: 100%; accent-color: #d9a441; }
.m-est { min-height: 20px; font-size: 13.5px; color: #d4c6a2; margin-top: 4px; }

/* battle report */
.rep-winner { font-size: 17px; font-weight: 900; margin: 6px 0 10px; letter-spacing: 1px; }
.rep-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rep-table th, .rep-table td { border: 1px solid #4d3c27; padding: 7px 9px; text-align: left; }
.rep-table th { color: #b3a584; background: #241b10; font-weight: normal; }

/* ── battle ── */
#battle-overlay { position: fixed; inset: 0; background: #15100a; z-index: 100;
  display: flex; align-items: center; justify-content: center; }
#battle-canvas { width: 100%; height: 100%; object-fit: contain; touch-action: none; }
#bhud { position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  padding: 10px 14px; pointer-events: none; }
.bhud-side { display: flex; flex-direction: column; gap: 6px; }
.bhud-gen { background: rgba(20,14,8,.8); border-left: 3px solid var(--fc); padding: 4px 8px;
  border-radius: 4px; min-width: 120px; }
.bhud-side.right .bhud-gen { border-left: none; border-right: 3px solid var(--fc); text-align: right; }
.bhud-gen.dead { opacity: .35; }
.bhud-gen .n { font-size: 13px; font-weight: 900; }
.bhud-gen .bar { height: 5px; background: #000; border-radius: 3px; margin-top: 3px; overflow: hidden; }
.bhud-gen .bar i { display: block; height: 100%; transition: width .2s; }
.bhud-gen .hp i { background: #6fd66f; }
.bhud-gen .mp i { background: #5ab0ff; }
.bhud-mid { text-align: center; color: #d4c6a2; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
#btimer-label { font-size: 10px; color: #8d8068; letter-spacing: 3px; }
#btimer { font-size: 26px; font-weight: 900; color: #f0e6cc; transition: color .3s; }
#btimer.low { color: #ff6b4d; animation: timer-pulse 1s infinite; }
@keyframes timer-pulse { 50% { opacity: .55; } }
#bcount-att, #bcount-def { font-weight: 900; text-shadow: 0 1px 3px #000; }
#battle-rotate { display: none; position: absolute; top: 13%; left: 50%; transform: translateX(-50%);
  background: rgba(26,19,11,.88); border: 1px solid #caa84e; border-radius: 50px;
  padding: 8px 20px; font-size: 13.5px; color: #f0e6cc; z-index: 5; pointer-events: none; }
@media (orientation: portrait) and (max-width: 700px) {
  #battle-rotate { display: block; }
}
#bcontrols { position: absolute; bottom: 14px; right: 14px; display: flex; gap: 10px; }
#bcontrols button { padding: 14px 18px; font-size: 16px; border-radius: 50px; background: rgba(46,34,20,.92); }
#btn-skill { font-weight: 900; font-size: 18px !important; padding: 18px 26px !important;
  border: 2px solid #6b5634 !important; --mp: 0%;
  background: linear-gradient(to top, rgba(90,176,255,.35) var(--mp), rgba(46,34,20,.92) var(--mp)) !important; }
#btn-skill.ready { background: #8a2828 !important; border-color: #ffd76a !important;
  box-shadow: 0 0 18px rgba(255,200,90,.65); animation: pulse 1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 30px rgba(255,200,90,.95); } }
#battle-banner { position: absolute; top: 40%; width: 100%; text-align: center;
  font-size: clamp(34px, 7vw, 64px); font-weight: 900; color: #ffd76a; letter-spacing: 12px;
  text-shadow: 0 4px 18px #000; opacity: 0; transition: opacity .3s; pointer-events: none; }
#battle-banner.show { opacity: 1; }
#battle-hint { position: absolute; bottom: 18px; left: 16px; color: #8d8068; font-size: 12px; pointer-events: none; }

/* difficulty select */
#diff-select { display: flex; gap: 10px; margin-bottom: 26px; }
#diff-select button { padding: 9px 26px; letter-spacing: 3px; font-size: 15px; border-radius: 50px; }
#diff-select button.on { background: #6e1f1f; border-color: #e2a05c; color: #ffe2b0;
  box-shadow: 0 0 14px rgba(226,160,92,.35); }

/* level badge */
.lv { font-style: normal; font-size: 10px; color: #1d150e; background: #d9a441;
  border-radius: 4px; padding: 0 4px; font-weight: 900; vertical-align: 1px; }

/* toasts */
#toast-wrap { position: fixed; top: 56px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 7px; z-index: 300; pointer-events: none; align-items: center; }
.toast { background: rgba(38,28,16,.95); border: 1px solid #caa84e; color: #f0e6cc;
  border-radius: 50px; padding: 8px 22px; font-size: 14px; letter-spacing: 1px;
  box-shadow: 0 6px 22px rgba(0,0,0,.55); animation: toast-in .25s ease-out; white-space: nowrap; }
.toast.out { opacity: 0; transition: opacity .45s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* march flash */
.march-flash { fill: none; stroke: #ffd76a; stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 16 14; animation: march-dash 1.3s linear; filter: drop-shadow(0 0 5px rgba(255,200,90,.8)); }
@keyframes march-dash { from { stroke-dashoffset: 220; opacity: .2; } 30% { opacity: 1; }
  to { stroke-dashoffset: 0; opacity: 0; } }

/* general bio card */
.gen-chip.clickable { cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.gen-chip.clickable:hover { border-color: #caa84e; }
.gen-chip img { width: 20px; height: 20px; border-radius: 50%; }
.bio-head { display: flex; gap: 14px; align-items: center; margin-bottom: 10px; }
.bio-pic { width: 72px; height: 72px; border-radius: 50%; border: 2px solid #6b5634; }
.bio-head h3 { margin: 0; }
.bio-fac { color: #b3a584; font-size: 13px; margin-top: 4px; }
.bio-text { font-size: 14px; line-height: 1.9; color: #d4c6a2; border-left: 3px solid #6b5634;
  padding-left: 10px; margin: 10px 0; }
.bio-stats { display: flex; gap: 18px; margin: 10px 0; color: #b3a584; font-size: 13.5px; }
.bio-stats b { color: #f0e6cc; font-size: 17px; margin-left: 3px; }
.bio-exp .bar { height: 6px; background: #1a130c; border-radius: 3px; overflow: hidden; margin-bottom: 3px; }
.bio-exp .bar i { display: block; height: 100%; background: linear-gradient(90deg, #8a6f3a, #d9a441); }
.bio-exp small { color: #8d8068; }
.bio-skill { margin-top: 12px; color: #e2a05c; font-size: 14.5px; line-height: 1.7; }
.bio-skill small { color: #a89875; }

/* chronicle */
.chronicle { max-height: 52vh; overflow-y: auto; font-size: 13.5px; line-height: 2; }
.chronicle h4 { color: #d9a441; letter-spacing: 4px; margin: 10px 0 4px; border-bottom: 1px solid #4d3c27;
  padding-bottom: 3px; }
.chr-line { color: #c4b491; }
.chr-line i { font-style: normal; color: #8d8068; font-size: 11.5px; margin-right: 6px; }

/* game over */
#go-banner { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; text-align: center;
  background: rgba(12,8,4,.92); }
#go-banner h1 { font-size: clamp(44px, 10vw, 90px); letter-spacing: 16px; }
.go-win h1 { color: #ffd76a; } .go-lose h1 { color: #b8563c; }
#go-banner p { color: #c4b491; } #go-banner button { font-size: 17px; padding: 12px 36px; }

/* ── mobile ── */
@media (max-width: 700px) {
  #topbar { flex-wrap: wrap; gap: 8px; font-size: 12px; padding: 6px 10px; }
  #top-faction { font-size: 15px; }
  #map-legend { flex-direction: row; flex-wrap: wrap; max-width: 72vw; gap: 2px 9px;
    font-size: 10.5px; bottom: 6px; right: 6px; padding: 5px 8px; }
  #city-panel { top: auto; bottom: 0; left: 0; width: 100%; max-width: 100%; border-radius: 14px 14px 0 0;
    max-height: 58vh; }
  #log-panel { height: 70px; font-size: 12px; }
  #bcontrols { bottom: 10px; right: 10px; gap: 7px; }
  #bcontrols button { padding: 11px 13px; font-size: 13px; }
  .bhud-gen { min-width: 86px; padding: 3px 6px; }
  .bhud-gen .n { font-size: 11px; }
  #battle-hint { display: none; }
}
