:root {
  --bg: #111629;
  --panel: rgba(18, 28, 45, 0.88);
  --panel-strong: rgba(12, 18, 33, 0.96);
  --line: rgba(180, 221, 211, 0.22);
  --text: #f6fff8;
  --muted: #a9c8c1;
  --green: #42ddb0;
  --gold: #ffd166;
  --violet: #b18cff;
  --danger: #ff6b76;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 16%, rgba(66, 221, 176, 0.24), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(177, 140, 255, 0.18), transparent 30%),
    linear-gradient(135deg, #0b1020 0%, #162033 48%, #12192b 100%);
  touch-action: manipulation;
}

body.game-active {
  overflow: hidden;
  touch-action: none;
}

#app {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary-btn {
  background: linear-gradient(135deg, #27d39a, #2fa8ff);
  box-shadow: 0 12px 28px rgba(47, 168, 255, 0.22);
}

.gold-btn {
  color: #221600;
  background: linear-gradient(135deg, #ffe28a, #ffb938);
  box-shadow: 0 12px 28px rgba(255, 185, 56, 0.2);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--line);
}

.danger-btn {
  border-color: rgba(255, 107, 118, 0.38);
  background: rgba(255, 107, 118, 0.16);
}

.screen {
  display: none;
  height: 100dvh;
  min-height: 100dvh;
  overflow-y: auto;
  padding: 28px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.screen.active {
  display: flex;
}

#gameScreen {
  overflow: hidden;
  padding: 0;
  touch-action: none;
}

.start-layout,
.training-layout,
.level-layout {
  width: min(1180px, 100%);
  margin: auto;
}

.start-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(340px, 1.08fr);
  gap: 36px;
  align-items: center;
}

.brand-block {
  padding: 36px 0;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block h1,
.training-header h1 {
  font-size: clamp(42px, 7vw, 84px);
  line-height: 1;
}

.subtitle {
  max-width: 620px;
  margin: 18px 0 0;
  color: #d7fff3;
  font-size: 20px;
  line-height: 1.7;
}

.test-note {
  max-width: 620px;
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 209, 102, 0.3);
  border-radius: 8px;
  color: #fff1b8;
  background: rgba(255, 209, 102, 0.09);
  font-weight: 800;
  line-height: 1.6;
}

.mobile-play-hint {
  max-width: 620px;
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid rgba(66, 221, 176, 0.42);
  border-radius: 8px;
  color: #d7fff3;
  background: rgba(66, 221, 176, 0.13);
  box-shadow: 0 12px 34px rgba(66, 221, 176, 0.12);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.55;
}

.start-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.start-status span {
  padding: 10px 12px;
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.start-status strong {
  margin-left: 6px;
  color: #fff1b8;
}

.plain-text {
  color: var(--muted);
  line-height: 1.7;
}

.start-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.hero-preview {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(18, 35, 58, 0.35), rgba(13, 19, 36, 0.96)),
    radial-gradient(circle at 48% 42%, rgba(66, 221, 176, 0.18), transparent 28%);
  box-shadow: var(--shadow);
}

.hero-preview::before {
  position: absolute;
  inset: 0;
  content: "";
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.65) 0 1px, transparent 1.4px),
    linear-gradient(rgba(114, 220, 195, 0.08) 1px, transparent 1px);
  background-size:
    54px 54px,
    100% 42px;
  opacity: 0.42;
}

.moon {
  position: absolute;
  top: 56px;
  right: 66px;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #ffe9a6;
  box-shadow: 0 0 60px rgba(255, 225, 143, 0.55);
}

.preview-aura {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 220px;
  height: 220px;
  border: 2px solid rgba(66, 221, 176, 0.42);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow:
    inset 0 0 40px rgba(66, 221, 176, 0.16),
    0 0 70px rgba(66, 221, 176, 0.22);
}

.preview-player {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  width: 86px;
  height: 86px;
  place-items: center;
  border-radius: 50%;
  color: #1d2e2f;
  font-size: 34px;
  font-weight: 900;
  background: linear-gradient(145deg, #bffff0, #41d7a9 60%, #2f9fcd);
  box-shadow:
    0 0 38px rgba(66, 221, 176, 0.45),
    0 18px 32px rgba(0, 0, 0, 0.34);
  transform: translate(-50%, -50%);
}

.preview-monster {
  position: absolute;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.12);
}

