:root {
  --ink: #f7f3eb;
  --muted: rgba(247, 243, 235, 0.78);
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(46, 89, 132, 0.58);
  --panel-strong: rgba(44, 88, 128, 0.82);
  --field-top: #2d58a8;
  --field-mid: #5f9fd1;
  --field-bottom: #59c344;
  --ground-dark: #a56414;
  --ground-light: #c68727;
  --success: #8bf28d;
  --warning: #ffe07a;
  --danger: #ff8787;
  --shadow: 0 22px 60px rgba(9, 23, 49, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Outfit", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(180deg, #1f4b8f, #4d8fc8 52%, #7ac65c 52%, #67b94f 100%);
}

.app-shell {
  width: min(1460px, calc(100vw - 24px));
  margin: 10px auto 24px;
  display: grid;
  gap: 12px;
}

.hud-card,
.control-card,
.battle-card {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.24);
  box-shadow: var(--shadow);
}

.hud-card,
.control-card {
  background: rgba(18, 41, 76, 0.74);
  backdrop-filter: blur(10px);
}

.hud-card {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  padding: 18px 22px;
  border-radius: 28px;
}

.eyebrow,
.label,
.subcopy,
.status-message,
.meter-label {
  color: var(--muted);
}

.eyebrow,
.label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
}

h1 {
  margin: 4px 0 10px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.9;
}

.subcopy,
.status-message {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.5;
}

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

.stat {
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

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

.battle-card {
  min-height: 900px;
  border-radius: 18px;
  --battle-sky-top: rgba(45, 88, 168, 0.98);
  --battle-sky-mid: rgba(86, 152, 206, 0.97);
  --battle-horizon: rgba(92, 197, 70, 0.98);
  --battle-ground-top: rgba(78, 180, 53, 0.94);
  --battle-ground-base: rgba(166, 103, 20, 0.98);
  --battle-cloud-left: rgba(255, 255, 255, 0.9);
  --battle-cloud-right: rgba(255, 255, 255, 0.92);
  --battle-pattern: rgba(255, 210, 99, 0.22);
  background:
    linear-gradient(180deg, var(--battle-sky-top) 0 25%, var(--battle-sky-mid) 25% 90%, var(--battle-horizon) 90% 100%);
}

.battlefield-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 6% 22%, var(--battle-cloud-left), transparent 9%),
    radial-gradient(circle at 89% 37%, var(--battle-cloud-right), transparent 9%),
    linear-gradient(180deg, transparent 0 90%, var(--battle-ground-top) 90% 93%, var(--battle-ground-base) 93% 100%);
}

.battlefield-backdrop::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 110px;
  background:
    linear-gradient(135deg, var(--battle-pattern) 25%, transparent 25%) 0 0 / 32px 32px,
    linear-gradient(225deg, var(--battle-pattern) 25%, transparent 25%) 0 0 / 32px 32px,
    linear-gradient(45deg, var(--battle-pattern) 25%, transparent 25%) 0 0 / 32px 32px,
    linear-gradient(315deg, var(--battle-pattern) 25%, transparent 25%) 0 0 / 32px 32px,
    linear-gradient(180deg, var(--ground-light), var(--ground-dark));
  opacity: 0.95;
}

.battle-card[data-stage-theme="forest"] {
  --battle-sky-top: rgba(37, 96, 97, 0.98);
  --battle-sky-mid: rgba(70, 145, 121, 0.97);
  --battle-horizon: rgba(58, 148, 61, 0.98);
  --battle-ground-top: rgba(62, 155, 61, 0.95);
  --battle-ground-base: rgba(103, 84, 34, 0.98);
  --battle-cloud-left: rgba(217, 247, 219, 0.38);
  --battle-cloud-right: rgba(230, 255, 225, 0.28);
  --battle-pattern: rgba(155, 214, 116, 0.2);
}

