:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #647084;
  --line: #d9e0e7;
  --surface: #ffffff;
  --band: #f3f6f8;
  --accent: #0e7c66;
  --accent-2: #b4462f;
  --focus: #1c67d2;
  --warning: #a76800;
  --shadow: 0 10px 30px rgba(24, 33, 47, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--band);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 38px;
  padding: 0 12px;
  border-radius: 6px;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

button.danger {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  background: #102033;
  color: white;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand strong {
  font-size: 22px;
}

.brand span,
.profile,
.small {
  color: #9fb1c6;
  font-size: 13px;
  line-height: 1.5;
}

.side-link {
  color: #dfe9f3;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  padding: 10px 12px;
}

.launcher {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(rgba(16, 32, 51, 0.68), rgba(16, 32, 51, 0.78)),
    url("/assets/opening-bg.png") center / cover;
}

.launcher-hero {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 28px;
  align-items: end;
  color: white;
}

.launcher-hero h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(34px, 6vw, 72px);
  line-height: 1.02;
}

.launcher-hero p {
  max-width: 620px;
  color: #dbe8f4;
  line-height: 1.7;
}

.eyebrow {
  margin: 0 0 10px;
  color: #a8d9cb;
  font-weight: 700;
}

.launcher-actions {
  display: grid;
  gap: 12px;
}

.launch-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.launch-card strong {
  font-size: 20px;
}

.launch-card span {
  color: var(--muted);
  line-height: 1.5;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: #dfe9f3;
  border-color: rgba(255, 255, 255, 0.13);
}

.nav button.active {
  background: #e8f5f1;
  color: #102033;
  border-color: #e8f5f1;
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 72px;
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 16px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
}

.content {
  padding: 26px;
  display: grid;
  gap: 20px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel,
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.65fr);
  gap: 18px;
}