.preview-monster::after {
  position: absolute;
  left: 50%;
  top: 44%;
  width: 26px;
  height: 8px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 25% 50%, #fff 0 4px, transparent 4.5px),
    radial-gradient(circle at 75% 50%, #fff 0 4px, transparent 4.5px);
  content: "";
  transform: translate(-50%, -50%);
}

.m1 {
  left: 18%;
  top: 26%;
  width: 54px;
  height: 54px;
  background: #121216;
}

.m2 {
  right: 18%;
  bottom: 24%;
  width: 64px;
  height: 64px;
  background: #d94854;
}

.m3 {
  left: 26%;
  bottom: 18%;
  width: 72px;
  height: 72px;
  background: #6d51c8;
}

.preview-sword,
.preview-fire {
  position: absolute;
  z-index: 2;
}

.preview-sword {
  left: 61%;
  top: 34%;
  width: 78px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #f9ffff 34%, #7ce7ff 68%, #ffe28a);
  transform: rotate(-24deg);
}

.preview-fire {
  left: 28%;
  top: 58%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3a8 0 22%, #ff9f43 23% 58%, #ec4d5c 59%);
  box-shadow: 0 0 34px rgba(255, 159, 67, 0.78);
}

.game-shell {
  position: relative;
  width: min(1180px, 100%);
  height: min(100dvh - 56px, 760px);
  min-height: 560px;
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1426;
  box-shadow: var(--shadow);
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
}

.hud {
  position: absolute;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-hud {
  left: 14px;
  top: 14px;
  right: 14px;
}

.hud-pill {
  display: flex;
  min-width: 100px;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(9, 15, 27, 0.64);
  backdrop-filter: blur(10px);
}

.hud-pill span {
  color: var(--muted);
  font-size: 12px;
}

.hud-pill strong {
  font-size: 14px;
}

.area-pill {
  border-color: rgba(255, 209, 102, 0.22);
}

.area-pill strong {
  color: #fff1b8;
}

.exp-wrap {
  position: absolute;
  z-index: 4;
  left: 14px;
  right: 14px;
  top: 64px;
  height: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
}

.exp-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #42ddb0, #7ce7ff, #ffe28a);
  transition: width 120ms linear;
}

.exp-wrap span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #102526;
  font-size: 11px;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.pressure-hud {
  position: absolute;
  z-index: 4;
  left: 14px;
  top: 88px;
  display: flex;
  max-width: min(880px, calc(100% - 28px));
  flex-wrap: wrap;
  gap: 7px;
}

.pressure-hud span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(191, 255, 240, 0.2);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  background: rgba(9, 15, 27, 0.58);
  backdrop-filter: blur(10px);
}

.pressure-hud strong {
  color: #fff1b8;
  font-size: 13px;
}

.pressure-hud span.danger {
  border-color: rgba(255, 107, 118, 0.5);
  background: rgba(255, 107, 118, 0.16);
}

.pressure-hud span.danger strong {
  color: #ffd7dc;
}