.battle-card[data-stage-theme="mountain"] {
  --battle-sky-top: rgba(44, 56, 110, 0.99);
  --battle-sky-mid: rgba(96, 112, 157, 0.97);
  --battle-horizon: rgba(121, 109, 108, 0.98);
  --battle-ground-top: rgba(117, 118, 104, 0.95);
  --battle-ground-base: rgba(99, 74, 49, 0.98);
  --battle-cloud-left: rgba(255, 246, 205, 0.32);
  --battle-cloud-right: rgba(227, 231, 255, 0.26);
  --battle-pattern: rgba(214, 209, 150, 0.18);
}

.battle-card[data-stage-theme="cave"] {
  --battle-sky-top: rgba(28, 35, 66, 0.99);
  --battle-sky-mid: rgba(61, 73, 104, 0.98);
  --battle-horizon: rgba(79, 87, 84, 0.98);
  --battle-ground-top: rgba(92, 103, 76, 0.92);
  --battle-ground-base: rgba(80, 61, 45, 0.98);
  --battle-cloud-left: rgba(205, 227, 255, 0.14);
  --battle-cloud-right: rgba(247, 242, 202, 0.1);
  --battle-pattern: rgba(168, 162, 127, 0.16);
}

.battle-card[data-stage-theme="tower"] {
  --battle-sky-top: rgba(65, 52, 98, 0.99);
  --battle-sky-mid: rgba(104, 83, 132, 0.98);
  --battle-horizon: rgba(101, 95, 124, 0.98);
  --battle-ground-top: rgba(85, 107, 82, 0.9);
  --battle-ground-base: rgba(83, 60, 78, 0.98);
  --battle-cloud-left: rgba(215, 215, 255, 0.18);
  --battle-cloud-right: rgba(255, 222, 248, 0.16);
  --battle-pattern: rgba(181, 152, 214, 0.16);
}

.battle-card[data-stage-theme="gym-rock"] {
  --battle-sky-top: rgba(79, 73, 79, 0.99);
  --battle-sky-mid: rgba(118, 112, 109, 0.98);
  --battle-horizon: rgba(123, 112, 90, 0.98);
  --battle-ground-top: rgba(132, 117, 73, 0.94);
  --battle-ground-base: rgba(92, 72, 47, 0.98);
  --battle-cloud-left: rgba(255, 245, 211, 0.16);
  --battle-cloud-right: rgba(237, 237, 237, 0.18);
  --battle-pattern: rgba(205, 177, 105, 0.16);
}

.battle-card[data-stage-theme="gym-water"] {
  --battle-sky-top: rgba(40, 81, 142, 0.99);
  --battle-sky-mid: rgba(75, 155, 198, 0.98);
  --battle-horizon: rgba(67, 172, 184, 0.98);
  --battle-ground-top: rgba(46, 145, 142, 0.94);
  --battle-ground-base: rgba(46, 97, 116, 0.98);
  --battle-cloud-left: rgba(228, 249, 255, 0.26);
  --battle-cloud-right: rgba(255, 255, 255, 0.2);
  --battle-pattern: rgba(129, 230, 241, 0.16);
}

.battle-card[data-stage-theme="gym-electric"] {
  --battle-sky-top: rgba(70, 78, 136, 0.99);
  --battle-sky-mid: rgba(122, 143, 205, 0.98);
  --battle-horizon: rgba(214, 194, 72, 0.98);
  --battle-ground-top: rgba(218, 186, 56, 0.94);
  --battle-ground-base: rgba(137, 97, 28, 0.98);
  --battle-cloud-left: rgba(255, 252, 214, 0.22);
  --battle-cloud-right: rgba(247, 243, 212, 0.18);
  --battle-pattern: rgba(255, 239, 140, 0.18);
}

.battle-card[data-stage-theme="gym-grass"] {
  --battle-sky-top: rgba(40, 89, 78, 0.99);
  --battle-sky-mid: rgba(73, 142, 105, 0.98);
  --battle-horizon: rgba(122, 178, 74, 0.98);
  --battle-ground-top: rgba(106, 178, 72, 0.94);
  --battle-ground-base: rgba(103, 90, 37, 0.98);
  --battle-cloud-left: rgba(235, 255, 220, 0.2);
  --battle-cloud-right: rgba(233, 255, 205, 0.16);
  --battle-pattern: rgba(182, 228, 124, 0.18);
}