.panel {
  padding: 18px;
  min-width: 0;
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.sound-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.sound-header h2 {
  margin: 0;
}

.icon-button {
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.icon-button.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafb;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f8fafb;
  font-size: 12px;
}

.status.published {
  color: #0d6b3c;
  border-color: #a9dcc2;
  background: #eefaf3;
}

.status.ai_generated,
.status.in_review {
  color: var(--warning);
  border-color: #f1d49d;
  background: #fff7e8;
}

.status.rejected {
  color: var(--accent-2);
  border-color: #efc1b8;
  background: #fff0ec;
}

.review-list {
  display: grid;
  gap: 12px;
}

.card {
  padding: 16px;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.choices {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.choice {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbfcfd;
}

.choice.correct {
  border-color: #96d4ae;
  background: #edf9f2;
}

.source {
  border-left: 3px solid var(--focus);
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

body[data-app-mode="game"],
body[data-app-mode="staff"] {
  overflow: hidden;
}

body[data-app-mode="game"] .shell,
body[data-app-mode="staff"] .shell {
  height: 100vh;
  min-height: 0;
  grid-template-columns: 160px minmax(0, 1fr);
  overflow: hidden;
}

body[data-app-mode="game"] .sidebar,
body[data-app-mode="staff"] .sidebar {
  padding: 14px 12px;
  gap: 12px;
}

body[data-app-mode="game"] .brand strong,
body[data-app-mode="staff"] .brand strong {
  font-size: 16px;
}

body[data-app-mode="game"] .topbar,
body[data-app-mode="staff"] .topbar {
  min-height: 48px;
  padding: 8px 16px;
}

body[data-app-mode="game"] .topbar h1,
body[data-app-mode="staff"] .topbar h1 {
  font-size: 16px;
}

body[data-app-mode="game"] .content,
body[data-app-mode="staff"] .content {
  height: calc(100vh - 48px);
  overflow: hidden;
  padding: 12px 16px;
}

body[data-app-mode="game"] .game-layout,
body[data-app-mode="staff"] .game-layout {
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

.game-stage {
  position: relative;
  min-height: 512px;
  border: 1px solid #14253a;
  border-radius: 8px;
  overflow: hidden;
  background: #08111e;
  box-shadow: var(--shadow);
  touch-action: none;
  user-select: none;
}

body[data-app-mode="game"] .game-stage,
body[data-app-mode="staff"] .game-stage {
  height: clamp(520px, calc(100vh - 74px), 760px);
  min-height: 0;
}

.screen-shake.hit {
  animation: screen-shake-hit 0.38s ease both;
}

.screen-shake.danger {
  animation: screen-shake-danger 0.46s ease both;
}

.quest-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quest-stats span {
  min-height: 32px;
  display: grid;
  place-items: center;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #f8fafb;
  font-size: 13px;
}

.stat-bar {
  display: grid;
  gap: 5px;
  margin: 10px 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.stat-row strong {
  color: var(--ink);
}

.stat-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe3ea;
}

.stat-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #16a34a;
}

.stat-bar.mp .stat-track span {
  background: #2563eb;
}

.stat-bar.exp .stat-track span {
  background: #d97706;
}

.quest-log {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  font-size: 12px;
  line-height: 1.45;
}

.quest-log div {
  color: var(--muted);
}

.quest-log div::before {
  content: "□";
  margin-right: 6px;
  color: #94a3b8;
}

.quest-log .done {
  color: #146c43;
  font-weight: 700;
}

.quest-log .done::before {
  content: "✓";
  color: #16a34a;
}

.dpad {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dpad button:first-child,
.dpad button:last-child {
  grid-column: 2;
}

.dpad .primary {
  min-width: 0;
  padding-inline: 8px;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 768 / 512;
  image-rendering: pixelated;
  touch-action: none;
}

body[data-app-mode="game"] canvas,
body[data-app-mode="staff"] canvas {
  height: 100%;
  object-fit: fill;
}

.dialogue {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  background: rgba(10, 20, 34, 0.94);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 14px;
  line-height: 1.6;
}

.scene-effect {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: clamp(28px, 5vw, 58px);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 255, 255, 0.45);
  animation: effect-pop 1.1s ease both;
}

.scene-effect.slash::before,
.scene-effect.boss-clear::before {
  content: "";
  position: absolute;
  width: min(72%, 620px);
  height: 16px;
  background: linear-gradient(90deg, transparent, #fff, #7ee4ff, transparent);
  transform: rotate(-18deg);
  box-shadow: 0 0 28px rgba(126, 228, 255, 0.9);
  animation: slash-sweep 0.58s ease both;
}

.scene-effect.equip {
  background: radial-gradient(circle, rgba(255, 239, 153, 0.38), rgba(13, 33, 54, 0.08) 42%, transparent 70%);
}

.scene-effect.shield {
  color: #c9f5ff;
}

.scene-effect.sword {
  color: #fff1a8;
}

.scene-effect.guard {
  color: #bcecff;
  background: radial-gradient(circle, rgba(126, 228, 255, 0.3), transparent 58%);
}

.scene-effect.heal {
  color: #bfffd0;
  background: radial-gradient(circle, rgba(34, 197, 94, 0.28), transparent 58%);
}

.scene-effect.level-up {
  color: #fff1a8;
  background: radial-gradient(circle, rgba(255, 210, 77, 0.34), transparent 62%);
}

.turn-cue {
  position: absolute;
  top: 26px;
  left: 50%;
  z-index: 8;
  translate: -50% 0;
  min-width: min(360px, calc(100% - 36px));
  padding: 12px 20px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  color: white;
  background: rgba(7, 18, 36, 0.92);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.32), 0 0 24px rgba(126, 228, 255, 0.18);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 900;
  text-align: center;
  animation: turn-cue-in 0.74s ease both;
}

.turn-cue.enemy {
  border-color: rgba(255, 183, 170, 0.92);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.32), 0 0 28px rgba(244, 63, 94, 0.32);
}

.turn-cue.magic,
.turn-cue.guard {
  border-color: rgba(188, 236, 255, 0.96);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.32), 0 0 28px rgba(126, 228, 255, 0.42);
}

.turn-cue.victory,
.turn-cue.treasure,
.turn-cue.heal {
  border-color: rgba(255, 241, 168, 0.96);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.32), 0 0 32px rgba(255, 210, 77, 0.44);
}

.damage-layer {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.damage-number {
  position: absolute;
  top: 40%;
  left: 50%;
  translate: -50% -50%;
  min-width: 80px;
  color: #fff;
  font-size: clamp(34px, 8vw, 76px);
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  -webkit-text-stroke: 2px rgba(8, 18, 39, 0.96);
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.36), 0 0 18px rgba(255, 255, 255, 0.48);
  animation: damage-float 0.92s cubic-bezier(.16, .98, .28, 1) both;
}

.damage-number.boss-damage {
  color: #fff1a8;
  font-size: clamp(46px, 10vw, 94px);
  animation-name: damage-critical;
}

.damage-number.player-damage {
  top: 26%;
  left: 28%;
  color: #ffb7aa;
}

.damage-number.heal {
  top: 30%;
  left: 28%;
  color: #bfffd0;
}

.damage-number.mp {
  top: 28%;
  left: 32%;
  color: #bcecff;
  font-size: clamp(26px, 5vw, 46px);
}

.equipment-overlay {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: white;
  background: radial-gradient(circle, rgba(255, 241, 168, 0.26), rgba(8, 17, 30, 0.15) 46%, transparent 70%);
  animation: equipment-fade 1.85s ease both;
}

.equipment-overlay img {
  width: min(128px, 24vw);
  height: min(128px, 24vw);
  object-fit: contain;
  filter: drop-shadow(0 18px 18px rgba(0, 0, 0, 0.42)) drop-shadow(0 0 22px rgba(255, 241, 168, 0.72));
  animation: equipment-rise 1.85s ease both;
}

.equipment-overlay strong {
  position: absolute;
  bottom: 20%;
  padding: 10px 18px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: rgba(8, 18, 39, 0.88);
  font-size: clamp(18px, 3.4vw, 32px);
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.3);
}

