:root {
  color-scheme: dark;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --gold: #f2cb68; --ink: #07131b; --panel: rgba(6, 22, 27, .94); --line: rgba(202, 232, 211, .25);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #071510; }
button { font: inherit; color: inherit; }
.hidden { display: none !important; }
.app { position: relative; width: 100%; height: 100%; height: 100dvh; overflow: hidden; touch-action: none; background: #10251f; }
#game { position: absolute; left: 50%; top: 50%; display: block; width: auto; height: min(100vh, 56.25vw); height: min(100dvh, 56.25vw); transform: translate(-50%, -50%); cursor: crosshair; }

.screen { position: absolute; z-index: 20; inset: 0; display: grid; place-content: center; padding: clamp(16px, 4vw, 52px); background: radial-gradient(circle at 58% 34%, rgba(35, 84, 63, .95), rgba(3, 13, 13, .98) 66%); }
.start-screen { grid-template-columns: minmax(260px, 430px) minmax(500px, 720px); grid-template-rows: 1fr auto; gap: 18px 32px; }
.start-copy { align-self: center; }
.eyebrow { margin: 0 0 8px; color: var(--gold); font-size: 12px; letter-spacing: .16em; }
h1 { margin: 0; color: #fff0bd; font: 800 clamp(48px, 7vw, 92px)/.95 serif; text-shadow: 0 4px 24px #000; }
.start-copy > p:last-child { max-width: 29ch; color: #b8cdc2; line-height: 1.7; }
.hero-list { grid-row: span 2; display: grid; gap: 12px; align-content: center; }
.hero-card { position: relative; min-height: 130px; padding: 20px 18px 16px 92px; overflow: hidden; text-align: left; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(135deg, rgba(18, 52, 45, .97), rgba(7, 23, 27, .96)); box-shadow: inset 0 1px rgba(255,255,255,.06); }
.hero-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--hero); }
.hero-card.selected { outline: 3px solid var(--hero); transform: translateX(-4px); }
.hero-emblem { position: absolute; left: 22px; top: 25px; display: grid; place-items: center; width: 52px; height: 62px; border: 3px solid var(--hero); color: #fff3c9; background: #07191a; font: 900 23px serif; }
.hero-card:nth-child(1) .hero-emblem { clip-path: polygon(50% 0, 92% 22%, 82% 82%, 50% 100%, 18% 82%, 8% 22%); }
.hero-card:nth-child(2) .hero-emblem { border-radius: 50%; box-shadow: 0 0 0 6px color-mix(in srgb, var(--hero) 30%, transparent); }
.hero-card:nth-child(3) .hero-emblem { border-radius: 50% 8px 8px 50%; }
.hero-card strong, .hero-card span, .hero-card small { display: block; }
.hero-card strong { color: #fff1c6; font-size: 22px; }
.hero-card span { margin: 5px 0; color: var(--hero); }
.hero-card small { color: #9db5aa; line-height: 1.45; }
.primary { justify-self: start; min-height: 48px; padding: 0 30px; border: 0; border-radius: 12px; color: #102017; background: linear-gradient(#ffe79b, #dba83a); font-weight: 900; box-shadow: 0 7px 22px rgba(223, 172, 55, .25); }

.hud { position: absolute; z-index: 8; inset: max(7px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) auto max(10px, env(safe-area-inset-left)); display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; pointer-events: none; text-shadow: 0 2px 5px #000; }
.hero-status { width: min(270px, 34vw); }
.hero-status strong { color: #f4fff7; }
.hero-status span { margin-left: 8px; color: var(--gold); }
.bar { height: 10px; margin-top: 5px; overflow: hidden; border: 1px solid rgba(255,255,255,.4); border-radius: 9px; background: rgba(0,0,0,.65); }
.bar i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #31a958, #86e481); }
.battle-status { padding: 7px 18px; text-align: center; border: 1px solid var(--line); border-radius: 12px; background: rgba(4, 17, 19, .82); }
.battle-status strong, .battle-status span { display: block; }
.battle-status strong { color: #ffe9a8; }
.battle-status span { color: #c2d6cc; font-size: 12px; }
.economy { justify-self: end; text-align: right; pointer-events: auto; }
.economy strong { display: block; margin-bottom: 4px; color: var(--gold); }
.economy button { padding: 7px 12px; border: 1px solid #c49a3b; border-radius: 9px; background: rgba(55, 37, 8, .9); }
.announcement { position: absolute; z-index: 9; top: 14%; left: 50%; transform: translateX(-50%); padding: 8px 20px; border: 1px solid var(--gold); border-radius: 999px; color: #ffecb1; background: rgba(4, 16, 17, .9); pointer-events: none; }

.build-panel { position: absolute; z-index: 12; right: max(12px, env(safe-area-inset-right)); top: 92px; width: min(360px, 44vw); padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: 0 12px 30px rgba(0,0,0,.45); }
.build-panel header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: #ffe7a1; }
.build-panel header button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: #173028; }
.build-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; }
.build-actions button { min-height: 62px; padding: 8px; text-align: left; border: 1px solid var(--line); border-radius: 9px; background: #102d27; }
.build-actions strong, .build-actions span { display: block; }
.build-actions strong { color: #f8f1d2; }
.build-actions span { margin-top: 3px; color: #9fb8ad; font-size: 11px; }
.build-actions button:disabled { opacity: .4; }

.touch-controls { position: absolute; z-index: 7; inset: 0; pointer-events: none; }
.joystick { position: absolute; left: max(24px, env(safe-area-inset-left)); bottom: max(20px, env(safe-area-inset-bottom)); display: none; width: 126px; height: 126px; border: 2px solid rgba(192, 231, 214, .32); border-radius: 50%; background: rgba(5, 20, 20, .32); pointer-events: auto; }
.joystick i { position: absolute; left: 38px; top: 38px; width: 50px; height: 50px; border-radius: 50%; background: rgba(115, 210, 176, .65); box-shadow: 0 0 22px rgba(70, 215, 169, .28); transform: translate(var(--jx, 0px), var(--jy, 0px)); }
.skill-buttons { position: absolute; right: max(20px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: flex; align-items: end; gap: 10px; pointer-events: none; }
.skill-cancel { position: absolute; right: max(102px, calc(env(safe-area-inset-right) + 82px)); bottom: max(108px, calc(env(safe-area-inset-bottom) + 98px)); display: grid; place-items: center; width: 76px; height: 76px; border: 2px solid rgba(255,126,112,.7); border-radius: 50%; color: #ffd4ce; background: rgba(87,20,17,.78); opacity: 0; transform: scale(.72); pointer-events: none; text-align: center; font-weight: 900; line-height: 1.05; transition: opacity .12s, transform .12s; }
.skill-cancel.visible { opacity: .72; transform: scale(1); }
.skill-cancel.active { opacity: 1; border-color: #fff; background: rgba(176,35,29,.96); box-shadow: 0 0 24px rgba(255,67,54,.58); transform: scale(1.12); }
.hero-skill { position: relative; width: 64px; height: 64px; border: 2px solid rgba(216, 239, 224, .45); border-radius: 50%; background: rgba(7, 31, 28, .86); box-shadow: inset 0 0 18px rgba(83, 201, 158, .2); pointer-events: auto; touch-action: none; font-size: 18px; font-weight: 900; }
.hero-skill.ultimate { width: 78px; height: 78px; border-color: #efbd58; background: rgba(73, 47, 8, .88); }
.hero-skill span { position: absolute; inset: auto 0 5px; color: #b8ccc2; font-size: 9px; font-weight: 500; }
.hero-skill.cooling { filter: grayscale(.65) brightness(.62); }
.hero-skill.aiming { outline: 3px solid #ffe188; }
.hero-skill.cancelling { outline-color: #ff6f61; filter: saturate(.6); }

.result-screen { text-align: center; }
.result-screen h2 { margin: 0 0 18px; color: #ffe597; font: 800 clamp(52px, 9vw, 100px) serif; }
.result-stats { display: grid; grid-template-columns: repeat(3, minmax(100px, 1fr)); gap: 8px; margin-bottom: 18px; }
.result-stats div { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(9, 29, 26, .85); }
.result-stats strong, .result-stats span { display: block; }
.result-stats span { color: #9fb7ac; font-size: 11px; }
.rotate-hint { display: none; }
button:focus-visible { outline: 3px solid #fff0a0; outline-offset: 2px; }

@media (pointer: coarse) {
  .joystick { display: block; }
}

@media (orientation: portrait) and (max-width: 800px) {
  .rotate-hint { position: absolute; z-index: 99; inset: 0; display: grid; place-content: center; color: #ffeab4; background: #071713; font-size: 23px; }
}
@media (max-height: 520px) {
  .start-screen { grid-template-columns: 220px minmax(0, 1fr); gap: 8px 14px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .start-copy > p:last-child { display: none; }
  h1 { font-size: clamp(38px, 7vw, 58px); }
  .hero-list { gap: 6px; }
  .hero-card { min-height: 72px; padding: 9px 8px 8px 62px; border-radius: 10px; }
  .hero-emblem { left: 12px; top: 10px; width: 38px; height: 48px; font-size: 16px; }
  .hero-card strong { font-size: 16px; }
  .hero-card span { margin: 2px 0; font-size: 11px; }
  .hero-card small { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .primary { min-height: 38px; padding: 0 18px; }
  .joystick { width: 94px; height: 94px; left: max(14px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); }
  .joystick i { left: 29px; top: 29px; width: 36px; height: 36px; }
  .hero-skill { width: 50px; height: 50px; }
  .hero-skill.ultimate { width: 60px; height: 60px; }
  .skill-buttons { right: max(10px, env(safe-area-inset-right)); bottom: max(8px, env(safe-area-inset-bottom)); gap: 6px; }
  .skill-cancel { right: max(82px, calc(env(safe-area-inset-right) + 70px)); bottom: max(76px, calc(env(safe-area-inset-bottom) + 68px)); width: 62px; height: 62px; font-size: 12px; }
  .hud { inset: max(4px, env(safe-area-inset-top)) max(7px, env(safe-area-inset-right)) auto max(7px, env(safe-area-inset-left)); font-size: 11px; }
  .battle-status { padding: 4px 10px; }
  .economy button { padding: 5px 8px; }
  .build-panel { top: 55px; width: min(350px, 52vw); max-height: calc(100dvh - 62px); overflow: auto; padding: 8px; }
  .build-actions button { min-height: 48px; padding: 6px; font-size: 11px; }
}
@media (max-width: 700px) and (orientation: landscape) {
  .start-screen { grid-template-columns: 160px minmax(0, 1fr); }
  .eyebrow { font-size: 9px; white-space: nowrap; }
  h1 { font-size: 36px; }
  .hero-card small { display: none; }
  .hero-card { min-height: 62px; }
  .hero-list { align-content: center; }
  .hero-status { width: 33vw; }
  .announcement { top: 18%; font-size: 11px; }
  .build-panel { left: max(112px, calc(env(safe-area-inset-left) + 102px)); right: max(188px, calc(env(safe-area-inset-right) + 178px)); top: auto; bottom: max(6px, env(safe-area-inset-bottom)); width: auto; max-height: none; overflow: visible; padding: 5px; border-radius: 10px; }
  .build-panel header { margin-bottom: 3px; font-size: 11px; }
  .build-panel header button { width: 24px; height: 24px; }
  .build-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .build-actions button { min-height: 42px; padding: 4px; text-align: center; }
  .build-actions span { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