.battle-card[data-stage-theme="gym-psychic"] {
  --battle-sky-top: rgba(86, 63, 126, 0.99);
  --battle-sky-mid: rgba(180, 117, 177, 0.98);
  --battle-horizon: rgba(218, 180, 109, 0.98);
  --battle-ground-top: rgba(169, 176, 91, 0.94);
  --battle-ground-base: rgba(117, 81, 50, 0.98);
  --battle-cloud-left: rgba(255, 232, 255, 0.2);
  --battle-cloud-right: rgba(251, 221, 255, 0.18);
  --battle-pattern: rgba(225, 170, 224, 0.18);
}

.battle-card[data-stage-theme="gym-fire"] {
  --battle-sky-top: rgba(118, 61, 42, 0.99);
  --battle-sky-mid: rgba(205, 118, 76, 0.98);
  --battle-horizon: rgba(226, 178, 88, 0.98);
  --battle-ground-top: rgba(184, 127, 58, 0.94);
  --battle-ground-base: rgba(110, 69, 39, 0.98);
  --battle-cloud-left: rgba(255, 236, 214, 0.18);
  --battle-cloud-right: rgba(255, 224, 191, 0.14);
  --battle-pattern: rgba(255, 190, 120, 0.18);
}

.battle-card[data-stage-theme="gym-ground"] {
  --battle-sky-top: rgba(98, 85, 61, 0.99);
  --battle-sky-mid: rgba(160, 136, 92, 0.98);
  --battle-horizon: rgba(181, 169, 102, 0.98);
  --battle-ground-top: rgba(156, 144, 74, 0.94);
  --battle-ground-base: rgba(106, 82, 47, 0.98);
  --battle-cloud-left: rgba(251, 240, 214, 0.16);
  --battle-cloud-right: rgba(242, 234, 203, 0.12);
  --battle-pattern: rgba(212, 190, 131, 0.16);
}

.battle-card[data-stage-theme="gym-poison"] {
  --battle-sky-top: rgba(92, 54, 110, 0.99);
  --battle-sky-mid: rgba(146, 92, 146, 0.98);
  --battle-horizon: rgba(153, 130, 92, 0.98);
  --battle-ground-top: rgba(128, 154, 77, 0.94);
  --battle-ground-base: rgba(98, 72, 47, 0.98);
  --battle-cloud-left: rgba(248, 223, 255, 0.18);
  --battle-cloud-right: rgba(236, 222, 255, 0.14);
  --battle-pattern: rgba(196, 149, 217, 0.18);
}

.battle-card[data-stage-theme="city"] {
  --battle-sky-top: rgba(123, 86, 116, 0.99);
  --battle-sky-mid: rgba(197, 144, 132, 0.98);
  --battle-horizon: rgba(171, 158, 103, 0.98);
  --battle-ground-top: rgba(126, 138, 90, 0.93);
  --battle-ground-base: rgba(123, 92, 56, 0.98);
  --battle-cloud-left: rgba(255, 235, 216, 0.26);
  --battle-cloud-right: rgba(255, 241, 224, 0.2);
  --battle-pattern: rgba(227, 194, 127, 0.16);
}

.battle-card[data-stage-theme="coast"] {
  --battle-sky-top: rgba(45, 98, 145, 0.99);
  --battle-sky-mid: rgba(119, 182, 214, 0.98);
  --battle-horizon: rgba(90, 174, 151, 0.98);
  --battle-ground-top: rgba(102, 180, 135, 0.94);
  --battle-ground-base: rgba(166, 129, 63, 0.98);
  --battle-cloud-left: rgba(242, 251, 255, 0.24);
  --battle-cloud-right: rgba(228, 255, 255, 0.22);
  --battle-pattern: rgba(243, 222, 142, 0.18);
}