.boss-clear-stage {
  position: absolute;
  inset: 0;
  z-index: 11;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
  font-size: clamp(30px, 7vw, 74px);
  font-weight: 1000;
  text-align: center;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.36), 0 0 26px rgba(255, 255, 255, 0.48);
  animation: boss-stage-pop 0.92s ease both;
}

.boss-clear-stage.break {
  background: radial-gradient(circle, rgba(255, 80, 80, 0.26), rgba(8, 17, 30, 0.28) 46%, transparent 72%);
}

.boss-clear-stage.light {
  background: radial-gradient(circle, rgba(126, 228, 255, 0.36), rgba(255, 241, 168, 0.18) 38%, transparent 72%);
}

.boss-clear-stage.clear {
  color: #fff1a8;
  background: radial-gradient(circle, rgba(255, 241, 168, 0.42), rgba(126, 228, 255, 0.18) 45%, rgba(8, 17, 30, 0.18) 72%);
}

.mobile-game-hud {
  display: none;
}

.scene-effect.damage {
  color: #ffb7aa;
  background: rgba(180, 39, 31, 0.18);
}

.scene-effect.boss,
.scene-effect.encounter {
  background: rgba(8, 17, 30, 0.28);
}

.scene-effect.boss-clear {
  background: radial-gradient(circle, rgba(255, 241, 168, 0.34), rgba(8, 17, 30, 0.18) 58%, transparent);
}

@keyframes effect-pop {
  0% {
    opacity: 0;
    transform: scale(0.86);
  }
  18% {
    opacity: 1;
    transform: scale(1.05);
  }
  72% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes slash-sweep {
  0% {
    opacity: 0;
    translate: -42% 36%;
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    translate: 44% -28%;
  }
}

@keyframes screen-shake-hit {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  20% {
    transform: translate3d(-5px, 2px, 0);
  }
  42% {
    transform: translate3d(6px, -3px, 0);
  }
  64% {
    transform: translate3d(-3px, 3px, 0);
  }
  82% {
    transform: translate3d(2px, 0, 0);
  }
}

@keyframes screen-shake-danger {
  0%, 100% {
    transform: translate3d(0, 0, 0);
  }
  12% {
    transform: translate3d(-9px, 4px, 0);
  }
  28% {
    transform: translate3d(10px, -5px, 0);
  }
  46% {
    transform: translate3d(-8px, -3px, 0);
  }
  66% {
    transform: translate3d(6px, 4px, 0);
  }
  84% {
    transform: translate3d(-3px, 0, 0);
  }
}

@keyframes turn-cue-in {
  0% {
    opacity: 0;
    transform: translateY(-18px) scale(0.94);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1.02);
  }
  74% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
}

@keyframes damage-float {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.76);
  }
  18% {
    opacity: 1;
    transform: translateY(-8px) scale(1.16);
  }
  62% {
    opacity: 1;
    transform: translateY(-44px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-76px) scale(0.9);
  }
}

@keyframes damage-critical {
  0% {
    opacity: 0;
    transform: translateY(20px) rotate(-3deg) scale(0.72);
  }
  20% {
    opacity: 1;
    transform: translateY(-14px) rotate(2deg) scale(1.22);
  }
  62% {
    opacity: 1;
    transform: translateY(-54px) rotate(-1deg) scale(1.04);
  }
  100% {
    opacity: 0;
    transform: translateY(-96px) rotate(0) scale(0.9);
  }
}

@keyframes equipment-fade {
  0%, 100% {
    opacity: 0;
  }
  12%, 78% {
    opacity: 1;
  }
}

