html, body { margin: 0; height: 100%; background: #0d0b16; overflow: hidden; -webkit-tap-highlight-color: transparent; }
:root {
  --gold: #e8c77a; --gold-hi: #fff1c4; --gold-dk: #8a6a2e; --ink: rgba(16, 13, 26, 0.86); --ink2: rgba(28, 22, 40, 0.8);
  --parch: #f3e6c4; --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", "Songti TC", "PMingLiU", "Noto Serif TC", "Noto Serif CJK TC", serif;
}
body { font-family: var(--serif) !important; color: var(--parch); }
html[lang="zh-CN"] body { font-family: "Palatino Linotype", Georgia, "Songti SC", "SimSun", "Noto Serif SC", "Noto Serif CJK SC", serif !important; }
html[lang="ja"] body { font-family: "Palatino Linotype", Georgia, "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", serif !important; }
button, .btn { font-family: inherit !important; }
#game, #overlay { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { pointer-events: none; z-index: 2; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; z-index: 20; }

/* ---------- title ---------- */
#title { overflow: hidden; background: #1c3550 url(../assets/cover-bg.png) center / cover no-repeat; cursor: pointer; }
#title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; animation: kenburns 24s ease-in-out infinite alternate; }
#title-shade { position: absolute; inset: 0; background: linear-gradient(to bottom, rgba(14, 10, 30, 0.42), rgba(0, 0, 0, 0) 32%, rgba(0, 0, 0, 0) 58%, rgba(12, 8, 22, 0.82)); }
#title-shade::after { content: ""; position: absolute; inset: 10px; border: 1px solid rgba(232, 199, 122, 0.45); box-shadow: inset 0 0 0 5px rgba(232, 199, 122, 0.12); pointer-events: none; }
#logo { position: absolute; left: 50%; top: 5%; width: 82%; max-height: 30%; object-fit: contain; transform: translateX(-50%); filter: drop-shadow(0 6px 14px rgba(10, 6, 20, 0.6)); opacity: 0; }
#logo.in { animation: logoIn 0.7s cubic-bezier(0.2, 1.5, 0.4, 1) both, logoFloat 4s ease-in-out 0.7s infinite; }
#prompt { position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%); white-space: nowrap; text-align: center; font-weight: 700; font-size: 21px; letter-spacing: 0.12em; color: var(--gold-hi); padding: 6px 34px; text-shadow: 0 2px 6px #000, 0 0 14px rgba(232, 199, 122, 0.75); animation: pulse 1.8s ease-in-out infinite;
  background: linear-gradient(90deg, rgba(16, 12, 28, 0), rgba(16, 12, 28, 0.62) 22%, rgba(16, 12, 28, 0.62) 78%, rgba(16, 12, 28, 0)); }