.battle-card[data-stage-theme="safari"] {
  --battle-sky-top: rgba(78, 122, 89, 0.99);
  --battle-sky-mid: rgba(135, 179, 114, 0.98);
  --battle-horizon: rgba(183, 180, 92, 0.98);
  --battle-ground-top: rgba(143, 181, 79, 0.94);
  --battle-ground-base: rgba(130, 96, 43, 0.98);
  --battle-cloud-left: rgba(252, 245, 212, 0.18);
  --battle-cloud-right: rgba(241, 255, 212, 0.14);
  --battle-pattern: rgba(219, 201, 122, 0.18);
}

.battle-card[data-stage-theme="power"] {
  --battle-sky-top: rgba(62, 77, 102, 0.99);
  --battle-sky-mid: rgba(105, 125, 150, 0.98);
  --battle-horizon: rgba(191, 173, 79, 0.98);
  --battle-ground-top: rgba(173, 168, 73, 0.94);
  --battle-ground-base: rgba(100, 84, 44, 0.98);
  --battle-cloud-left: rgba(231, 240, 255, 0.16);
  --battle-cloud-right: rgba(255, 246, 210, 0.14);
  --battle-pattern: rgba(230, 214, 125, 0.18);
}

.battle-card[data-stage-theme="mansion"] {
  --battle-sky-top: rgba(89, 69, 67, 0.99);
  --battle-sky-mid: rgba(145, 103, 90, 0.98);
  --battle-horizon: rgba(173, 144, 97, 0.98);
  --battle-ground-top: rgba(145, 112, 71, 0.94);
  --battle-ground-base: rgba(93, 66, 43, 0.98);
  --battle-cloud-left: rgba(255, 230, 217, 0.15);
  --battle-cloud-right: rgba(255, 215, 202, 0.12);
  --battle-pattern: rgba(211, 173, 129, 0.16);
}

.battle-card[data-stage-theme="league"] {
  --battle-sky-top: rgba(43, 58, 102, 0.99);
  --battle-sky-mid: rgba(96, 122, 176, 0.98);
  --battle-horizon: rgba(213, 188, 102, 0.98);
  --battle-ground-top: rgba(170, 152, 75, 0.94);
  --battle-ground-base: rgba(90, 74, 48, 0.98);
  --battle-cloud-left: rgba(239, 244, 255, 0.18);
  --battle-cloud-right: rgba(255, 246, 214, 0.14);
  --battle-pattern: rgba(223, 205, 128, 0.18);
}

.battle-card[data-stage-theme="ice-cave"] {
  --battle-sky-top: rgba(94, 133, 168, 0.99);
  --battle-sky-mid: rgba(160, 205, 228, 0.98);
  --battle-horizon: rgba(183, 225, 231, 0.98);
  --battle-ground-top: rgba(154, 213, 220, 0.94);
  --battle-ground-base: rgba(111, 149, 170, 0.98);
  --battle-cloud-left: rgba(246, 252, 255, 0.2);
  --battle-cloud-right: rgba(225, 243, 255, 0.18);
  --battle-pattern: rgba(207, 238, 255, 0.18);
}

.battle-topbar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 22px 0;
}

.sound-panel,
.ad-panel,
.target-overlay,
.typing-panel,
.roster-panel {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sound-panel {
  width: min(520px, 54vw);
  padding: 18px 22px;
  border-radius: 24px;
}

.sound-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  align-items: center;
  gap: 12px;
}

.sound-row + .sound-row {
  margin-top: 18px;
}