@keyframes equipment-rise {
  0% {
    opacity: 0;
    transform: translateY(48px) scale(0.62) rotate(-8deg);
  }
  18% {
    opacity: 1;
    transform: translateY(-8px) scale(1.08) rotate(5deg);
  }
  52% {
    transform: translateY(-34px) scale(1) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-70px) scale(0.94);
  }
}

@keyframes boss-stage-pop {
  0% {
    opacity: 0;
    transform: scale(0.86);
  }
  18% {
    opacity: 1;
    transform: scale(1.06);
  }
  72% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

.battle {
  position: absolute;
  inset: 0;
  background: #050914;
  display: block;
  padding: 0;
  animation: battle-in 0.28s ease both;
}

.rpg-battle-screen {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 512px;
  overflow: hidden;
  color: #fff;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.rpg-battle-sky {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 9, 20, 0.18), rgba(5, 9, 20, 0.62)),
    url("/assets/battle-bg.png") center / cover no-repeat;
  transform: scale(1.02);
}

.rpg-battle-screen.boss .rpg-battle-sky {
  filter: saturate(0.95) contrast(1.12);
}

.rpg-battle-screen.guardian .rpg-battle-sky {
  filter: hue-rotate(18deg) saturate(1.08);
}

.rpg-party-window,
.rpg-battle-message,
.rpg-command-window,
.rpg-quiz-window,
.battle-result-window {
  position: absolute;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  background: rgba(8, 18, 39, 0.9);
  box-shadow: 0 8px 0 rgba(0, 0, 0, 0.32), inset 0 0 0 2px rgba(112, 178, 255, 0.22);
}

.rpg-party-window {
  top: 18px;
  left: 18px;
  width: min(310px, calc(100% - 36px));
  min-height: 86px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 5px 12px;
  padding: 12px 14px;
  font-size: 15px;
}

.rpg-party-window strong {
  grid-column: 1 / -1;
  font-size: 17px;
}

.rpg-enemy-stage {
  position: absolute;
  top: 18%;
  left: 50%;
  width: min(540px, 52%);
  height: 42%;
  transform: translateX(-50%);
  display: grid;
  place-items: end center;
}

.rpg-enemy-name {
  position: absolute;
  top: -20px;
  z-index: 4;
  padding: 8px 20px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  background: rgba(8, 18, 39, 0.86);
  font-weight: 800;
  letter-spacing: 0;
}

.rpg-monster {
  position: relative;
  z-index: 2;
  width: clamp(220px, 18vw, 360px);
  height: clamp(220px, 18vw, 360px);
  object-fit: contain;
  margin-top: 0;
  animation: monster-idle 1.35s ease-in-out infinite;
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.42));
  transform-origin: 50% 100%;
}

.rpg-battle-screen.boss .rpg-monster {
  width: clamp(280px, 22vw, 430px);
  height: clamp(280px, 22vw, 430px);
}

.rpg-enemy-shadow {
  position: absolute;
  bottom: 0;
  width: min(260px, 58%);
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
  filter: blur(3px);
}

.enemy-hp {
  position: absolute;
  z-index: 3;
  bottom: -28px;
  width: min(280px, 90%);
  display: grid;
  gap: 5px;
  padding: 8px 10px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background: rgba(8, 18, 39, 0.82);
  font-size: 12px;
  font-weight: 800;
}

.enemy-hp-track {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.18);
}

.enemy-hp-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #f97316, #facc15);
}

.rpg-battle-message {
  left: 18px;
  right: 18px;
  bottom: 20px;
  min-height: 76px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 750;
  line-height: 1.45;
}

.rpg-command-window {
  right: 20px;
  bottom: 106px;
  width: 220px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.rpg-command-window button,
.rpg-choice-grid button {
  min-height: 50px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-align: left;
}

.rpg-command-window button:hover,
.rpg-choice-grid button:hover {
  background: rgba(126, 228, 255, 0.22);
}

.rpg-quiz-window {
  left: 18px;
  right: 18px;
  bottom: 106px;
  padding: 14px;
}

.rpg-hint {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 241, 168, 0.18);
  color: #fff3aa;
  line-height: 1.45;
}

.rpg-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.battle-result-window {
  left: 50%;
  bottom: 110px;
  z-index: 8;
  width: min(560px, calc(100% - 40px));
  transform: translateX(-50%);
  display: grid;
  gap: 12px;
  padding: 18px;
  color: #fff;
}

