:root {
  --bg: #0a0f0c;
  --panel: #182019;
  --panel-2: #232d24;
  --line: #5f6e60;
  --text: #eef1df;
  --muted: #a7ad99;
  --green: #8ea660;
  --red: #bd3d35;
  --amber: #d3a640;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #050806; color: var(--text); font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
button, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.mobile-only { display: none; }
#app { width: 100%; height: 100%; }
.screen { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.start-screen { background: radial-gradient(circle at 50% 20%, #394236 0, #151c17 35%, #070a08 72%); }
.start-screen::before { content: ""; position: absolute; inset: 0; opacity: .2; background-image: linear-gradient(30deg, transparent 48%, rgba(255,255,255,.05) 49%, transparent 51%), linear-gradient(-30deg, transparent 48%, rgba(255,255,255,.04) 49%, transparent 51%); background-size: 80px 80px; }
.scanlines { pointer-events: none; position: absolute; inset: 0; opacity: .2; background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(0,0,0,.4) 4px); }
.start-card, .modal { position: relative; width: min(560px, 96vw); background: linear-gradient(180deg, rgba(40,50,41,.97), rgba(17,23,18,.98)); border: 2px solid #6e7868; outline: 1px solid #161b16; box-shadow: var(--shadow), inset 0 0 0 4px rgba(255,255,255,.025); padding: 28px; text-align: center; }
.modal.wide { width: min(900px, 96vw); max-height: 88vh; overflow: auto; }
.emblem, .result-icon { width: 74px; height: 74px; margin: -58px auto 16px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(#c54b40, #70231f); border: 4px solid #282b23; box-shadow: 0 0 0 2px #a8a58a, 0 10px 20px rgba(0,0,0,.4); font-size: 38px; }
.eyebrow { margin: 4px 0; color: var(--amber); letter-spacing: .25em; font-size: 12px; }
h1 { margin: 8px 0 10px; font-size: clamp(30px, 5vw, 52px); line-height: 1; text-shadow: 0 3px #000; }
h2 { margin: 0 0 14px; font-size: 30px; }
h3 { margin: 0 0 8px; color: #d7d6b3; }
.subtitle { color: var(--muted); line-height: 1.7; }
.faction-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; }
.faction-card { min-height: 118px; padding: 14px; border: 1px solid #657063; background: #1a211b; cursor: pointer; transition: .16s; }
.faction-card:hover, .faction-card.selected { border-color: #d3bb70; background: #2b342b; box-shadow: inset 0 0 0 2px rgba(211,187,112,.14); transform: translateY(-1px); }
.faction-card strong, .faction-card small { display: block; }
.faction-card strong { font-size: 18px; margin: 5px 0; }
.faction-card small { color: var(--muted); line-height: 1.5; }
.faction-icon { font-size: 28px; color: #d2ba69; }
.field-label { display: block; margin: 6px 0 8px; text-align: left; color: var(--muted); }
select { width: 100%; background: #101510; color: white; border: 1px solid #687267; padding: 11px 12px; }
.primary-btn, .secondary-btn { width: 100%; border: 1px solid #7f8b79; padding: 12px 16px; margin-top: 12px; cursor: pointer; font-weight: 700; letter-spacing: .08em; }
.primary-btn { background: linear-gradient(#9b3230, #6f201f); border-color: #ce665c; }
.primary-btn:hover { filter: brightness(1.16); }
.secondary-btn { background: linear-gradient(#39443a, #202820); }
.secondary-btn:hover { background: #465247; }
.danger { color: #ffc6c1; }
.legal-note { margin: 14px 0 0; color: #777f72; font-size: 11px; }
.overlay { background: rgba(2,4,2,.78); backdrop-filter: blur(4px); z-index: 100; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.manual-grid article { background: rgba(0,0,0,.2); border: 1px solid #515b51; padding: 15px; }
.manual-grid p { margin: 6px 0; color: #c5c9ba; line-height: 1.6; }
.button-stack { display: grid; gap: 2px; }
.result-modal .result-icon { margin-top: -66px; }
.result-stats { margin-top: 18px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-stats div { padding: 12px; background: #111611; border: 1px solid #4d584e; }
.result-stats b { display: block; font-size: 22px; color: #e5ca78; }

.game-shell { width: 100%; height: 100%; display: grid; grid-template-columns: 1fr 250px; grid-template-rows: 48px 1fr; background: #050806; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; background: linear-gradient(#252f26, #141a15); border-bottom: 2px solid #626e62; box-shadow: 0 3px 10px #000; z-index: 20; }
.brand { width: 250px; height: 100%; display: flex; align-items: center; gap: 10px; padding: 0 14px; background: rgba(0,0,0,.22); font-weight: 800; letter-spacing: .08em; }
.brand-mark { color: #df4c41; font-size: 22px; }
.resource-strip { display: flex; align-items: center; gap: 24px; padding: 0 18px; flex: 1; }
.resource { display: flex; gap: 8px; align-items: center; min-width: 108px; font-variant-numeric: tabular-nums; }
.resource .icon { color: #e0c66a; }
.top-actions { display: flex; gap: 4px; padding-right: 8px; }
.icon-btn { width: 38px; height: 34px; background: #1e271f; border: 1px solid #58645a; cursor: pointer; }
.icon-btn:hover { background: #344035; }
.viewport { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #263026; touch-action: none; }
#game-canvas { width: 100%; height: 100%; display: block; cursor: default; image-rendering: pixelated; }
.sidebar { min-height: 0; background: linear-gradient(90deg, #121813, #202820); border-left: 2px solid #616d62; display: flex; flex-direction: column; z-index: 22; box-shadow: -4px 0 14px #000; }
.radar-panel { position: relative; flex: 0 0 154px; padding: 7px; background: #0c110d; border-bottom: 2px solid #5e6a5f; }
#minimap { width: 100%; height: 100%; display: block; background: #070a07; border: 1px solid #384039; cursor: crosshair; }
.radar-offline { position: absolute; inset: 7px; display: grid; place-items: center; background: repeating-linear-gradient(45deg, rgba(0,0,0,.72) 0 6px, rgba(30,36,30,.82) 6px 12px); color: #aa594f; letter-spacing: .16em; font-weight: 800; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid #5b665c; }
.tab { padding: 10px 4px; background: #1a221b; border: 0; border-right: 1px solid #455047; cursor: pointer; color: #b9c0ae; }
.tab.active { background: #364136; color: white; box-shadow: inset 0 -3px #c1483e; }
.build-list { flex: 1; overflow-y: auto; padding: 8px; display: grid; grid-template-columns: 1fr 1fr; align-content: start; gap: 7px; }
.build-item { position: relative; min-height: 86px; padding: 7px; text-align: left; background: linear-gradient(#2b352c, #151c16); border: 1px solid #5c695e; cursor: pointer; overflow: hidden; }
.build-item:hover:not(:disabled) { border-color: #d0b461; filter: brightness(1.12); }
.build-item:disabled { opacity: .38; cursor: not-allowed; }
.build-item .unit-symbol { display: grid; place-items: center; height: 38px; color: #d7c57f; font-size: 26px; }
.build-item strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.build-item small { display: block; color: #d9b95d; font-size: 11px; margin-top: 2px; }
.build-item .req { color: #d27268; }
.build-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #1b1b1b; }
.build-progress span { display: block; height: 100%; background: #a94b3f; }
.queue-panel { flex: 0 0 92px; background: #111711; border-top: 2px solid #5f6a60; padding: 7px 9px; }
.queue-title { font-size: 12px; font-weight: 800; color: #d2c79c; margin-bottom: 5px; }
.queue-list { font-size: 11px; max-height: 54px; overflow: auto; }
.queue-row { display: flex; justify-content: space-between; gap: 6px; padding: 3px 0; border-bottom: 1px dotted #3d473f; }
.muted { color: #798275; }
.selection-info { position: absolute; left: 10px; bottom: 10px; min-width: 210px; max-width: min(360px, 70%); padding: 9px 12px; background: rgba(12,17,13,.9); border: 1px solid #707c70; box-shadow: var(--shadow); font-size: 13px; pointer-events: none; }
.selection-info .hp { height: 5px; background: #272d27; margin-top: 6px; }
.selection-info .hp span { display: block; height: 100%; background: #6da15b; }
.toast { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); padding: 9px 14px; background: rgba(15,18,15,.94); border: 1px solid #d2b45e; color: #f1e1a7; z-index: 30; box-shadow: var(--shadow); }
.order-hint { position: absolute; right: 10px; bottom: 10px; padding: 6px 9px; background: rgba(0,0,0,.55); color: #c9cfbf; font-size: 11px; pointer-events: none; }
.mobile-orders { position: absolute; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-50%); gap: 5px; z-index: 21; }
.mobile-orders button { padding: 10px 14px; border: 1px solid #7b867b; background: rgba(23,31,24,.92); }
.mobile-orders button.active { background: #8d312c; border-color: #d66d64; }

@media (max-width: 900px) {
  .mobile-only { display: inline-flex; align-items: center; justify-content: center; }
  .game-shell { grid-template-columns: 1fr; grid-template-rows: 44px 1fr; }
  .brand { width: auto; min-width: 120px; font-size: 13px; }
  .resource-strip { gap: 9px; padding: 0 8px; }
  .resource { min-width: 72px; font-size: 12px; gap: 4px; }
  .sidebar { position: absolute; top: 44px; right: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(102%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .order-hint { display: none; }
  .mobile-orders { display: flex; }
  .selection-info { bottom: 58px; }
  .manual-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .screen { padding: 12px; }
  .start-card, .modal { padding: 20px 16px; }
  .faction-grid { grid-template-columns: 1fr; }
  .faction-card { min-height: 88px; }
  .brand span:last-child { display: none; }
  .brand { min-width: 44px; padding: 0 12px; }
  .resource-strip { justify-content: space-around; }
  .resource { min-width: auto; }
  .resource:nth-child(3) { display: none; }
  .result-stats { grid-template-columns: 1fr; }
}