.sound-row span {
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.sound-row input[type="range"] {
  width: 100%;
}

.ad-panel {
  width: min(500px, 32vw);
  padding: 18px 22px;
  border-radius: 0 0 0 24px;
  text-align: right;
}

.ad-panel strong {
  display: block;
  font-size: clamp(1.3rem, 2vw, 2.4rem);
}

.ad-panel p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.battlefield {
  position: relative;
  height: 900px;
  isolation: isolate;
  z-index: 6;
}

.inventory-bar {
  position: absolute;
  left: 50%;
  width: min(720px, calc(100% - 120px));
  bottom: 2px;
  transform: translateX(-50%);
  z-index: 10;
  padding: 4px 6px 5px;
  border-radius: 14px;
  background: rgba(19, 35, 58, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
}

.target-overlay {
  position: absolute;
  left: 50%;
  top: 53%;
  z-index: 4;
  width: min(860px, calc(100% - 340px));
  transform: translate(-50%, -50%);
  padding: 26px 32px 30px;
  border-radius: 8px;
  text-align: center;
}

.overlay-labels,
.word-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.combo {
  font-weight: 800;
  color: #ffe996;
}

.target-word {
  margin-top: 18px;
  min-height: 72px;
  color: rgba(255, 255, 255, 0.95);
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(1.8rem, 3.4vw, 3.2rem);
  letter-spacing: 0.04em;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 0 12px rgba(255, 255, 255, 0.08);
  word-break: break-word;
}

.target-japanese {
  margin-top: 14px;
  min-height: 74px;
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(2.2rem, 4.5vw, 4.4rem);
  line-height: 1.25;
  color: rgba(255, 248, 236, 0.98);
  text-shadow:
    0 2px 0 rgba(0, 0, 0, 0.4),
    0 0 12px rgba(255, 255, 255, 0.08);
}

.target-char {
  color: rgba(255, 255, 255, 0.92);
  transition: color 100ms ease-out, text-shadow 100ms ease-out;
}

.target-char.correct {
  color: var(--success);
  text-shadow: 0 0 10px rgba(139, 242, 141, 0.5);
}

.target-char.active {
  color: var(--warning);
  text-shadow: 0 0 10px rgba(255, 224, 122, 0.48);
}

.target-char.error {
  color: var(--danger);
  text-shadow: 0 0 10px rgba(255, 135, 135, 0.44);
}

.sr-only-input {
  position: absolute;
  opacity: 0.001;
  pointer-events: none;
  width: 1px;
  height: 1px;
  inset: auto;
}

.base {
  position: absolute;
  bottom: 112px;
  z-index: 2;
}

.base-battle-hp {
  position: absolute;
  left: 50%;
  bottom: 232px;
  transform: translateX(-50%);
  min-width: 88px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 29, 52, 0.72);
  color: #fff7e8;
  text-align: center;
  font-family: "DotGothic16", sans-serif;
  font-size: 0.95rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.player-base {
  left: 28px;
}

.enemy-base {
  right: 28px;
}

.base-core {
  width: 132px;
  height: 220px;
  border-radius: 0;
  border: 8px solid rgba(0, 0, 0, 0.38);
  border-bottom-width: 10px;
  background:
    radial-gradient(circle at 50% 74%, #000 0 16%, transparent 17%),
    linear-gradient(180deg, #9796a3 0 100%);
  display: grid;
  place-items: start center;
  padding-top: 16px;
  font-family: "DotGothic16", sans-serif;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.base-core::before,
.base-core::after {
  content: "";
  position: absolute;
  top: -18px;
  width: 24px;
  height: 38px;
  background: #868694;
  border: 8px solid rgba(0, 0, 0, 0.38);
  border-bottom: none;
}

.base-core::before {
  left: 18px;
}

.base-core::after {
  right: 18px;
}

.base-core span {
  width: 84px;
  text-align: center;
}

.battle-stats {
  position: absolute;
  bottom: 300px;
  z-index: 7;
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(1.8rem, 3vw, 3rem);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.player-stats {
  left: 78px;
}

.enemy-stats {
  right: 78px;
}

.battle-points-display {
  position: absolute;
  top: 210px;
  right: 36px;
  z-index: 7;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 29, 52, 0.72);
  color: #fff7e8;
  font-family: "DotGothic16", sans-serif;
  font-size: 1rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.selection-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
  background: rgba(11, 23, 42, 0.48);
  backdrop-filter: blur(8px);
}

.selection-overlay.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.selection-card {
  width: min(760px, calc(100% - 40px));
  max-height: calc(100vh - 56px);
  padding: 24px;
  border-radius: 24px;
  background: rgba(24, 52, 89, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.selection-card.stage-choice {
  width: min(1260px, calc(100% - 36px));
  display: flex;
  flex-direction: column;
}

.selection-card.team-choice {
  display: flex;
  flex-direction: column;
}

.selection-card.scroll-choice {
  display: flex;
  flex-direction: column;
}

.selection-card h2 {
  margin: 8px 0 10px;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.stage-view-toggle {
  display: inline-flex;
  gap: 8px;
  margin: 4px 0 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(9, 25, 48, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.stage-view-toggle.hidden {
  display: none;
}

.stage-view-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.stage-view-button.selected {
  background: rgba(238, 163, 43, 0.96);
  border-color: rgba(255, 240, 208, 0.45);
  color: #fffdf7;
}

.stage-view-button:hover,
.stage-view-button:focus-visible {
  transform: translateY(-1px);
}

.selection-options {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.selection-card.team-choice .selection-options {
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 8px;
  overflow-y: auto;
}

.selection-card.stage-choice .selection-options {
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 8px;
  overflow-y: auto;
}

.selection-card.scroll-choice .selection-options {
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 8px;
  overflow-y: auto;
}

.selection-options.hidden {
  display: none;
}

.stage-map {
  position: relative;
  margin-top: 18px;
  width: 100%;
  height: min(66vh, 720px);
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(106, 176, 44, 0.98), rgba(116, 187, 39, 0.98));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.stage-map::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 92% 8%, rgba(132, 169, 233, 0.94), transparent 18%),
    linear-gradient(180deg, transparent 0 67%, rgba(104, 147, 220, 0.88) 67% 100%);
  opacity: 0.95;
}

.stage-map::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 75% 23%, rgba(70, 112, 39, 0.38), transparent 8%);
  mix-blend-mode: multiply;
}

.stage-map-path {
  position: absolute;
  z-index: 1;
  border-radius: 22px;
  background: rgba(238, 235, 171, 0.82);
  box-shadow: inset 0 0 0 1px rgba(118, 115, 61, 0.08);
}

.stage-map-node {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  color: #fff7dd;
  cursor: pointer;
  padding: 0;
  transform: translate(-50%, -50%);
  font: inherit;
}

.stage-map-node::before {
  content: "";
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5f8ff, #5db9ff 55%, #1b5f90 100%);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.46),
    0 0 0 7px rgba(29, 77, 129, 0.32),
    0 6px 16px rgba(10, 22, 46, 0.28);
}

.stage-map-node span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(241, 145, 10, 0.96);
  color: #fff9ec;
  font-family: "DotGothic16", sans-serif;
  font-size: clamp(0.8rem, 1.1vw, 1.05rem);
  line-height: 1.2;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}

.stage-map-node span em {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 248, 220, 0.2);
  color: #fffbd7;
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.stage-map-node span em.clear {
  background: rgba(124, 223, 142, 0.24);
  color: #eaffea;
}

.stage-map-node.current span {
  background: rgba(232, 87, 48, 0.96);
}

.stage-map-node.new-stage::before {
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.58),
    0 0 0 9px rgba(255, 226, 86, 0.42),
    0 0 22px rgba(255, 213, 74, 0.7),
    0 6px 16px rgba(10, 22, 46, 0.32);
}

.stage-map-node.new-stage span {
  background: rgba(255, 170, 29, 0.98);
  box-shadow:
    0 0 0 1px rgba(255, 244, 194, 0.18),
    0 6px 14px rgba(0, 0, 0, 0.18),
    0 0 18px rgba(255, 203, 80, 0.24);
}

.stage-map-node.cleared-stage span {
  box-shadow:
    0 0 0 1px rgba(170, 243, 181, 0.16),
    0 6px 14px rgba(0, 0, 0, 0.18);
}

.stage-map-node:hover span,
.stage-map-node:focus-visible span {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.stage-map-node:hover::before,
.stage-map-node:focus-visible::before {
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.56),
    0 0 0 8px rgba(255, 210, 93, 0.34),
    0 6px 16px rgba(10, 22, 46, 0.32);
}

.stage-map-node[disabled] {
  cursor: default;
}

.stage-map-node.hidden {
  display: none !important;
}

.selection-option {
  appearance: none;
  width: 100%;
  padding: 14px 12px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: center;
}

.selection-option.selected {
  border-color: rgba(139, 242, 141, 0.62);
  background: rgba(79, 170, 110, 0.18);
}

.selection-option.new-stage {
  position: relative;
  border-color: rgba(255, 215, 115, 0.48);
  background:
    linear-gradient(180deg, rgba(255, 187, 70, 0.18), rgba(255, 255, 255, 0.08));
  box-shadow: 0 0 0 1px rgba(255, 224, 125, 0.08), 0 10px 22px rgba(255, 183, 58, 0.12);
}

.selection-option.cleared-stage {
  border-color: rgba(124, 223, 142, 0.42);
  box-shadow: 0 0 0 1px rgba(174, 241, 176, 0.08), 0 10px 22px rgba(72, 180, 96, 0.08);
}

.selection-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  margin: 0 auto 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 170, 29, 0.96);
  color: #fffdf6;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.selection-badge.clear {
  background: rgba(76, 186, 96, 0.96);
}

.selection-option img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  image-rendering: pixelated;
}

.selection-option strong {
  display: block;
  margin-top: 8px;
  font-size: 1rem;
}

.selection-option span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

#selection-confirm {
  margin-top: 18px;
  position: sticky;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 14px 26px rgba(8, 18, 36, 0.3);
}

.selection-card.team-choice #selection-confirm {
  align-self: stretch;
}