#prompt::before, #prompt::after { content: ""; position: absolute; left: 8%; right: 8%; height: 1px; background: linear-gradient(90deg, transparent, var(--gold), transparent); }
#prompt::before { top: 0; } #prompt::after { bottom: 0; }
#title-keys { position: absolute; left: 6%; right: 6%; bottom: 6%; text-align: center; color: #eadfc0; font-size: 14px; line-height: 1.5; text-shadow: 0 1px 3px #000; opacity: 0.9; letter-spacing: 0.03em; }
#sparks { position: absolute; inset: 0; pointer-events: none; }
.spark { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: radial-gradient(circle, #fff, rgba(255, 220, 140, 0.85) 40%, rgba(255, 220, 140, 0) 70%); animation: rise linear infinite; }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.1) translateY(-1.5%); } }
@keyframes logoIn { 0% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(0.6); } 100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes logoFloat { 0%, 100% { opacity: 1; transform: translateX(-50%) translateY(0); } 50% { opacity: 1; transform: translateX(-50%) translateY(-7px); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes rise { 0% { transform: translateY(0) scale(0.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-46vh) translateX(20px) scale(1.1); opacity: 0; } }

/* ---------- intro video ---------- */
#intro { background: #1c3550 url(../assets/cover-bg.png) center / cover no-repeat; }
#intro-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: transparent; }
#skip { position: absolute; top: calc(64px + env(safe-area-inset-top, 0px)); right: 12px; min-width: 92px; min-height: 44px; padding: 8px 18px; border-radius: 4px; border: 1px solid var(--gold); background: linear-gradient(var(--ink2), var(--ink)); color: var(--gold-hi); font-size: 16px; font-weight: 700; letter-spacing: 0.1em; cursor: pointer;
  box-shadow: inset 0 0 0 3px rgba(16, 12, 28, 0.9), inset 0 0 0 4px rgba(232, 199, 122, 0.45), 0 4px 12px rgba(0, 0, 0, 0.5); text-shadow: 0 1px 2px #000; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.panel { position: relative; background: linear-gradient(160deg, rgba(34, 27, 50, 0.88), rgba(14, 11, 24, 0.86)); border: 1px solid var(--gold); border-radius: 6px;
  box-shadow: inset 0 0 0 3px rgba(14, 11, 24, 0.85), inset 0 0 0 4px rgba(232, 199, 122, 0.38), 0 6px 16px rgba(0, 0, 0, 0.45); }
.panel::before, .panel::after { content: ""; position: absolute; width: 9px; height: 9px; background: var(--gold); transform: rotate(45deg); box-shadow: 0 0 6px rgba(232, 199, 122, 0.8); pointer-events: none; }
.panel::before { top: -5px; left: calc(50% - 5px); }
.panel::after { bottom: -5px; left: calc(50% - 5px); }
#hud-left { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 10px; width: min(196px, 48vw); padding: 9px 11px 9px; box-sizing: border-box; }
.row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.tag { color: var(--gold); font-weight: 700; font-size: 13px; width: 22px; letter-spacing: 0.04em; text-shadow: 0 1px 2px #000; }
.tag.en { color: #bfe3ff; font-size: 15px; text-align: center; }
.bar { position: relative; flex: 1; height: 10px; background: linear-gradient(#07060c, #1c1828); border-radius: 2px; overflow: hidden; border: 1px solid rgba(232, 199, 122, 0.75); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.7); }
.bar::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 45%; background: linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0)); pointer-events: none; }
.bar > div { height: 100%; width: 100%; transition: width 0.15s; }
#hp-fill { background: linear-gradient(90deg, #2f8f5e, #6fdc9a 70%, #c9ffd9); }
#en-fill { background: linear-gradient(90deg, #2f5fae, #6fb2ff 70%, #d8ecff); width: 0; }
#en-fill.full { background: linear-gradient(90deg, #a9781f, #f2cf6d 70%, #fff4c9); box-shadow: 0 0 8px rgba(242, 207, 109, 0.9); }
#hp-text { color: var(--parch); font-weight: 700; font-size: 16px; min-width: 32px; text-align: right; text-shadow: 0 1px 2px #000; font-variant-numeric: tabular-nums; }
.chips { display: flex; gap: 10px; padding-left: 28px; }
.chip { position: relative; width: 36px; height: 36px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #2c2440, #0e0b18); border: 1px solid var(--gold); display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 0 2px rgba(14, 11, 24, 0.9), inset 0 0 0 3px rgba(232, 199, 122, 0.35); }
.chip img { width: 78%; height: 78%; object-fit: contain; }
.chip span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--parch); font-weight: 700; font-size: 15px; background: rgba(8, 6, 14, 0.66); border-radius: 50%; text-shadow: 0 1px 2px #000; }
.chip span:empty { display: none; }
.chip.ready { border-color: var(--gold-hi); animation: glow 0.9s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: inset 0 0 0 2px rgba(14, 11, 24, 0.9), 0 0 4px 1px rgba(232, 199, 122, 0.55); } to { box-shadow: inset 0 0 0 2px rgba(14, 11, 24, 0.9), 0 0 14px 4px rgba(255, 224, 150, 0.95); } }
#hud-right { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 64px; padding: 7px 13px; text-align: right; font-weight: 700; max-width: calc(50vw - 74px); box-sizing: border-box; }
#hud-right::before, #hud-right::after { left: auto; right: -5px; top: calc(50% - 5px); bottom: auto; }
#hud-right::after { right: auto; left: -5px; }
#wave-text { font-size: 16px; color: var(--gold); text-shadow: 0 1px 2px #000; white-space: nowrap; letter-spacing: 0.04em; }
#score-text { font-size: 16px; color: var(--parch); text-shadow: 0 1px 2px #000; white-space: nowrap; font-variant-numeric: tabular-nums; }
#boss { position: absolute; top: calc(116px + env(safe-area-inset-top, 0px)); left: 7%; right: 7%; text-align: center; }
#boss-name { display: inline-block; color: #ffdcb0; font-weight: 700; font-size: 16px; letter-spacing: 0.14em; padding: 0 22px; margin-bottom: 4px; text-shadow: 0 2px 3px #000, 0 0 10px rgba(0, 0, 0, 0.9);
  background: linear-gradient(90deg, transparent, rgba(16, 12, 28, 0.7) 20%, rgba(16, 12, 28, 0.7) 80%, transparent); }
#boss-name::before, #boss-name::after { content: "◆"; color: var(--gold); font-size: 10px; margin: 0 8px; vertical-align: middle; }
.bar.boss { height: 12px; border: 1px solid var(--gold); box-shadow: 0 0 0 2px rgba(10, 8, 18, 0.85), 0 0 0 3px rgba(232, 199, 122, 0.4); }
#boss-fill { background: linear-gradient(90deg, #7a1820, #d9483a 70%, #ffb39a); }

#banner { position: fixed; left: 0; right: 0; top: 30%; display: flex; flex-direction: column; align-items: center; text-align: center; pointer-events: none; opacity: 0; z-index: 6; }
#banner.show { animation: bannerAnim 2.4s ease-out both; }
#banner .big { position: relative; max-width: 92vw; box-sizing: border-box; padding: 4px 26px; font-size: 40px; font-weight: 700; color: var(--gold-hi); letter-spacing: 0.12em;
  text-shadow: 0 2px 0 #5a4214, 0 0 18px rgba(232, 199, 122, 0.85), 0 4px 12px #000; }
#banner .big::before, #banner .big::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold-hi) 50%, var(--gold) 80%, transparent); }
#banner .big::before { top: 0; } #banner .big::after { bottom: 0; }
#banner .sub { max-width: 86vw; margin-top: 8px; font-size: 17px; font-weight: 700; color: var(--parch); letter-spacing: 0.06em; text-shadow: 0 2px 4px #000; }
#banner.boss .big { color: #ffd9b0; text-shadow: 0 2px 0 #5e1a10, 0 0 18px rgba(255, 110, 60, 0.85), 0 4px 12px #000; }
@keyframes bannerAnim { 0% { opacity: 0; transform: scale(1.2); } 12% { opacity: 1; transform: scale(1); } 80% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.97) translateY(-12px); } }