.debug-panel {
  position: absolute;
  z-index: 6;
  top: 96px;
  right: 14px;
  width: min(286px, calc(100% - 28px));
  overflow: hidden;
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 8px;
  background: rgba(6, 10, 19, 0.74);
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.debug-toggle {
  width: 100%;
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-bottom: 1px solid rgba(255, 209, 102, 0.18);
  border-radius: 0;
  color: #fff1b8;
  background: rgba(255, 209, 102, 0.08);
  font-size: 12px;
  text-align: left;
}

.debug-body {
  display: grid;
  max-height: 420px;
  overflow: auto;
  padding: 8px 10px 10px;
  gap: 5px;
}

.debug-body div {
  display: flex;
  min-height: 21px;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.debug-body strong {
  color: #d7fff3;
  font-weight: 900;
  text-align: right;
}

.debug-panel.collapsed .debug-body {
  display: none;
}

.debug-panel.collapsed {
  width: auto;
}

.debug-panel.collapsed .debug-toggle {
  border-bottom: 0;
}

.omen {
  position: absolute;
  z-index: 5;
  top: 126px;
  left: 50%;
  padding: 8px 18px;
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 999px;
  color: #fff1b8;
  font-weight: 900;
  background: rgba(80, 42, 104, 0.78);
  box-shadow: 0 0 28px rgba(255, 209, 102, 0.28);
  transform: translateX(-50%);
}

.mobile-tutor-tip {
  position: absolute;
  z-index: 8;
  left: 50%;
  top: 50%;
  width: min(520px, calc(100% - 36px));
  padding: 16px 18px;
  border: 1px solid rgba(255, 209, 102, 0.46);
  border-radius: 8px;
  color: #fff6cf;
  background: rgba(6, 10, 19, 0.82);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.32);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.55;
  text-align: center;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.skill-panel {
  position: absolute;
  z-index: 4;
  right: 14px;
  bottom: 14px;
  width: min(300px, calc(100% - 28px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(9, 15, 27, 0.68);
  backdrop-filter: blur(12px);
}

.skill-panel h2 {
  margin-bottom: 8px;
  font-size: 15px;
}

.skill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.skill-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #effff8;
  font-size: 12px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.08);
}

.joystick {
  position: absolute;
  z-index: 7;
  left: 0;
  top: 0;
  display: grid;
  width: 136px;
  height: 136px;
  place-items: center;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transition:
    opacity 80ms ease,
    transform 80ms ease;
  touch-action: none;
  user-select: none;
  pointer-events: none;
}

.joystick.active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.joystick-base {
  position: relative;
  width: 124px;
  height: 124px;
  border: 1px solid rgba(191, 255, 240, 0.32);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(191, 255, 240, 0.16), transparent 39%),
    rgba(8, 15, 28, 0.46);
  box-shadow:
    inset 0 0 22px rgba(191, 255, 240, 0.1),
    0 10px 28px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
}

.joystick-base::before,
.joystick-base::after {
  position: absolute;
  left: 50%;
  top: 50%;
  content: "";
  background: rgba(191, 255, 240, 0.22);
  transform: translate(-50%, -50%);
}

.joystick-base::before {
  width: 70%;
  height: 1px;
}

.joystick-base::after {
  width: 1px;
  height: 70%;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255, 241, 184, 0.78);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.62), transparent 26%),
    linear-gradient(145deg, rgba(66, 221, 176, 0.88), rgba(47, 168, 255, 0.82));
  box-shadow: 0 0 24px rgba(66, 221, 176, 0.34);
  transform: translate(-50%, -50%);
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 16, 0.62);
  backdrop-filter: blur(8px);
}

.modal-panel,
.result-panel {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.modal-panel {
  padding: 24px;
}

.modal-panel h2 {
  margin-bottom: 18px;
  font-size: 28px;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.upgrade-card {
  display: flex;
  min-height: 222px;
  padding: 14px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.14), transparent 38%),
    rgba(255, 255, 255, 0.07);
  text-align: left;
}

.upgrade-card.breakthrough {
  border-color: rgba(255, 209, 102, 0.38);
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 209, 102, 0.2), transparent 38%),
    rgba(255, 255, 255, 0.08);
}

.upgrade-card:hover {
  border-color: rgba(255, 209, 102, 0.55);
}

.skill-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #09111f;
  font-size: 24px;
  background: var(--gold);
}

.upgrade-card strong {
  display: block;
  margin-top: 12px;
  font-size: 18px;
}

.upgrade-card span,
.upgrade-card p {
  color: var(--muted);
}

.upgrade-card .choice-type {
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #d7fff3;
  font-size: 11px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.08);
}

.upgrade-card.breakthrough .choice-type {
  border-color: rgba(255, 209, 102, 0.36);
  color: #fff1b8;
  background: rgba(255, 209, 102, 0.12);
}

.upgrade-card p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.upgrade-card .effect-note {
  color: #fff1b8;
  font-weight: 800;
}

.overlay-screen {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(66, 221, 176, 0.12), transparent 34%),
    rgba(7, 10, 18, 0.84);
}

.result-panel {
  padding: 28px;
}

.result-panel h2 {
  font-size: 36px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.stat-grid div,
.training-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.stat-grid div {
  padding: 14px;
}

.stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.training-layout,
.level-layout {
  align-self: center;
}

.training-header {
  display: flex;
  gap: 18px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.stone-bank {
  padding: 12px 16px;
  border: 1px solid rgba(255, 209, 102, 0.38);
  border-radius: 8px;
  color: #fff1b8;
  background: rgba(255, 209, 102, 0.12);
}

.stone-bank strong {
  font-size: 24px;
}

.character-card {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(255, 209, 102, 0.26);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(66, 221, 176, 0.12), rgba(255, 209, 102, 0.08)),
    rgba(255, 255, 255, 0.06);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.22);
}