@media (max-height: 900px) {
  .selection-card {
    max-height: calc(100vh - 32px);
  }
}

.control-card {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 14px;
  padding: 18px;
  border-radius: 28px;
}

.typing-panel,
.roster-panel {
  padding: 20px;
  border-radius: 24px;
}

.compact-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.meter-row {
  display: grid;
  gap: 10px;
}

.meter {
  height: 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.meter-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #ffe07a, #ff995c);
  transition: width 120ms ease-out;
}

.roster {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.roster-bar {
  margin-top: 0;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 3px;
}

.roster-card {
  appearance: none;
  position: relative;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease-out, border-color 120ms ease-out, background 120ms ease-out;
}

.roster-bar .roster-card {
  grid-template-columns: 1fr;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 78px;
  padding: 4px 4px 18px;
  text-align: center;
}

.roster-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(255, 224, 122, 0.45);
  background: rgba(255, 255, 255, 0.14);
}

.roster-card:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.roster-card.ready {
  border-color: rgba(139, 242, 141, 0.45);
  background: rgba(79, 170, 110, 0.16);
}

.roster-card img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  image-rendering: pixelated;
}

.roster-bar .roster-card img {
  width: 52px;
  height: 52px;
}

.roster-bar .roster-card .roster-meta strong,
.roster-bar .roster-card .roster-meta span {
  display: none;
}