.result-title {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

.result-lines,
.level-result {
  display: grid;
  gap: 7px;
  font-size: 16px;
  line-height: 1.5;
}

.level-result {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.level-result strong {
  color: #fff3aa;
}

.battle-result-window button {
  min-height: 48px;
  justify-self: end;
  min-width: 180px;
  font-weight: 800;
}

.battle-log {
  position: absolute;
  left: 18px;
  top: 118px;
  width: min(260px, 35%);
  display: grid;
  gap: 5px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.battle-log div {
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(8, 18, 39, 0.54);
}

@keyframes battle-in {
  from {
    opacity: 0;
    transform: scale(1.03);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes monster-idle {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.game-side {
  display: grid;
  gap: 14px;
  align-content: start;
}

.log {
  max-height: 260px;
  overflow: auto;
  display: grid;
  gap: 8px;
  font-size: 13px;
}

.log div {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

@media (max-width: 920px) {
  body[data-app-mode="game"],
  body[data-app-mode="staff"] {
    overflow: auto;
  }

  body[data-app-mode="game"] .shell,
  body[data-app-mode="staff"] .shell {
    height: auto;
    min-height: 100vh;
    grid-template-columns: 1fr;
    overflow: visible;
  }

  body[data-app-mode="game"] .content,
  body[data-app-mode="staff"] .content {
    height: auto;
    overflow: visible;
  }

  body[data-app-mode="game"] .game-layout,
  body[data-app-mode="staff"] .game-layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  body[data-app-mode="game"] .game-stage,
  body[data-app-mode="staff"] .game-stage {
    height: auto;
  }

  .shell,
  .grid,
  .game-layout,
  .launcher-hero {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content {
    padding: 12px;
  }

  .game-stage {
    min-height: auto;
  }

  .mobile-game-hud {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: block;
    pointer-events: none;
  }

  .mobile-status-strip {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    min-height: 36px;
    display: grid;
    grid-template-columns: auto repeat(3, minmax(0, 1fr));
    align-items: center;
    gap: 6px;
    padding: 7px 9px;
    border: 2px solid rgba(255, 255, 255, 0.84);
    border-radius: 8px;
    color: #fff;
    background: rgba(7, 18, 36, 0.82);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.24);
    font-size: 12px;
    pointer-events: none;
  }

  .mobile-status-strip span,
  .mobile-status-strip strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-action-bar {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    pointer-events: auto;
  }

  .mobile-action-bar button {
    min-height: 46px;
    padding: 0 6px;
    border: 2px solid rgba(255, 255, 255, 0.84);
    border-radius: 8px;
    color: #fff;
    background: rgba(7, 18, 36, 0.86);
    box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
    font-size: 13px;
    font-weight: 900;
  }

  canvas {
    height: auto;
    aspect-ratio: 768 / 512;
  }

  body[data-app-mode="game"] canvas,
  body[data-app-mode="staff"] canvas {
    height: auto;
    object-fit: fill;
  }

  .dpad button {
    min-height: 46px;
  }
}

@media (max-width: 560px) {
  .content,
  .topbar {
    padding: 16px;
  }

  .metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }

  canvas {
    height: auto;
  }

  body[data-app-mode="game"] canvas,
  body[data-app-mode="staff"] canvas {
    height: auto;
  }

  .game-stage {
    min-height: auto;
  }

  .rpg-party-window {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    min-height: 64px;
    grid-template-columns: repeat(3, auto);
    font-size: 12px;
    padding: 8px 10px;
  }

  .rpg-party-window strong {
    font-size: 14px;
  }

  .rpg-enemy-stage {
    top: 72px;
    width: 72%;
    height: 170px;
  }

  .rpg-monster,
  .rpg-battle-screen.boss .rpg-monster {
    width: 150px;
    height: 150px;
  }

  .rpg-command-window,
  .rpg-quiz-window,
  .battle-result-window {
    left: 10px;
    right: 10px;
    bottom: 88px;
    width: auto;
    transform: none;
  }

  .battle-result-window {
    padding: 12px;
  }

  .result-title {
    font-size: 18px;
  }

  .result-lines,
  .level-result {
    font-size: 13px;
  }

  .rpg-choice-grid {
    grid-template-columns: 1fr;
  }

  .battle-log {
    display: none;
  }

  .rpg-battle-message {
    left: 10px;
    right: 10px;
    bottom: 10px;
    min-height: 70px;
    font-size: 14px;
  }

  .turn-cue {
    top: 56px;
    min-width: calc(100% - 20px);
    padding: 9px 12px;
    font-size: 18px;
  }

  .damage-number.player-damage,
  .damage-number.heal,
  .damage-number.mp {
    left: 50%;
  }

  .equipment-overlay strong {
    bottom: 28%;
    max-width: calc(100% - 28px);
    text-align: center;
  }
}