.portrait-frame {
  position: relative;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 36%, rgba(255, 209, 102, 0.2), transparent 34%),
    linear-gradient(180deg, rgba(9, 17, 31, 0.74), rgba(6, 10, 18, 0.92));
}

#rolePortrait {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 360px;
}

.power-toast {
  position: absolute;
  left: 50%;
  bottom: 20px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 209, 102, 0.52);
  border-radius: 999px;
  color: #fff1b8;
  font-weight: 900;
  background: rgba(45, 29, 11, 0.74);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 240ms ease;
  pointer-events: none;
}

.power-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.role-profile {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
}

.role-profile h2 {
  color: #fff1b8;
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.08;
}

.role-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.role-stats.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.role-stats article,
.equipped-row {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.role-stats span,
.equipped-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.role-stats strong,
.equipped-row strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  color: #fff1b8;
  font-size: 18px;
}

.role-stats article:nth-child(2) strong {
  color: #bffff0;
  font-size: 24px;
}

.role-break strong {
  color: #ffd166;
}

.equipped-row {
  margin-top: 10px;
}

.role-profile .plain-text {
  margin: 10px 0 0;
}

.room-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
  margin-bottom: 0;
}

.room-summary article,
.level-card,
.training-section,
.codex-card,
.artifact-card,
.achievement-card,
.more-panel,
.role-more {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.more-panel,
.role-more {
  margin-bottom: 16px;
  padding: 12px 14px;
}

.role-more {
  margin: 12px 0 0;
  background: rgba(0, 0, 0, 0.12);
}

.inline-more {
  margin: 14px 0 0;
}

.more-panel summary,
.role-more summary {
  color: #d7fff3;
  font-weight: 900;
  cursor: pointer;
}

.room-summary article {
  padding: 14px;
}

.room-summary span,
.level-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.room-summary strong {
  display: block;
  margin-top: 7px;
  color: #fff1b8;
  font-size: 24px;
}

.training-section {
  margin-top: 14px;
  padding: 16px;
}

.breakthrough-card {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  background:
    radial-gradient(circle at 18% 50%, rgba(255, 209, 102, 0.16), transparent 32%),
    rgba(255, 255, 255, 0.06);
}

.breakthrough-card h2,
.section-title h2 {
  font-size: 24px;
}

.breakthrough-card .plain-text {
  margin: 8px 0 0;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 12px;
}

.training-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.training-list.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.training-card {
  display: flex;
  min-height: 210px;
  padding: 14px;
  flex-direction: column;
  gap: 10px;
}

.training-card.focus {
  border-color: rgba(255, 209, 102, 0.34);
  background:
    linear-gradient(180deg, rgba(255, 209, 102, 0.1), rgba(66, 221, 176, 0.05)),
    rgba(255, 255, 255, 0.06);
}

.training-card.compact {
  min-height: 184px;
}

.training-card h2 {
  font-size: 19px;
}

.training-card p {
  flex: 1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.training-card .meta-level {
  color: #fff1b8;
  font-weight: 900;
}

.training-card .power-note {
  color: #bffff0;
  font-weight: 800;
}

.level-pips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.level-pips i {
  flex: 1 0 calc(20% - 5px);
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.level-pips i.active {
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.level-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.level-card {
  position: relative;
  min-height: 318px;
  overflow: hidden;
  padding: 18px;
}

.level-card::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.16), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.level-card.locked {
  filter: grayscale(0.55);
  opacity: 0.68;
}

.level-card.selected {
  border-color: rgba(255, 209, 102, 0.62);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.16), 0 18px 42px rgba(0, 0, 0, 0.2);
}

.level-card.danger {
  border-color: rgba(255, 107, 118, 0.68);
  box-shadow: 0 0 0 1px rgba(255, 107, 118, 0.2), 0 18px 42px rgba(0, 0, 0, 0.24);
}

.mini-tag.danger {
  border-color: rgba(255, 107, 118, 0.55);
  color: #ffd7dc;
  background: rgba(255, 107, 118, 0.16);
}

.level-card h2,
.level-card p,
.level-card button,
.level-card span,
.level-scene {
  position: relative;
  z-index: 1;
}

.level-card h2 {
  margin-top: 8px;
  font-size: 28px;
}

.level-card p {
  min-height: 58px;
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.level-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 12px;
}

.level-meta .mini-tag {
  overflow-wrap: anywhere;
  border-color: rgba(255, 255, 255, 0.16);
  color: #d7fff3;
  background: rgba(255, 255, 255, 0.08);
}

.level-scene {
  height: 96px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
}

.level-scene.path {
  background:
    radial-gradient(circle at 28% 72%, #6f8a78 0 10px, transparent 11px),
    radial-gradient(circle at 70% 62%, #96b696 0 8px, transparent 9px),
    linear-gradient(120deg, transparent 42%, rgba(210, 220, 180, 0.22) 43% 58%, transparent 59%),
    linear-gradient(180deg, #18382f, #253b35);
}

.level-scene.bamboo {
  background:
    repeating-linear-gradient(90deg, rgba(92, 166, 103, 0.68) 0 5px, transparent 5px 35px),
    radial-gradient(circle at 50% 54%, rgba(198, 239, 188, 0.2), transparent 36%),
    linear-gradient(180deg, #253542, #1d2a24);
}

.level-scene.temple {
  background:
    linear-gradient(165deg, transparent 22%, rgba(151, 122, 90, 0.36) 23% 40%, transparent 41%),
    linear-gradient(90deg, transparent 8%, rgba(231, 203, 138, 0.12) 9% 16%, transparent 17%),
    radial-gradient(circle at 74% 46%, rgba(255, 209, 102, 0.2), transparent 25%),
    linear-gradient(180deg, #342536, #1f2026);
}

.level-scene.storm {
  background:
    repeating-linear-gradient(115deg, transparent 0 28px, rgba(167, 139, 250, 0.2) 29px 33px),
    radial-gradient(circle at 64% 28%, rgba(255, 241, 184, 0.25), transparent 18%),
    linear-gradient(180deg, #182342, #231d39);
}

.level-scene.trial {
  background:
    radial-gradient(circle at 56% 35%, rgba(255, 209, 102, 0.32), transparent 23%),
    repeating-linear-gradient(70deg, transparent 0 22px, rgba(177, 140, 255, 0.18) 23px 28px),
    linear-gradient(180deg, #342044, #463214);
}

.codex-list,
.artifact-list,
.achievement-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.codex-card,
.artifact-card,
.achievement-card {
  min-height: 118px;
  padding: 12px;
}

.codex-card h3,
.artifact-card h3,
.achievement-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.codex-card p,
.artifact-card p,
.achievement-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.codex-card.unseen,
.artifact-card.locked,
.achievement-card.locked {
  opacity: 0.62;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.mini-tag {
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #fff1b8;
  font-size: 11px;
  font-weight: 800;
  background: rgba(255, 209, 102, 0.1);
}

.level-card button {
  width: 100%;
}

@media (max-width: 920px) {
  .screen {
    padding: 16px;
  }

  .start-layout,
  .character-card,
  .training-list,
  .training-list.compact,
  .room-summary,
  .role-stats,
  .role-stats.compact,
  .level-list,
  .codex-list,
  .artifact-list,
  .achievement-list {
    grid-template-columns: 1fr;
  }

  .hero-preview {
    min-height: 360px;
  }

  .game-shell {
    min-height: 620px;
  }

  .exp-wrap {
    top: 112px;
  }

  .pressure-hud {
    top: 140px;
  }

  .debug-panel {
    top: 212px;
    right: 14px;
    width: min(286px, calc(100% - 28px));
  }

  .debug-body {
    max-height: 230px;
  }

  .omen {
    top: 454px;
  }

  .upgrade-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .skill-panel {
    left: 14px;
    width: auto;
  }

  .portrait-frame {
    min-height: 280px;
  }

  #rolePortrait {
    min-height: 280px;
  }
}

@media (max-width: 560px) {
  .top-hud {
    gap: 6px;
  }

  .hud-pill {
    min-width: calc(50% - 3px);
    padding: 7px 8px;
  }

  .game-shell {
    height: calc(100vh - 32px);
    min-height: 580px;
  }

  .exp-wrap {
    top: 148px;
  }

  .pressure-hud {
    top: 176px;
  }

  .debug-panel {
    top: 248px;
  }

  .debug-body {
    max-height: 180px;
  }

  .omen {
    top: 470px;
  }

  .brand-block h1,
  .training-header h1 {
    font-size: 46px;
  }

  .training-header {
    align-items: start;
    flex-direction: column;
  }
}

@media (min-width: 701px) {
  #gameScreen {
    padding: 28px;
  }
}

@media (max-width: 700px) {
  .screen {
    padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 14px);
  }

  #gameScreen {
    padding: 0;
  }

  .start-layout,
  .training-layout,
  .level-layout {
    width: 100%;
  }

  .brand-block {
    padding: 18px 0 10px;
  }

  .brand-block h1,
  .training-header h1 {
    font-size: 42px;
  }

  .subtitle {
    font-size: 16px;
    line-height: 1.55;
  }

  .test-note {
    font-size: 14px;
  }

  .mobile-play-hint {
    padding: 15px 16px;
    font-size: 16px;
  }

  .start-actions,
  .button-row {
    gap: 14px;
  }

  .start-actions button,
  .button-row button {
    flex: 1 1 100%;
    min-height: 56px;
    padding: 0 16px;
    font-size: 16px;
  }

  .hero-preview {
    min-height: min(54vh, 420px);
  }

  .game-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .top-hud {
    left: 8px;
    right: 8px;
    top: calc(env(safe-area-inset-top) + 8px);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
    pointer-events: none;
  }

  .hud-pill {
    min-width: 0;
    height: 36px;
    padding: 4px 5px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 1px;
    background: rgba(9, 15, 27, 0.56);
  }

  .top-hud .hud-pill:nth-child(1),
  .top-hud .area-pill,
  .top-hud .hud-pill:nth-child(8) {
    display: none;
  }

  .hud-pill span {
    font-size: 9px;
  }

  .hud-pill strong {
    max-width: 100%;
    overflow: hidden;
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .exp-wrap {
    display: none;
  }

  .exp-wrap span {
    font-size: 10px;
  }

  .pressure-hud {
    left: 8px;
    right: auto;
    top: calc(env(safe-area-inset-top) + 48px);
    max-width: calc(100% - 16px);
    flex-direction: row;
    align-items: flex-start;
    gap: 4px;
    pointer-events: none;
  }

  .pressure-hud span {
    max-width: 100%;
    padding: 5px 7px;
    justify-content: space-between;
    font-size: 10px;
  }

  .pressure-hud strong {
    font-size: 11px;
  }

  .pressure-hud span:nth-child(n + 2) {
    display: none;
  }

  .pressure-hud span:nth-child(3),
  .pressure-hud span:nth-child(4) {
    display: none;
  }

  .debug-panel {
    top: calc(env(safe-area-inset-top) + 82px);
    right: 8px;
    width: min(286px, calc(100% - 16px));
  }

  .debug-toggle {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(255, 209, 102, 0.24);
    border-radius: 8px;
    font-size: 12px;
    text-align: center;
  }

  .debug-body {
    max-height: 38vh;
  }

  .omen {
    top: calc(env(safe-area-inset-top) + 116px);
    max-width: calc(100% - 24px);
    padding: 7px 12px;
    font-size: 12px;
    text-align: center;
    white-space: normal;
  }

  .skill-panel {
    display: none;
  }

  .joystick {
    width: 132px;
    height: 132px;
  }

  .joystick-base {
    width: 124px;
    height: 124px;
  }

  .joystick-knob {
    width: 50px;
    height: 50px;
  }

  .mobile-tutor-tip {
    top: 46%;
    width: min(340px, calc(100% - 32px));
    padding: 14px 15px;
    font-size: 15px;
  }

  .modal {
    padding: 12px;
  }

  .modal-panel,
  .result-panel {
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .modal-panel,
  .result-panel {
    padding: 18px;
  }

  .result-panel h2 {
    font-size: 28px;
  }

  .stat-grid div {
    padding: 12px;
  }

  .stat-grid strong {
    font-size: 20px;
  }

  .character-card,
  .training-section {
    padding: 14px;
  }

  .breakthrough-card,
  .section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .training-card {
    min-height: 0;
  }

  .level-card {
    min-height: 0;
    padding: 16px;
  }

  .level-list {
    gap: 16px;
  }

  .training-list,
  .training-list.compact,
  .codex-list,
  .artifact-list,
  .achievement-list {
    gap: 12px;
  }
}

@media (max-height: 680px) and (max-width: 700px) {
  .top-hud {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .hud-pill {
    height: 32px;
  }

  .pressure-hud {
    top: calc(env(safe-area-inset-top) + 42px);
  }

  .debug-panel {
    top: calc(env(safe-area-inset-top) + 74px);
  }

  .joystick {
    width: 126px;
    height: 126px;
  }

  .joystick-base {
    width: 118px;
    height: 118px;
  }

  .joystick-knob {
    width: 48px;
    height: 48px;
  }
}