.roster-card strong {
  display: block;
  font-size: 0.95rem;
}

.roster-card span {
  color: var(--muted);
  font-size: 0.78rem;
}

.roster-cost {
  position: absolute;
  right: 4px;
  bottom: 2px;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(12, 24, 46, 0.82);
  color: #ffe996;
  font-size: 0.56rem;
  font-weight: 700;
}

.roster-key {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  background: rgba(17, 31, 56, 0.96);
  color: #fff3b0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  font-size: 0.56rem;
  font-weight: 800;
  position: absolute;
  left: 4px;
  bottom: 2px;
}

.restart-button {
  margin-top: 18px;
  width: 100%;
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  color: white;
  background: linear-gradient(90deg, #2e8b57, #1d6a8f);
  cursor: pointer;
}

.secondary-button {
  margin-top: 10px;
  align-self: start;
  width: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.8rem;
  color: rgba(255, 244, 232, 0.92);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.status-message {
  margin-top: 14px;
}

.unit {
  position: absolute;
  bottom: 96px;
  width: 82px;
  z-index: 8;
  transform: translateX(-50%);
}

.unit-body {
  position: relative;
  display: grid;
  justify-items: center;
}

.unit img {
  width: 82px;
  height: 82px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.15));
}

.unit.player img {
  transform: scaleX(-1);
}