#subtitle { position: fixed; left: 6%; right: 6%; top: calc(170px + env(safe-area-inset-top, 0px)); text-align: center; color: var(--parch); font-size: 17px; font-weight: 600; line-height: 1.45; letter-spacing: 0.03em;
  background: linear-gradient(90deg, rgba(14, 11, 24, 0.2), rgba(14, 11, 24, 0.8) 15%, rgba(14, 11, 24, 0.8) 85%, rgba(14, 11, 24, 0.2)); border-top: 1px solid rgba(232, 199, 122, 0.6); border-bottom: 1px solid rgba(232, 199, 122, 0.6);
  padding: 9px 14px; opacity: 0; transition: opacity 0.25s; pointer-events: none; z-index: 30; text-shadow: 0 1px 2px #000; }
#subtitle.show { opacity: 1; }
#subtitle.intro { top: auto; bottom: 10%; }
#subtitle.res { top: calc(18px + env(safe-area-inset-top, 0px)); bottom: auto; }

#flash { position: fixed; inset: 0; pointer-events: none; z-index: 4; opacity: 0; background: radial-gradient(ellipse at center, rgba(255, 0, 0, 0) 45%, rgba(200, 20, 30, 0.6) 100%); }

/* ---------- result / help ---------- */
#result, #help { display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(14, 10, 26, 0.45), rgba(6, 4, 12, 0.8)); }
#result:not(.hidden) .card { animation: cardIn 0.5s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.card { width: min(340px, calc(100vw - 40px)); padding: 26px 22px 22px; box-sizing: border-box; text-align: center; border-radius: 8px;
  box-shadow: inset 0 0 0 4px rgba(14, 11, 24, 0.9), inset 0 0 0 5px rgba(232, 199, 122, 0.45), inset 0 0 40px rgba(232, 199, 122, 0.08), 0 10px 30px rgba(0, 0, 0, 0.6); }
