:root {
  color-scheme: dark;
  --ink: #10191d;
  --paper: #e9dfc7;
  --jade: #6ed0c4;
  --gold: #d8b45d;
  --red: #a74e3d;
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; height: 100%; background: #0b1115; overflow: hidden; }

body {
  color: var(--paper);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 12%, rgba(64, 123, 120, .18), transparent 32rem),
    radial-gradient(circle at 86% 80%, rgba(136, 75, 50, .14), transparent 30rem),
    #0b1115;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .16;
  background-image: repeating-linear-gradient(110deg, transparent 0 22px, rgba(255,255,255,.025) 23px 24px);
}

button { font: inherit; }

.app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
}

.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  box-shadow: none;
  background: #17232a;
  touch-action: none;
  user-select: none;
}

#game { display: block; width: 100%; height: 100%; }

.icon-button {
  position: absolute;
  z-index: 6;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(230,211,160,.48);
  background: rgba(14,24,27,.76);
  color: #f2e8ce;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.sound-button { right: 68px; }
.icon-button.hidden { display: none; }

.audio-mixer {
  position: absolute;
  z-index: 8;
  top: 68px;
  right: 68px;
  width: 224px;
  padding: 14px;
  border: 1px solid rgba(230,211,160,.4);
  border-radius: 10px;
  background: rgba(8,18,22,.92);
  box-shadow: 0 12px 34px rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
}
.audio-mixer label { display: grid; grid-template-columns: 38px 1fr; gap: 8px; align-items: center; margin: 7px 0; color: #d9d4c3; font-size: 12px; }
.audio-mixer input { width: 100%; accent-color: #d8b45d; }
.audio-mixer button { width: 100%; margin-top: 8px; padding: 8px; border: 1px solid rgba(216,180,93,.35); border-radius: 5px; color: #eadcb8; background: rgba(35,64,63,.75); cursor: pointer; }

.screen-panel {
  position: absolute;
  z-index: 5;
  inset: 0;
  padding: 18% 12% 10%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, rgba(9,18,22,.74), rgba(9,15,18,.94));
  backdrop-filter: blur(5px);
}

.screen-panel.active { display: flex; }
.screen-panel.compact { padding-top: 28%; }
.screen-panel.scroll-panel { justify-content: flex-start; align-items: stretch; overflow: auto; padding: 48px clamp(24px, 8vw, 150px) 56px; text-align: left; scrollbar-color: rgba(216,180,93,.5) rgba(7,14,17,.4); }
.panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; width: 100%; max-width: 980px; margin: 0 auto 14px; }
.panel-header h2 { margin-bottom: 0; }
.close-button { margin-top: 4px; padding: 10px 18px; border: 1px solid rgba(216,180,93,.38); border-radius: 5px; color: #e6d9ba; background: rgba(18,37,40,.8); cursor: pointer; }
.screen-panel h1 { margin: 8px 0 0; font: 800 clamp(54px, 12vw, 92px)/1.05 "STKaiti", "KaiTi", serif; letter-spacing: .12em; color: #f0e1b9; text-shadow: 0 4px 18px rgba(216,180,93,.22); }
.screen-panel h2 { margin: 12px 0 18px; font: 700 clamp(34px, 7vw, 58px)/1.2 "STKaiti", "KaiTi", serif; letter-spacing: .08em; color: #f0e1b9; }
.title-seal { color: #e9c46e; font-size: 12px; letter-spacing: .26em; text-transform: uppercase; }
.tagline { margin: 12px 0 4px; letter-spacing: .22em; color: #b9d8d2; }
.intro { max-width: 370px; color: #d5d0bf; line-height: 1.8; font-size: 14px; }
.ornament { width: 76%; display: flex; align-items: center; gap: 12px; margin: 24px 0 8px; color: #d8b45d; }
.ornament span { height: 1px; flex: 1; background: linear-gradient(90deg, transparent, #9c7c3b); }
.ornament span:last-child { background: linear-gradient(90deg, #9c7c3b, transparent); }

.primary-button, .text-button, .level-card {
  border: 0;
  color: #f7ecd0;
  cursor: pointer;
}

.primary-button {
  min-width: 210px;
  margin-top: 18px;
  padding: 14px 28px;
  border: 1px solid #c7a452;
  border-radius: 4px;
  background: linear-gradient(135deg, #325c59, #1d3b3b);
  box-shadow: inset 0 0 18px rgba(110,208,196,.12), 0 8px 24px rgba(0,0,0,.32);
  letter-spacing: .18em;
}

.primary-button:hover { filter: brightness(1.12); }
.text-button { margin-top: 15px; padding: 8px 18px; background: transparent; color: #bfc7c2; }
.text-button:hover { color: #fff1ca; }
.control-note { margin-top: 24px; color: #829793; font-size: 12px; letter-spacing: .08em; }
.continue-copy { margin: 12px 0 -4px; padding: 8px 14px; border: 1px solid rgba(216,180,93,.2); border-radius: 20px; color: #d7c58f; background: rgba(8,20,23,.54); font-size: 12px; }
.menu-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 8px; }

.level-list { width: 100%; max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.chapter-heading { grid-column: 1 / -1; margin: 16px 0 0; padding: 8px 2px 5px; border-bottom: 1px solid rgba(216,180,93,.28); color: #e6c975; font: 700 19px "STKaiti", "KaiTi", serif; letter-spacing: .1em; }
.level-card { width: 100%; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; text-align: left; padding: 13px 14px; border: 1px solid rgba(216,180,93,.25); border-radius: 6px; background: rgba(20,38,41,.82); }
.level-card:hover:not(:disabled) { border-color: rgba(216,180,93,.7); background: rgba(32,58,58,.9); }
.level-card:disabled { opacity: .42; cursor: not-allowed; }
.level-index { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 1px solid #9c7c3b; color: #e5c66f; font: 700 11px serif; }
.level-card strong { display: block; font-family: "STKaiti", "KaiTi", serif; font-size: 19px; }
.level-card small { color: #91a9a3; }
.level-state { font-size: 11px; color: #d8b45d; }
.endless-card { grid-column: 1 / -1; background: linear-gradient(135deg, rgba(72,38,54,.9), rgba(20,49,52,.9)); }

.loadout-summary { max-width: 980px; width: 100%; margin: 0 auto 10px; color: #8fd5ce; font-size: 13px; }
.option-title { max-width: 980px; width: 100%; margin: 18px auto 8px; color: #e4cc8a; font: 700 17px "STKaiti", "KaiTi", serif; }
.option-copy { max-width: 980px; width: 100%; margin: 8px auto; color: #8da29e; font-size: 12px; }
.loadout-grid { width: 100%; max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.weapon-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.loadout-card, .choice-button { min-height: 62px; padding: 11px 13px; border: 1px solid rgba(216,180,93,.24); border-radius: 6px; color: #d9dfd8; background: rgba(17,37,40,.82); cursor: pointer; text-align: left; }
.loadout-card strong, .loadout-card small { display: block; }
.loadout-card strong { color: #eadbad; font-family: "STKaiti", "KaiTi", serif; font-size: 17px; }
.loadout-card small { margin-top: 5px; color: #8fa5a0; font-size: 10px; }
.loadout-card.selected, .choice-button.selected { border-color: #e2bf62; background: linear-gradient(135deg, rgba(54,105,98,.9), rgba(33,62,62,.92)); box-shadow: inset 0 0 18px rgba(101,223,209,.12); }
.loadout-card:disabled, .choice-button:disabled { opacity: .38; cursor: not-allowed; }
.weapon-thunder.selected { box-shadow: inset 0 0 24px rgba(101,220,255,.22); }
.weapon-fire.selected { box-shadow: inset 0 0 24px rgba(255,113,57,.2); }
.weapon-ice.selected { box-shadow: inset 0 0 24px rgba(145,212,255,.2); }
.choice-row { width: 100%; max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.choice-button { min-height: 44px; text-align: center; }
.save-actions { width: 100%; max-width: 980px; margin: 18px auto 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.armory-head { width: 100%; max-width: 980px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.coin-balance { flex: 0 0 auto; margin: 0; padding: 8px 14px; border: 1px solid rgba(226,191,98,.48); border-radius: 22px; color: #f0d37f; background: rgba(10,30,31,.78); font-weight: 700; }
.armory-preview { display: block; width: min(100%, 720px); aspect-ratio: 16 / 7; margin: 5px auto 0; border: 1px solid rgba(216,180,93,.36); border-radius: 8px; background: #0c1c22; box-shadow: inset 0 0 40px rgba(51,112,108,.15), 0 14px 35px rgba(0,0,0,.3); }
.armory-preview-copy { width: min(100%, 720px); margin: 7px auto 15px; color: #9fd3cc; font-size: 12px; text-align: center; }
.armory-list { width: 100%; max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.armory-card { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 7px; border: 1px solid rgba(216,180,93,.22); border-radius: 7px; background: rgba(13,31,34,.8); }
.armory-card.selected { border-color: #e2bf62; box-shadow: inset 0 0 26px rgba(94,205,194,.1); }
.armory-card.locked { opacity: .48; }
.armory-select, .armory-buy { border: 0; border-radius: 5px; color: #e9dfc7; background: transparent; cursor: pointer; }
.armory-select { padding: 9px 11px; text-align: left; }
.armory-select strong, .armory-select small { display: block; }
.armory-select strong { color: #ead38d; font: 700 18px "STKaiti", "KaiTi", serif; }
.armory-select small { margin-top: 4px; color: #8fa8a2; font-size: 10px; }
.armory-buy { min-width: 96px; padding: 8px 10px; border: 1px solid rgba(216,180,93,.34); background: rgba(42,77,73,.78); font-size: 11px; }
.armory-select:disabled, .armory-buy:disabled { cursor: not-allowed; opacity: .48; }
.armory-status { width: 100%; max-width: 980px; min-height: 20px; margin: 12px auto 0; color: #cfbc85; font-size: 12px; text-align: center; }
.records-list { width: 100%; max-width: 980px; margin: 0 auto; display: grid; gap: 8px; }
.record-row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid rgba(216,180,93,.2); background: rgba(17,35,38,.76); }
.record-row strong { color: #ebcf7f; }.record-row span { color: #d4dbd4; }.record-row small { color: #8ca19d; }
.empty-copy { color: #8ca19d; }

.result-stats { width: min(80%, 620px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 2px; }
.result-stats div { padding: 10px 6px; background: rgba(255,255,255,.045); border-top: 1px solid rgba(216,180,93,.25); }
.result-stats strong { display: block; color: #efcf7d; font-size: 20px; }
.result-stats span { color: #91a9a3; font-size: 11px; }

.training-result, .training-balance, .training-list, .training-actions { width: 100%; max-width: 820px; margin-inline: auto; }
.training-result { margin-top: 0; color: #d8c995; line-height: 1.7; }
.training-balance { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center; margin-bottom: 16px; padding: 14px 18px; border: 1px solid rgba(216,180,93,.3); border-radius: 8px; background: rgba(12,31,33,.82); }
.training-balance strong { grid-row: 1 / 3; color: #f0cb68; font: 800 42px/1 "STKaiti", "KaiTi", serif; }
.training-balance span { color: #e7dab5; font-weight: 700; }.training-balance small { color: #8fa59f; }
.training-list { display: grid; gap: 10px; }
.training-row { display: grid; grid-template-columns: minmax(130px, 1fr) auto minmax(190px, 1.5fr); gap: 12px; align-items: center; padding: 13px 15px; border: 1px solid rgba(216,180,93,.23); border-radius: 7px; background: rgba(15,35,38,.84); }
.training-row strong { display: block; color: #ecd58f; font: 700 19px "STKaiti", "KaiTi", serif; }.training-row small { display: block; margin-top: 4px; color: #91a7a1; }
.training-stepper { display: flex; align-items: center; gap: 9px; }.training-stepper button { width: 36px; height: 36px; border: 1px solid rgba(216,180,93,.35); border-radius: 50%; color: #f1e2bd; background: rgba(42,77,73,.75); cursor: pointer; }.training-stepper b { min-width: 20px; text-align: center; color: #f3cb63; }
.training-preview { color: #b9d5cf; font-size: 12px; text-align: right; }
.training-actions { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 9px; margin-top: 16px; }.training-actions .primary-button { margin-top: 0; }.training-actions .choice-button { text-align: center; }
.curio-detail-copy { width: min(92%, 520px); padding: 18px; border: 1px solid rgba(216,180,93,.3); border-radius: 9px; background: rgba(10,28,31,.86); color: #c8d3cd; line-height: 1.8; text-align: left; }.curio-detail-copy strong { color: #efcf76; }
.curio-confirm-screen { background: radial-gradient(circle at 50% 43%, rgba(126,78,20,.28), transparent 42%), linear-gradient(180deg, rgba(7,14,17,.84), rgba(8,12,14,.97)); }
.curio-confirm-copy { width: min(92%, 560px); padding: 22px 24px; border: 1px solid rgba(255,209,91,.54); border-radius: 10px; background: rgba(39,27,10,.9); box-shadow: 0 0 45px rgba(255,186,52,.16), inset 0 0 26px rgba(255,220,116,.08); color: #e7dcc1; line-height: 1.85; text-align: left; }
.curio-confirm-copy strong { display: block; margin-bottom: 8px; color: #ffe18a; font-size: 18px; }.curio-confirm-copy span { color: #b9c9c3; font-size: 12px; }
.curio-confirm-actions { width: min(92%, 560px); display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; margin-top: 14px; }.curio-confirm-actions .primary-button { min-width: 0; margin: 0; }.curio-confirm-actions .choice-button { text-align: center; }.danger-confirm { background: linear-gradient(135deg, #9a6321, #604016); border-color: #f2c760; }

.side-copy { display: none; }
.eyebrow { color: #d8b45d; letter-spacing: .2em; font-size: 11px; }
.side-copy h2 { margin: 10px 0 18px; font: 700 38px/1.2 "STKaiti", "KaiTi", serif; color: #ebddbd; }
.side-copy > p:not(.eyebrow) { color: #aebbb7; line-height: 1.8; }
.side-copy dl { display: grid; gap: 8px; margin-top: 30px; }
.side-copy dl div { display: grid; grid-template-columns: 44px 1fr; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); padding: 9px 0; }
.side-copy dt { color: #e3c36e; font: 700 24px "STKaiti", "KaiTi", serif; }
.side-copy dd { margin: 0; color: #c5cfcb; }
.upgrade-route { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 24px; padding: 12px; border: 1px solid rgba(216,180,93,.2); background: rgba(17,35,37,.62); color: #e0c675; font-size: 12px; }
.upgrade-route i { color: #719e98; font-style: normal; }

@media (max-width: 820px) {
  body { background: #080d10; }
  .app-shell { display: grid; place-items: center; padding: 0; height: 100dvh; }
  .game-stage { width: min(100vw, calc(100dvh * 9 / 16)); height: min(100dvh, calc(100vw * 16 / 9)); margin: auto; border: 0; border-radius: 0; }
  .side-copy { display: none; }
  .audio-mixer { right: 12px; top: 66px; }
  .screen-panel.scroll-panel { padding: 58px 20px 42px; }
  .level-list { grid-template-columns: 1fr; }
  .weapon-grid, .loadout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .armory-list { grid-template-columns: 1fr; }
  .armory-head { align-items: flex-start; flex-direction: column; gap: 0; }
  .record-row { grid-template-columns: 55px 1fr; }.record-row small { grid-column: 2; }
  .training-row { grid-template-columns: 1fr auto; }.training-preview { grid-column: 1 / -1; text-align: left; }.training-actions { grid-template-columns: 1fr; }
  .curio-confirm-actions { grid-template-columns: 1fr; }
  .panel-header h2 { font-size: 31px; }
}

@media (max-width: 520px) {
  .screen-panel { padding-inline: 8%; }
  .screen-panel h1 { font-size: 50px; }
  .result-stats { width: 96%; grid-template-columns: repeat(2, 1fr); }
  .choice-row, .save-actions { grid-template-columns: 1fr; }
  .armory-card { grid-template-columns: 1fr 92px; }
}

html[data-mode="mobile"] .app-shell { display: grid; place-items: center; width: 100vw; height: 100dvh; }
html[data-mode="mobile"] .game-stage { width: min(100vw, calc(100dvh * 9 / 16)); height: min(100dvh, calc(100vw * 16 / 9)); border: 0; border-radius: 0; }
html[data-mode="desktop"] .app-shell { display: block; width: 100vw; height: 100dvh; }
html[data-mode="desktop"] .game-stage { width: 100%; height: 100%; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