.unit.enemy img {
  transform: scaleX(1);
}

.unit.attacking .unit-body {
  animation: unitAttackShake 180ms ease-out;
}

.health {
  width: 60px;
  height: 7px;
  margin-bottom: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  overflow: hidden;
}

.health-fill {
  height: 100%;
  background: linear-gradient(90deg, #51b36d, #9eea6c);
}

.impact {
  position: absolute;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 146, 43, 0.7);
  box-shadow: 0 0 0 12px rgba(255, 146, 43, 0.14);
  animation: burst 0.28s ease-out forwards;
  pointer-events: none;
}

.effectiveness-text {
  position: absolute;
  z-index: 9;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border-radius: 999px;
  font-family: "DotGothic16", sans-serif;
  font-size: 0.72rem;
  color: #fffdf2;
  background: rgba(22, 34, 58, 0.82);
  pointer-events: none;
  animation: effectivenessPop 0.52s ease-out forwards;
}

.effectiveness-text.super {
  background: rgba(226, 103, 44, 0.92);
}

.effectiveness-text.weak {
  background: rgba(58, 109, 196, 0.9);
}

.effectiveness-text.immune {
  background: rgba(90, 90, 110, 0.9);
}

@keyframes burst {
  from {
    opacity: 1;
    transform: scale(0.4);
  }
  to {
    opacity: 0;
    transform: scale(1.8);
  }
}

@keyframes effectivenessPop {
  from {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.9);
  }
  18% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: translate(-50%, -90%) scale(1);
  }
}

@keyframes unitAttackShake {
  0% {
    transform: translateX(0) scale(1);
  }
  25% {
    transform: translateX(-4px) scale(1.03);
  }
  50% {
    transform: translateX(6px) scale(0.98);
  }
  75% {
    transform: translateX(-3px) scale(1.02);
  }
  100% {
    transform: translateX(0) scale(1);
  }
}

@media (max-width: 1100px) {
  .battle-card {
    min-height: 760px;
  }

  .battlefield {
    height: 760px;
  }

  .target-overlay {
    width: min(720px, calc(100% - 220px));
  }

  .ad-panel {
    display: none;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100vw, calc(100vw - 12px));
    margin: 6px auto 18px;
  }

  .hud-card,
  .control-card {
    grid-template-columns: 1fr;
  }

  .battle-card {
    min-height: 620px;
  }

  .battlefield {
    height: 620px;
  }

  .battle-topbar {
    padding: 12px 12px 0;
  }

  .sound-panel {
    width: min(100%, 420px);
    padding: 14px 16px;
  }

  .sound-row {
    grid-template-columns: 92px 1fr;
  }

  .sound-row span {
    font-size: 2rem;
  }

  .target-overlay {
    width: calc(100% - 60px);
    top: 50%;
    padding: 20px;
  }

  .inventory-bar {
    left: 50%;
    width: calc(100% - 24px);
    bottom: 2px;
    padding: 4px;
  }

  .roster-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .base {
    bottom: 104px;
  }

  .base-core {
    width: 92px;
    height: 160px;
    font-size: 0.64rem;
  }

  .base-battle-hp {
    bottom: 170px;
    min-width: 70px;
    font-size: 0.72rem;
  }

  .battle-stats {
    bottom: 230px;
    font-size: 1.8rem;
  }

  .battle-points-display {
    top: 164px;
    right: 12px;
    font-size: 0.72rem;
    padding: 5px 8px;
  }

  .selection-options {
    grid-template-columns: 1fr;
  }

  .player-stats {
    left: 28px;
  }

  .enemy-stats {
    right: 28px;
  }

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

  .unit {
    bottom: 94px;
    width: 70px;
  }

  .unit img {
    width: 70px;
    height: 70px;
  }
}