.card h1 { position: relative; margin: 0 0 16px; padding-bottom: 12px; font-size: 32px; font-weight: 700; letter-spacing: 0.12em; color: var(--gold-hi); text-shadow: 0 2px 0 #5a4214, 0 0 16px rgba(232, 199, 122, 0.75); }
.card h1::after, .card h2::after { content: "◆"; position: absolute; left: 0; right: 0; bottom: -6px; font-size: 10px; color: var(--gold); letter-spacing: 0; text-shadow: none;
  background: linear-gradient(90deg, transparent, var(--gold) 30%, transparent 46%, transparent 54%, var(--gold) 70%, transparent) center / 100% 1px no-repeat; }
.card h1.lose { color: #f2c4b8; text-shadow: 0 2px 0 #4a1010, 0 0 16px rgba(220, 80, 70, 0.6); }
.card h2 { position: relative; margin: 0 0 16px; padding-bottom: 10px; font-size: 23px; font-weight: 700; letter-spacing: 0.1em; color: var(--gold); }
#res-stats { margin-bottom: 16px; }
.stat { display: flex; justify-content: space-between; padding: 8px 6px; font-size: 17px; font-weight: 600; color: var(--parch); border-bottom: 1px solid rgba(232, 199, 122, 0.22); }
.stat b { color: var(--gold); font-variant-numeric: tabular-nums; }
.btn { display: block; width: 100%; min-height: 50px; margin-top: 10px; border-radius: 4px; border: 1px solid rgba(232, 199, 122, 0.7); background: linear-gradient(rgba(44, 36, 62, 0.9), rgba(20, 16, 32, 0.9)); color: var(--parch); font-size: 18px; font-weight: 700; letter-spacing: 0.1em; cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(14, 11, 24, 0.9), inset 0 0 0 3px rgba(232, 199, 122, 0.25); text-shadow: 0 1px 2px #000; }
.btn.primary { background: linear-gradient(#f7dc95, #c99a3e 60%, #a87a26); color: #2a1c06; border-color: #fff0c0; text-shadow: 0 1px 0 rgba(255, 240, 200, 0.6);
  box-shadow: inset 0 0 0 2px rgba(255, 240, 200, 0.35), 0 0 12px rgba(232, 199, 122, 0.35); }
.btn:focus-visible, .btn.focus { outline: 2px solid var(--gold-hi); outline-offset: 3px; }
#help-body { white-space: pre-line; text-align: left; font-size: 15px; line-height: 1.6; max-height: 58vh; overflow-y: auto; color: var(--parch); }
@keyframes cardIn { from { opacity: 0; transform: scale(0.88) translateY(18px); } to { opacity: 1; transform: none; } }
