:root {
  color-scheme: dark;
  --bg: #05070d;
  --ink: #f8fbff;
  --muted: #a6b1c1;
  --cyan: #45e0ff;
  --mint: #4dffb1;
  --gold: #ffd166;
  --rose: #ff4f78;
  --violet: #7c8cff;
  --panel: rgba(18, 24, 36, 0.86);
  --panel-strong: rgba(30, 38, 54, 0.96);
  --line: rgba(255, 255, 255, 0.13);
  --danger: #ff315f;
  --steel: #222b3d;
  --deep: #070b13;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% 8%, rgba(69, 224, 255, 0.2), transparent 32%),
    radial-gradient(circle at 86% 20%, rgba(255, 79, 120, 0.16), transparent 34%),
    linear-gradient(145deg, #05070d, #0a0f1c 48%, #05070d);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body {
  width: 100%;
  max-width: 100%;
}

button {
  font: inherit;
  touch-action: manipulation;
}

.game-shell {
  width: min(1180px, 100%);
  max-width: 100vw;
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(260px, 1fr);
  gap: 32px;
  align-items: center;
  padding: 24px;
}

.game-phone {
  position: relative;
  width: min(430px, 100%);
  min-height: 900px;
  margin: 0 auto;
  padding: 22px 18px 92px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 32px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 18%),
    radial-gradient(circle at 50% 4%, rgba(69, 224, 255, 0.14), transparent 34%),
    #080c14;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.52);
}

.game-phone::before {
  content: "";
  position: absolute;
  inset: -140px -100px auto auto;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(69, 224, 255, 0.24), transparent 70%);
  pointer-events: none;
}

.hud-top,
.mission-panel,
.score-row,
.booster-row,
.bottom-actions {
  position: relative;
  z-index: 2;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.kicker,
.label {
  display: block;
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  line-height: 1.02;
}

h2 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.04;
}

p {
  color: var(--muted);
  line-height: 1.46;
}

.round-window,
.moves-box {
  min-width: 64px;
  padding: 10px 12px;
  border: 1px solid rgba(69, 224, 255, 0.22);
  border-radius: 18px;
  background: rgba(69, 224, 255, 0.1);
  text-align: center;
}

.round-window span,
.moves-box span,
.score-row span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.round-window strong,
.moves-box strong {
  display: block;
  color: var(--cyan);
  font-size: 24px;
}

.mission-panel {
  min-height: 78px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.objective-rack {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.goal-chip {
  min-height: 54px;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 17px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(10, 15, 25, 0.86);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.goal-chip span:not(.goal-orb) {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.goal-chip strong {
  color: var(--ink);
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.goal-chip.done {
  border-color: rgba(77, 255, 177, 0.44);
  background:
    radial-gradient(circle at 20% 30%, rgba(77, 255, 177, 0.2), transparent 44%),
    rgba(12, 24, 22, 0.92);
}

.goal-orb {
  width: 20px;
  height: 20px;
  display: block;
  border-radius: 7px;
  background: var(--gem);
  box-shadow: 0 0 14px color-mix(in srgb, var(--glow), transparent 12%);
  clip-path: polygon(50% 0, 94% 28%, 78% 84%, 50% 100%, 22% 84%, 6% 28%);
}

.mission-panel strong {
  display: block;
  font-size: 17px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr 76px 64px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.score-row > div,
.small-action {
  min-height: 56px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

.score-row strong {
  display: block;
  font-size: 19px;
}

.small-action {
  color: var(--ink);
  cursor: pointer;
}

.board-frame {
  position: relative;
  z-index: 1;
  padding: 10px;
  border: 1px solid rgba(69, 224, 255, 0.2);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 50%, rgba(69, 224, 255, 0.14), transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    #080d17;
  box-shadow:
    inset 0 0 44px rgba(0, 0, 0, 0.44),
    0 20px 58px rgba(0, 0, 0, 0.26);
}

.board-glow {
  position: absolute;
  inset: 12px;
  border-radius: 22px;
  box-shadow: 0 0 55px rgba(69, 224, 255, 0.12);
  pointer-events: none;
}

.board {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cell {
  position: relative;
  min-width: 0;
  padding: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 8%, rgba(255, 255, 255, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.015)),
    linear-gradient(145deg, #182233, #090d16 74%);
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease;
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -9px 18px rgba(0, 0, 0, 0.28),
    0 8px 18px rgba(0, 0, 0, 0.2);
}

.cell:not(.power-cell):not(.gem-box):not(.gem-seal)::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 9px 11px auto;
  height: 26%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.66), transparent);
  filter: blur(0.2px);
  pointer-events: none;
  transform: rotate(-17deg);
}

.cell::after {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 13px;
  background:
    radial-gradient(circle at 34% 22%, rgba(255, 255, 255, 0.82), transparent 13%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.38), transparent 22% 62%, rgba(0, 0, 0, 0.26)),
    var(--gem);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.56),
    inset 0 -10px 18px rgba(0, 0, 0, 0.3),
    0 0 22px color-mix(in srgb, var(--glow), transparent 16%),
    0 10px 18px rgba(0, 0, 0, 0.34);
  clip-path: polygon(50% 1%, 91% 23%, 98% 58%, 72% 91%, 50% 99%, 28% 91%, 2% 58%, 9% 23%);
  filter: saturate(1.16) contrast(1.08);
}

.cell.power-cell {
  border-color: rgba(255, 209, 102, 0.72);
  box-shadow:
    inset 0 0 24px rgba(255, 209, 102, 0.12),
    0 0 24px rgba(255, 209, 102, 0.18);
}

.cell.power-cell::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 2px;
  border-radius: 13px;
  border: 1px solid rgba(255, 209, 102, 0.58);
  background:
    linear-gradient(90deg, transparent 45%, rgba(255, 255, 255, 0.52) 48% 52%, transparent 55%),
    linear-gradient(0deg, transparent 45%, rgba(255, 255, 255, 0.34) 48% 52%, transparent 55%);
  mix-blend-mode: screen;
  pointer-events: none;
}

.cell.power-line::before {
  background:
    linear-gradient(90deg, transparent 39%, rgba(255, 255, 255, 0.88) 45% 55%, transparent 61%),
    radial-gradient(circle, rgba(255, 209, 102, 0.3), transparent 58%);
}

.cell.power-nova::before {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.86) 0 8%, rgba(255, 209, 102, 0.44) 9% 34%, transparent 35%),
    conic-gradient(from 0deg, transparent, rgba(255, 209, 102, 0.7), transparent, rgba(69, 224, 255, 0.54), transparent);
}

.power-mark {
  position: relative;
  z-index: 4;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #07101b;
  background: linear-gradient(135deg, #ffffff, var(--gold));
  font-weight: 950;
  font-size: 18px;
  box-shadow: 0 0 22px rgba(255, 209, 102, 0.72);
}

.power-mark.nova {
  font-size: 22px;
  background: radial-gradient(circle, #ffffff 0 18%, var(--gold) 19% 52%, var(--rose) 53% 100%);
  color: #fff;
}

.cell.selected {
  transform: scale(0.95);
  border-color: var(--cyan);
  filter: brightness(1.35);
}

.cell.matching {
  animation: pop 280ms ease-out both;
}

@keyframes pop {
  50% {
    transform: scale(1.16);
    filter: brightness(1.9);
  }
  100% {
    transform: scale(0.12);
    opacity: 0;
  }
}

.gem-cyan {
  --gem: linear-gradient(145deg, #aaf6ff 0%, #45e0ff 34%, #126d9c 100%);
  --glow: #4be5ff;
}

.gem-mint {
  --gem: linear-gradient(145deg, #c5ffe7 0%, #52ffba 34%, #0a8f62 100%);
  --glow: #52ffba;
}

.gem-gold {
  --gem: linear-gradient(145deg, #fff0b4 0%, #ffd166 34%, #aa6a15 100%);
  --glow: #ffd166;
}

.gem-rose {
  --gem: linear-gradient(145deg, #ffc2cf 0%, #ff5a82 34%, #a8133b 100%);
  --glow: #ff5a82;
}

.gem-violet {
  --gem: linear-gradient(145deg, #d7dcff 0%, #8d99ff 35%, #3341b2 100%);
  --glow: #8d99ff;
}

.cell.gem-box::after {
  clip-path: inset(8% round 10px);
  --gem:
    linear-gradient(90deg, transparent 0 46%, rgba(255, 255, 255, 0.24) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 0 46%, rgba(0, 0, 0, 0.28) 47% 53%, transparent 54%),
    linear-gradient(145deg, #d89a41, #71401f 52%, #2b211b);
  --glow: #ffd166;
}

.cell.gem-box::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 15px 17px;
  border-left: 2px solid rgba(255, 255, 255, 0.32);
  border-bottom: 2px solid rgba(0, 0, 0, 0.32);
  transform: skew(-16deg);
  pointer-events: none;
}

.cell.gem-seal::after {
  background:
    radial-gradient(circle, rgba(69, 224, 255, 0.2), transparent 56%),
    rgba(6, 15, 24, 0.76);
  border: 4px solid var(--cyan);
  clip-path: inset(16% round 10px);
  box-shadow:
    0 0 20px rgba(69, 224, 255, 0.75),
    inset 0 0 22px rgba(69, 224, 255, 0.35);
}

.cell.gem-line::after {
  --gem: linear-gradient(90deg, #ffffff, var(--gold), var(--cyan), #ffffff);
  --glow: #45e0ff;
  clip-path: polygon(50% 0, 62% 34%, 100% 46%, 62% 58%, 50% 100%, 38% 58%, 0 46%, 38% 34%);
}

.cell.gem-nova::after {
  --gem: radial-gradient(circle, #ffffff 0 18%, #ffd166 19% 45%, #ff4f78 46% 100%);
  --glow: #ffd166;
  clip-path: polygon(50% 0, 63% 27%, 94% 18%, 78% 50%, 100% 76%, 66% 70%, 50% 100%, 34% 70%, 0 76%, 22% 50%, 6% 18%, 37% 27%);
}

.laser-beam {
  position: absolute;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, transparent, #ffffff 9% 13%, var(--cyan) 22% 78%, #ffffff 87% 91%, transparent);
  box-shadow:
    0 0 18px rgba(69, 224, 255, 0.96),
    0 0 48px rgba(69, 224, 255, 0.64),
    0 0 88px rgba(255, 79, 120, 0.24);
  animation: laserFlash 360ms ease-out both;
}

.laser-beam.horizontal {
  left: 10px;
  right: 10px;
  height: 10px;
  transform: translateY(-50%);
  border-radius: 999px;
}

.laser-beam.vertical {
  top: 10px;
  bottom: 10px;
  width: 10px;
  transform: translateX(-50%);
  border-radius: 999px;
  background: linear-gradient(0deg, transparent, #ffffff 9% 13%, var(--cyan) 22% 78%, #ffffff 87% 91%, transparent);
}

@keyframes laserFlash {
  0% {
    opacity: 0;
    filter: blur(9px);
  }
  18%,
  70% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    filter: blur(13px);
  }
}

.floating-text {
  position: absolute;
  z-index: 6;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) rotate(-8deg) scale(0.86);
  padding: 12px 18px;
  border-radius: 16px;
  opacity: 0;
  pointer-events: none;
  color: #07101b;
  background: linear-gradient(135deg, var(--gold), var(--cyan));
  font-size: 27px;
  font-weight: 950;
  box-shadow: 0 20px 50px rgba(69, 224, 255, 0.28);
}

.floating-text.show {
  animation: floatText 900ms ease-out both;
}

@keyframes floatText {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) rotate(-8deg) scale(0.76);
  }
  22%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -72%) rotate(-8deg) scale(1.12);
  }
}

#fx-canvas {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.shake {
  animation: shake 260ms ease-in-out;
}

@keyframes shake {
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
}

.booster-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 12px;
}

.booster {
  min-height: 68px;
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.booster.locked {
  opacity: 0.45;
}

.booster-icon {
  display: block;
  width: 28px;
  height: 18px;
  margin: 0 auto 4px;
}

.line-icon {
  background: linear-gradient(90deg, transparent 0 14%, var(--cyan) 15% 85%, transparent 86%);
}

.prism-icon {
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--cyan), var(--gold), var(--rose));
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.booster strong,
.booster small {
  display: block;
}

.booster small {
  color: var(--muted);
  font-size: 11px;
}

.status-strip {
  min-height: 54px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(69, 224, 255, 0.18);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(69, 224, 255, 0.07);
  font-size: 13px;
  line-height: 1.35;
}

.bottom-actions {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: 1.4fr 0.8fr;
  gap: 10px;
}

.bottom-actions button,
.primary,
.text-button {
  min-height: 54px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 950;
}

.bottom-actions button:first-child,
.primary {
  color: #07101b;
  background: linear-gradient(135deg, var(--cyan), #9cffdd 54%, var(--gold));
}

.bottom-actions button:last-child,
.text-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(2, 4, 8, 0.68);
  backdrop-filter: blur(10px);
}

.overlay.hidden {
  display: none;
}

.result-card {
  width: 100%;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    radial-gradient(circle at 80% 0%, rgba(69, 224, 255, 0.14), transparent 36%),
    var(--panel-strong);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
}

.result-score {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.result-score span,
.reward-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.result-score strong {
  font-size: 24px;
}

.reward-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.reward-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.reward-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.direction-panel {
  max-width: 500px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(8, 12, 20, 0.7);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
}

.direction-panel ul {
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

/* V8 visual pass: brighter premium puzzle stage, darker board, bigger candy pieces. */
body {
  background:
    radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.82), transparent 22%),
    radial-gradient(circle at 88% 18%, rgba(255, 79, 120, 0.38), transparent 34%),
    radial-gradient(circle at 45% 86%, rgba(69, 224, 255, 0.42), transparent 36%),
    linear-gradient(180deg, #ffe66d 0%, #9ff7e9 48%, #ffd2e1 100%);
}

.game-phone {
  color: #221936;
  background:
    radial-gradient(circle at 48% 10%, rgba(255, 255, 255, 0.88), transparent 28%),
    linear-gradient(180deg, rgba(255, 249, 209, 0.96), rgba(178, 247, 234, 0.94) 48%, rgba(255, 221, 236, 0.94));
  box-shadow:
    0 30px 90px rgba(88, 35, 93, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.56);
}

.game-phone::before {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.82), transparent 58%),
    radial-gradient(circle at 40% 45%, rgba(255, 79, 120, 0.28), transparent 70%);
}

.mission-panel,
.score-row > div,
.small-action,
.booster,
.status-strip,
.result-card {
  color: #221936;
  border-color: rgba(139, 42, 145, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.68)),
    rgba(255, 255, 255, 0.78);
  box-shadow:
    0 10px 28px rgba(101, 61, 107, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.kicker,
.label {
  color: #cf148f;
}

p,
.score-row span,
.round-window span,
.moves-box span,
.booster small,
.status-strip,
.goal-chip span:not(.goal-orb) {
  color: rgba(34, 25, 54, 0.68);
}

.round-window,
.moves-box {
  border-color: rgba(207, 20, 143, 0.24);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 24px rgba(207, 20, 143, 0.12);
}

.round-window strong,
.moves-box strong {
  color: #cf148f;
}

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

.goal-chip {
  border-color: rgba(255, 255, 255, 0.66);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.54)),
    rgba(255, 255, 255, 0.66);
  box-shadow: 0 10px 24px rgba(60, 70, 93, 0.11);
}

.board-frame {
  border-color: rgba(255, 255, 255, 0.58);
  background:
    radial-gradient(circle at 50% 10%, rgba(69, 224, 255, 0.2), transparent 34%),
    linear-gradient(180deg, #134e61, #10394d 58%, #102d42);
  box-shadow:
    0 22px 46px rgba(31, 60, 82, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    inset 0 -22px 42px rgba(0, 0, 0, 0.28);
}

.board {
  gap: 5px;
}

.cell {
  touch-action: none;
  border-radius: 13px;
  border-color: rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    rgba(9, 48, 64, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -8px 16px rgba(0, 0, 0, 0.24);
  will-change: transform, opacity, filter;
}

.cell::after {
  inset: 3px;
  border-radius: 12px;
  clip-path: none;
  background:
    radial-gradient(circle at 32% 20%, rgba(255, 255, 255, 0.94), transparent 13%),
    radial-gradient(circle at 72% 82%, rgba(0, 0, 0, 0.2), transparent 30%),
    var(--gem);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.74),
    inset 0 -11px 16px rgba(0, 0, 0, 0.22),
    0 0 18px color-mix(in srgb, var(--glow), transparent 18%),
    0 8px 10px rgba(0, 0, 0, 0.22);
}

.gem-cyan {
  --gem: linear-gradient(145deg, #d3fbff 0%, #45e0ff 42%, #087ea2 100%);
}

.gem-mint {
  --gem: linear-gradient(145deg, #d7ffe9 0%, #35ee94 43%, #079858 100%);
}

.gem-gold {
  --gem: linear-gradient(145deg, #fff7b8 0%, #ffd144 44%, #c47811 100%);
}

.gem-rose {
  --gem: linear-gradient(145deg, #ffc6d4 0%, #ff3f74 44%, #b50f42 100%);
}

.gem-violet {
  --gem: linear-gradient(145deg, #f2c4ff 0%, #bd42f0 44%, #65229f 100%);
}

.gem-wall {
  --gem: linear-gradient(145deg, #8fa5b8, #2f4054 62%, #172033);
  --glow: #9fd7ff;
}

.cell.gem-mint::after {
  border-radius: 50%;
}

.cell.gem-gold::after {
  border-radius: 12px 22px 12px 22px;
}

.cell.gem-rose::after {
  border-radius: 50% 50% 42% 42%;
}

.cell.gem-violet::after {
  border-radius: 18px 18px 11px 11px;
}

.cell.gem-wall::after {
  --gem:
    linear-gradient(90deg, transparent 0 45%, rgba(255, 255, 255, 0.24) 46% 54%, transparent 55%),
    linear-gradient(0deg, transparent 0 45%, rgba(0, 0, 0, 0.22) 46% 54%, transparent 55%),
    linear-gradient(145deg, #6f8497, #27384a 62%, #142033);
  --glow: #9fd7ff;
  border-radius: 10px;
}

.wall-hp {
  position: relative;
  z-index: 4;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: #172033;
  border: 2px solid rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 950;
}

.cell.power-cell {
  border-color: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 0 0 2px rgba(255, 209, 102, 0.62),
    0 0 32px rgba(255, 209, 102, 0.54),
    inset 0 0 20px rgba(255, 255, 255, 0.26);
}

.cell.power-cube::before {
  background:
    linear-gradient(90deg, transparent 0 37%, rgba(255, 255, 255, 0.9) 38% 45%, transparent 46% 54%, rgba(255, 255, 255, 0.9) 55% 62%, transparent 63%),
    linear-gradient(0deg, transparent 0 37%, rgba(255, 255, 255, 0.78) 38% 45%, transparent 46% 54%, rgba(255, 255, 255, 0.78) 55% 62%, transparent 63%);
}

.cell.power-mega::before {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 1) 0 10%, rgba(255, 209, 102, 0.78) 11% 34%, transparent 35%),
    conic-gradient(from 0deg, #45e0ff, #ffd166, #ff4f78, #4dffb1, #45e0ff);
}

.cell.power-prism::before {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.96) 0 12%, transparent 13%),
    conic-gradient(from 0deg, #45e0ff, #4dffb1, #ffd166, #ff4f78, #bd42f0, #45e0ff);
  animation: prismSpin 1.4s linear infinite;
}

.power-mark {
  color: #2c1735;
}

.power-mark.cube {
  border-radius: 9px;
  background: linear-gradient(135deg, #ffffff, #45e0ff 48%, #ffd166);
}

.power-mark.mega {
  color: #ffffff;
  background: conic-gradient(from 0deg, #45e0ff, #ffd166, #ff4f78, #4dffb1, #45e0ff);
}

.power-mark.prism {
  color: #07101b;
  background: conic-gradient(from 0deg, #45e0ff, #4dffb1, #ffd166, #ff4f78, #bd42f0, #45e0ff);
}

.bottom-actions button:first-child,
.primary {
  color: #ffffff;
  background: linear-gradient(135deg, #cf148f, #ff4f78 48%, #ffd166);
  box-shadow: 0 14px 32px rgba(207, 20, 143, 0.28);
}

.bottom-actions button:last-child,
.text-button {
  color: #221936;
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(207, 20, 143, 0.16);
}

/* V9 RPG Match Battle layer. */
.battle-stage {
  position: relative;
  z-index: 2;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(8, 20, 34, 0.12), rgba(8, 20, 34, 0.42)),
    radial-gradient(circle at 72% 18%, rgba(255, 209, 102, 0.28), transparent 24%),
    linear-gradient(180deg, #273c58 0%, #172437 46%, #101928 100%);
  box-shadow:
    0 16px 34px rgba(38, 49, 68, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.battle-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 16%, rgba(255, 255, 255, 0.08) 17% 18%, transparent 19% 38%, rgba(255, 255, 255, 0.08) 39% 40%, transparent 41% 100%),
    radial-gradient(circle at 50% 110%, rgba(69, 224, 255, 0.24), transparent 45%);
  opacity: 0.88;
  pointer-events: none;
}

.battle-topline {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 900;
}

.battle-topline strong {
  color: #ffffff;
  font-size: 14px;
}

.enemy-zone {
  position: relative;
  z-index: 2;
  min-height: 118px;
  display: grid;
  place-items: center;
  padding-top: 4px;
}

.enemy-sprite {
  position: relative;
  width: 146px;
  height: 118px;
  display: grid;
  place-items: center;
  transform-origin: bottom center;
}

.enemy-sprite::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 79, 120, 0.32), transparent 62%);
  box-shadow:
    0 0 48px rgba(255, 79, 120, 0.42),
    0 0 76px rgba(69, 224, 255, 0.2);
}

.enemy-sprite::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 116px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.42), transparent 68%);
}

.enemy-core {
  position: relative;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 14%, #ff4f78 15% 58%, #5a1f74 59%);
  box-shadow: 0 0 30px rgba(255, 79, 120, 0.86);
}

.enemy-art {
  position: relative;
  z-index: 2;
  width: 150px;
  height: 128px;
  object-fit: contain;
  filter:
    drop-shadow(0 12px 10px rgba(0, 0, 0, 0.34))
    drop-shadow(0 0 18px rgba(124, 140, 255, 0.45));
  animation: enemyIdle 2.8s ease-in-out infinite;
}

.enemy-art + .enemy-core {
  position: absolute;
}

.enemy-hp {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 0;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.enemy-hp span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4dffb1, #ffd166, #ff4f78);
  transition: width 220ms ease-out;
}

.damage-number {
  position: absolute;
  z-index: 5;
  top: 20px;
  right: -18px;
  opacity: 0;
  color: #ffffff;
  text-shadow: 0 3px 0 rgba(88, 8, 38, 0.62), 0 0 18px rgba(255, 79, 120, 0.8);
  font-size: 34px;
  font-weight: 950;
  pointer-events: none;
}

.damage-number.show {
  animation: damagePop 620ms ease-out both;
}

.damage-number.critical {
  color: #ffd166;
  font-size: 39px;
}

.hero-row {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
  margin-top: 8px;
}

.hero-card {
  position: relative;
  min-width: 0;
  padding: 4px 3px 5px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 15px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(0, 0, 0, 0.08)),
    color-mix(in srgb, var(--hero-glow), #101928 72%);
  color: #ffffff;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 -10px 14px rgba(0, 0, 0, 0.22),
    0 0 18px color-mix(in srgb, var(--hero-glow), transparent 72%);
}

.hero-card strong,
.hero-card small {
  display: block;
}

.hero-card strong {
  margin-top: 3px;
  font-size: 11px;
}

.hero-card small {
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
  font-weight: 800;
}

.hero-meta {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}

.hero-level {
  justify-self: center;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 9px;
  font-weight: 950;
  line-height: 1.2;
}

.hero-hp,
.hero-xp {
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.36);
}

.hero-hp i,
.hero-xp i {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 220ms ease;
}

.hero-hp i {
  background: linear-gradient(90deg, #ff4f78, #ffd166, #52ffba);
}

.hero-xp i {
  background: linear-gradient(90deg, #45e0ff, #8d99ff);
}

.hero-card.hero-dead {
  filter: grayscale(1) brightness(0.42);
  opacity: 0.62;
}

.hero-card.hero-dead::after {
  content: "KO";
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(6, 9, 15, 0.58);
  color: #fff;
  font-size: 21px;
  font-weight: 950;
  letter-spacing: 0.04em;
}

.hero-card.healing::before {
  content: attr(data-heal);
  position: absolute;
  z-index: 5;
  top: -12px;
  right: 4px;
  color: #52ffba;
  font-size: 16px;
  font-weight: 950;
  text-shadow: 0 0 12px rgba(82, 255, 186, 0.8);
  animation: healPop 720ms ease-out both;
}

.hero-portrait {
  width: 44px;
  height: 54px;
  display: block;
  margin: 0 auto;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.58);
  background: var(--hero);
  box-shadow:
    0 0 16px color-mix(in srgb, var(--hero-glow), transparent 18%),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  animation: heroIdle 3.2s ease-in-out infinite;
}

.hero-rose {
  --hero: linear-gradient(145deg, #ffc2cf, #ff4f78 50%, #7b1231);
  --hero-glow: #ff4f78;
}

.hero-cyan {
  --hero: linear-gradient(145deg, #d3fbff, #45e0ff 50%, #0b6b92);
  --hero-glow: #45e0ff;
}

.hero-mint {
  --hero: linear-gradient(145deg, #d8ffe9, #4dffb1 50%, #0b8056);
  --hero-glow: #4dffb1;
}

.hero-gold {
  --hero: linear-gradient(145deg, #fff7bf, #ffd166 50%, #a76312);
  --hero-glow: #ffd166;
}

.hero-violet {
  --hero: linear-gradient(145deg, #f2e8ff, #b35cff 50%, #35206f);
  --hero-glow: #b35cff;
}

.hero-card.attacking {
  animation: heroStrike 520ms ease-out both;
}

.battle-stage.enemy-hit .enemy-sprite {
  animation: enemyHit 300ms ease-out both;
}

.battle-stage.boss-strike .hero-card:not(.hero-dead) {
  animation: heroDamaged 360ms ease-out both;
}

.battle-stage.boss-strike::before {
  filter: brightness(1.2) saturate(1.3);
}

.battle-stage.combo-strike::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: -12px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.96), transparent 12%),
    conic-gradient(from 0deg, transparent, rgba(69, 224, 255, 0.9), transparent, rgba(255, 79, 120, 0.86), transparent);
  mix-blend-mode: screen;
  animation: comboStageFlash 620ms ease-out both;
  pointer-events: none;
}

.enemy-sprite.spawn {
  animation: enemySpawn 520ms ease-out both;
}

.cell.birthing-special {
  animation: specialCellBirth 720ms ease-out both;
}

.cell:active {
  filter: brightness(1.24);
  transform: scale(0.96);
}

.special-birth {
  position: absolute;
  z-index: 8;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #221936;
  background:
    radial-gradient(circle, #ffffff 0 18%, var(--gem) 19% 52%, transparent 53%),
    conic-gradient(from 0deg, #45e0ff, #ffd166, #ff4f78, #4dffb1, #45e0ff);
  box-shadow:
    0 0 18px rgba(255, 255, 255, 0.9),
    0 0 42px color-mix(in srgb, var(--glow), transparent 10%);
  font-weight: 950;
  transform: translate(-50%, -50%) scale(0.3);
  pointer-events: none;
  animation: specialBirth 780ms ease-out both;
}

.prism-pulse {
  position: absolute;
  z-index: 9;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #ffffff;
  font-size: 26px;
  font-weight: 950;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.28), 0 0 22px rgba(255, 255, 255, 0.88);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.54), transparent 18%),
    conic-gradient(from 0deg, rgba(69, 224, 255, 0.92), rgba(77, 255, 177, 0.88), rgba(255, 209, 102, 0.9), rgba(255, 79, 120, 0.88), rgba(189, 66, 240, 0.84), rgba(69, 224, 255, 0.92));
  mix-blend-mode: screen;
  pointer-events: none;
  animation: prismPulse 820ms ease-out both;
}

@keyframes damagePop {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.7);
  }
  20%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-42px) scale(1.18);
  }
}

@keyframes heroStrike {
  0% {
    transform: translateY(0) scale(1);
  }
  35% {
    transform: translateY(-12px) scale(1.08);
    filter: brightness(1.45);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes heroDamaged {
  25% {
    transform: translateX(-4px);
    filter: brightness(1.7) saturate(1.2);
  }
  55% {
    transform: translateX(4px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes healPop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.86);
  }
  24% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-16px) scale(1.08);
  }
}

@keyframes enemyHit {
  25% {
    transform: translateX(-8px) scale(1.03);
    filter: brightness(1.6);
  }
  55% {
    transform: translateX(7px) scale(0.98);
  }
}

@keyframes enemySpawn {
  0% {
    opacity: 0;
    transform: translateY(-18px) scale(0.72);
    filter: blur(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes enemyIdle {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-4px) scale(1.025);
  }
}

@keyframes heroIdle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes comboStageFlash {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(0deg);
  }
  18%,
  60% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: scale(1.25) rotate(60deg);
  }
}

@keyframes specialCellBirth {
  0% {
    filter: brightness(1);
  }
  38% {
    filter: brightness(2.2);
    transform: scale(1.12);
  }
  100% {
    filter: brightness(1);
  }
}

@keyframes specialBirth {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.28) rotate(-40deg);
  }
  22%,
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.55) rotate(40deg);
  }
}

@keyframes prismSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes prismPulse {
  0% {
    opacity: 0;
    transform: scale(0.42) rotate(-24deg);
    filter: blur(8px);
  }
  25%,
  62% {
    opacity: 0.92;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: scale(1.16) rotate(18deg);
    filter: blur(12px);
  }
}

@media (max-width: 860px) {
  .game-shell {
    display: block;
    width: 100vw;
    max-width: 100vw;
    padding: 0;
    overflow: hidden;
  }

  .game-phone {
    width: 100%;
    max-width: 100vw;
    min-height: 100dvh;
    padding-inline: 14px;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }

  .direction-panel {
    display: none;
  }

  .hud-top,
  .battle-stage,
  .mission-panel,
  .objective-rack,
  .score-row,
  .board-frame,
  .booster-row,
  .status-strip,
  .bottom-actions {
    width: calc(100vw - 42px);
    max-width: 388px;
    margin-left: auto;
    margin-right: auto;
  }
}

/* V19 dungeon hub and high-visibility hero charge. */
.hidden {
  display: none !important;
}

.combat-screen {
  position: relative;
  z-index: 2;
}

.back-to-menu {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  color: #ffffff;
  background: rgba(11, 23, 42, 0.76);
  box-shadow: 0 8px 18px rgba(17, 26, 47, 0.24);
  font-size: 23px;
  font-weight: 950;
  cursor: pointer;
}

.main-menu {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 18px 18px;
  overflow-y: auto;
  color: #f7fbff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 17%),
    radial-gradient(circle at 76% 8%, rgba(255, 209, 102, 0.2), transparent 25%),
    radial-gradient(circle at 12% 28%, rgba(69, 224, 255, 0.18), transparent 30%),
    linear-gradient(165deg, #111a2d 0%, #07101d 52%, #160b24 100%);
}

.main-menu::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
}

.menu-header,
.menu-squad,
.training-recommendation,
.dungeon-browser,
.menu-actions,
.menu-notice {
  position: relative;
  z-index: 1;
}

.menu-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.menu-header h1 {
  max-width: 260px;
  color: #ffffff;
  font-size: 31px;
  line-height: 1;
}

.menu-progress {
  min-width: 70px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 209, 102, 0.46);
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 209, 102, 0.12);
  text-align: center;
  box-shadow: 0 0 22px rgba(255, 209, 102, 0.12);
}

.menu-progress span,
.menu-section-title span,
.training-recommendation span {
  display: block;
  color: rgba(255, 255, 255, 0.62);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.menu-progress strong {
  display: block;
  color: #ffd166;
  font-size: 28px;
}

.menu-notice {
  padding: 11px 13px;
  border-left: 4px solid #ffd166;
  color: #fff;
  background: rgba(255, 209, 102, 0.12);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.menu-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.menu-section-title strong {
  color: #45e0ff;
  font-size: 12px;
}

.menu-section-title small {
  color: rgba(255, 255, 255, 0.45);
  font-size: 9px;
}

.menu-hero-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.menu-hero {
  position: relative;
  min-width: 0;
  padding: 5px 4px 8px;
  border: 1px solid color-mix(in srgb, var(--hero-glow), #ffffff 34%);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--hero-glow), transparent 70%), rgba(4, 9, 18, 0.94));
  text-align: center;
}

.menu-hero img {
  width: 100%;
  height: 62px;
  display: block;
  margin-bottom: 4px;
  object-fit: cover;
  object-position: top;
  border-radius: 5px;
}

.menu-hero strong,
.menu-hero span,
.menu-hero small {
  display: block;
}

.menu-hero strong {
  color: #ffffff;
  font-size: 10px;
}

.menu-hero span {
  color: var(--hero-glow);
  font-size: 9px;
  font-weight: 900;
}

.menu-hero small {
  color: rgba(255, 255, 255, 0.54);
  font-size: 7px;
}

.menu-xp-track {
  position: absolute;
  right: 4px;
  bottom: 3px;
  left: 4px;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.menu-xp-track i {
  display: block;
  height: 100%;
  background: var(--hero-glow);
}

.training-recommendation {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(77, 255, 177, 0.52);
  border-radius: 8px;
  background:
    radial-gradient(circle at 12% 50%, rgba(77, 255, 177, 0.2), transparent 42%),
    rgba(10, 28, 30, 0.78);
  box-shadow: 0 0 24px rgba(77, 255, 177, 0.12);
}

.training-recommendation strong,
.training-recommendation small {
  display: block;
}

.training-recommendation strong {
  margin: 2px 0;
  color: #ffffff;
  font-size: 19px;
}

.training-recommendation small {
  color: rgba(255, 255, 255, 0.58);
  font-size: 10px;
}

.training-recommendation button,
.menu-actions button {
  min-height: 40px;
  padding: 0 13px;
  border: 0;
  border-radius: 7px;
  color: #07131b;
  background: linear-gradient(135deg, #4dffb1, #45e0ff);
  font-weight: 950;
  cursor: pointer;
}

.dungeon-browser {
  min-height: 0;
  flex: 1 1 auto;
}

.dungeon-list {
  display: grid;
  gap: 7px;
}

.dungeon-entry {
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  color: #ffffff;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.025)),
    rgba(5, 11, 22, 0.76);
  text-align: left;
  cursor: pointer;
}

.dungeon-entry.recommended {
  border-color: rgba(77, 255, 177, 0.68);
  box-shadow: inset 3px 0 #4dffb1;
}

.dungeon-entry.frontier {
  border-color: rgba(255, 209, 102, 0.66);
}

.dungeon-number {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #07101b;
  background: linear-gradient(135deg, #ffffff, #ffd166);
  font-size: 16px;
  font-weight: 950;
}

.dungeon-copy strong,
.dungeon-copy small {
  display: block;
}

.dungeon-copy strong {
  font-size: 14px;
}

.dungeon-copy small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.52);
  font-size: 10px;
}

.dungeon-tag {
  padding: 4px 6px;
  border-radius: 5px;
  color: #9ff7e9;
  background: rgba(69, 224, 255, 0.11);
  font-size: 8px;
  font-weight: 950;
  text-transform: uppercase;
}

.menu-actions {
  display: grid;
}

.menu-actions button {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.hero-card:not(.healing)::before {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 1px;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(var(--hero-glow) var(--energy-fill), rgba(255, 255, 255, 0.08) 0);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.hero-card > * {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.hero-energy-label {
  color: rgba(255, 255, 255, 0.78);
  font-size: 8px;
  font-weight: 950;
  line-height: 1;
}

.super-callout {
  position: absolute;
  z-index: 8;
  top: -9px;
  left: 50%;
  display: none;
  padding: 3px 6px;
  border: 2px solid #ffffff;
  border-radius: 5px;
  color: #07101b;
  background: #ffffff;
  font-size: 9px;
  font-weight: 1000;
  box-shadow: 0 0 18px #ffffff, 0 0 30px var(--hero-glow);
  transform: translateX(-50%);
}

.hero-card.super-ready .super-callout {
  display: block;
  animation: superCallout 620ms ease-in-out infinite;
}

.hero-card.super-ready {
  transform: translateY(-3px) scale(1.04);
}

@keyframes superCallout {
  50% { transform: translateX(-50%) scale(1.12); filter: brightness(1.25); }
}

@media (max-width: 860px) {
  .combat-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .main-menu {
    padding: max(16px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  }

  .menu-header h1 {
    font-size: 26px;
  }

  .hud-top {
    justify-content: flex-start;
  }

  .hud-top .round-window {
    margin-left: auto;
  }

  .battle-stage {
    flex-basis: clamp(190px, 24dvh, 208px);
  }

  .hero-card {
    min-height: 78px;
    padding: 3px 3px 19px;
  }

  .hero-portrait {
    width: clamp(40px, 11vw, 50px);
    height: clamp(45px, 12vw, 54px);
  }

  .hero-card strong {
    display: block;
    margin-top: 1px;
    font-size: 9px;
    line-height: 1;
  }

  .hero-card small {
    display: none;
  }

  .hero-meta {
    position: static;
    margin: 0;
  }

  .hud-top h1 {
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
  }

  .hero-level {
    position: absolute;
    z-index: 4;
    top: 4px;
    right: 4px;
    padding: 2px 4px;
    background: rgba(4, 10, 20, 0.78);
  }

  .hero-hp {
    position: absolute;
    right: 4px;
    bottom: 13px;
    left: 4px;
    height: 4px;
  }

  .hero-energy {
    position: absolute;
    right: 4px;
    bottom: 4px;
    left: 4px;
    height: 7px;
    border-color: rgba(255, 255, 255, 0.72);
  }

  .hero-energy-label {
    position: absolute;
    z-index: 5;
    right: 0;
    bottom: 3px;
    left: 0;
    color: #ffffff;
    font-size: 7px;
    text-align: center;
    text-shadow: 0 1px 3px #000000;
  }

  .hero-xp {
    display: none;
  }

  .hero-energy-label {
    display: block;
  }
}

@media (max-width: 390px) {
  .menu-hero img {
    height: 54px;
  }

  .battle-stage {
    flex-basis: clamp(184px, 23dvh, 198px);
  }
}

/* V21 native-style portrait layout and horizontal dungeon path. */
@media (max-width: 860px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #07101d;
  }

  body {
    position: fixed;
    inset: 0;
  }

  .game-shell {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    display: block;
    padding: 0;
    overflow: hidden;
    background: #07101d;
  }

  .game-phone {
    --app-top: max(8px, env(safe-area-inset-top));
    --app-bottom: max(8px, env(safe-area-inset-bottom));
    --app-gutter: clamp(8px, 2.5vw, 12px);
    width: 100%;
    max-width: 430px;
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background:
      radial-gradient(circle at 50% -10%, rgba(69, 224, 255, 0.22), transparent 34%),
      linear-gradient(170deg, #101b2f 0%, #07101d 54%, #140a21 100%);
    box-shadow: none;
  }

  .main-menu {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: clamp(10px, 1.8dvh, 16px);
    padding:
      calc(var(--app-top) + 8px)
      var(--app-gutter)
      calc(var(--app-bottom) + 8px);
    overflow: hidden;
  }

  .menu-header {
    min-height: 58px;
    align-items: center;
  }

  .menu-header h1 {
    max-width: none;
    margin: 0;
    font-size: clamp(25px, 7vw, 31px);
  }

  .menu-header .kicker {
    display: block;
  }

  .menu-progress {
    min-width: 62px;
    padding: 6px 8px;
  }

  .menu-progress strong {
    font-size: 24px;
  }

  .menu-notice {
    position: absolute;
    z-index: 30;
    top: calc(var(--app-top) + 76px);
    right: var(--app-gutter);
    left: var(--app-gutter);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
  }

  .menu-squad {
    min-height: 0;
  }

  .menu-section-title {
    margin-bottom: 6px;
  }

  .menu-hero-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .menu-hero {
    height: clamp(112px, 15dvh, 132px);
    padding: 4px 3px 8px;
  }

  .menu-hero img {
    height: clamp(54px, 8.4dvh, 70px);
    margin-bottom: 3px;
  }

  .menu-hero strong {
    font-size: 9px;
  }

  .menu-hero span {
    font-size: 8px;
  }

  .menu-hero small {
    display: block;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.66);
    font-size: 6px;
    line-height: 1.25;
    white-space: nowrap;
  }

  .dungeon-browser {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .dungeon-list {
    min-height: 0;
    display: flex;
    gap: 10px;
    padding: 2px 9% 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 9%;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    touch-action: pan-x;
  }

  .dungeon-list::-webkit-scrollbar {
    display: none;
  }

  .dungeon-entry {
    position: relative;
    flex: 0 0 82%;
    min-width: 0;
    height: 100%;
    min-height: 218px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto auto;
    align-content: stretch;
    gap: 6px;
    padding: 12px;
    overflow: hidden;
    border-radius: 8px;
    scroll-snap-align: center;
    text-align: left;
    background:
      radial-gradient(circle at 72% 32%, rgba(69, 224, 255, 0.18), transparent 34%),
      linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(3, 8, 18, 0.94));
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.3);
  }

  .dungeon-entry.frontier {
    border-color: #ffd166;
    box-shadow:
      inset 0 0 0 1px rgba(255, 209, 102, 0.28),
      0 14px 32px rgba(0, 0, 0, 0.36);
  }

  .dungeon-entry.recommended:not(.frontier) {
    border-color: #4dffb1;
    box-shadow:
      inset 0 0 0 1px rgba(77, 255, 177, 0.22),
      0 14px 28px rgba(0, 0, 0, 0.3);
  }

  .dungeon-entry.locked {
    opacity: 0.5;
    filter: grayscale(0.75);
  }

  .dungeon-card-top,
  .dungeon-card-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .dungeon-number {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .dungeon-emblem {
    align-self: center;
    justify-self: center;
    width: clamp(82px, 24vw, 106px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 50%;
    color: #ffffff;
    background:
      radial-gradient(circle, rgba(255, 255, 255, 0.24), transparent 42%),
      conic-gradient(from 45deg, #45e0ff, #4dffb1, #ffd166, #ff4f78, #45e0ff);
    box-shadow:
      inset 0 0 0 10px rgba(5, 12, 24, 0.78),
      0 0 24px rgba(69, 224, 255, 0.2);
    font-size: 30px;
    font-weight: 950;
  }

  .dungeon-copy strong {
    font-size: 19px;
  }

  .dungeon-copy small {
    font-size: 11px;
  }

  .dungeon-card-stats {
    color: rgba(255, 255, 255, 0.58);
    font-size: 8px;
    font-weight: 800;
  }

  .dungeon-card-action {
    min-height: 38px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    color: #07101b;
    background: linear-gradient(135deg, #4dffb1, #45e0ff);
    font-size: 12px;
    font-weight: 950;
  }

  .dungeon-entry.frontier .dungeon-card-action {
    background: linear-gradient(135deg, #ffd166, #ff9f4d);
  }

  .dungeon-entry.locked .dungeon-card-action {
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
  }

  .dungeon-swipe-hint {
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: rgba(255, 255, 255, 0.45);
    font-size: 10px;
  }

  .dungeon-swipe-hint i {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
  }

  .dungeon-swipe-hint i:nth-of-type(2) {
    width: 12px;
    border-radius: 999px;
    background: #45e0ff;
  }

  .menu-actions {
    min-height: 40px;
    display: flex;
    gap: 8px;
  }

  .menu-actions button {
    min-width: 0;
    flex: 1 1 auto;
  }

  .install-app {
    color: #07101b !important;
    background: linear-gradient(135deg, #ffd166, #ff9f4d) !important;
  }

  .combat-screen {
    width: 100%;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(204px, 1fr) auto;
    align-content: start;
    gap: 5px;
    padding:
      calc(var(--app-top) + 5px)
      var(--app-gutter)
      var(--app-bottom);
    overflow: hidden;
  }

  .hud-top {
    width: 100%;
    min-height: 42px;
    display: grid;
    grid-template-columns: 40px 1fr 40px 58px;
    gap: 7px;
    margin: 0;
  }

  .hud-top h1 {
    font-size: 20px;
  }

  .back-to-menu,
  .restart-action {
    width: 40px;
    height: 40px;
    min-height: 40px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 8px;
    color: #ffffff;
    background: rgba(11, 23, 42, 0.82);
    font-size: 21px;
    font-weight: 950;
  }

  .round-window {
    min-width: 58px;
    padding: 5px 7px;
  }

  .battle-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    flex: none;
    margin: 0;
  }

  .enemy-zone {
    min-height: 0;
  }

  .hero-row {
    margin-top: 4px;
  }

  .mission-panel,
  .objective-rack,
  .score-row,
  .status-strip,
  .bottom-actions {
    display: none !important;
  }

  .board-frame {
    --board-fit: min(calc(100vw - (var(--app-gutter) * 2)), 406px);
    width: var(--board-fit);
    height: var(--board-fit);
    max-width: 100%;
    max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 258px);
    align-self: start;
    justify-self: center;
    margin: 0 auto;
    aspect-ratio: 1;
  }

  .board {
    width: 100%;
    height: 100%;
  }
}

/* V22 UI corrections. Keep this block last. */
@media (max-width: 860px) {
  .menu-notice {
    position: absolute;
    z-index: 40;
    top: auto;
    right: var(--app-gutter);
    bottom: calc(var(--app-bottom) + 54px);
    left: var(--app-gutter);
    max-width: none;
    padding: 8px 10px;
    border: 1px solid rgba(255, 209, 102, 0.48);
    border-left-width: 3px;
    border-radius: 6px;
    background: rgba(7, 16, 29, 0.96);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.46);
    font-size: 10px;
    line-height: 1.2;
  }

  .dungeon-list {
    padding-inline: 7%;
  }

  .dungeon-entry:not(.frontier) {
    flex: 0 0 70px;
    width: 70px;
    height: 278px;
    min-height: 0;
    grid-template-rows: auto 1fr;
    padding: 9px 7px;
  }

  .dungeon-entry:not(.frontier) .dungeon-tag,
  .dungeon-entry:not(.frontier) .dungeon-copy,
  .dungeon-entry:not(.frontier) .dungeon-card-stats,
  .dungeon-entry:not(.frontier) .dungeon-card-action {
    display: none;
  }

  .dungeon-entry:not(.frontier) .dungeon-card-top {
    justify-content: center;
  }

  .dungeon-entry:not(.frontier) .dungeon-emblem {
    width: 48px;
    align-self: center;
    font-size: 17px;
    box-shadow:
      inset 0 0 0 6px rgba(5, 12, 24, 0.78),
      0 0 16px rgba(69, 224, 255, 0.16);
  }

  .dungeon-entry.frontier {
    flex-basis: min(72vw, 280px);
    width: min(72vw, 280px);
  }

  .floating-text {
    z-index: 15;
    top: 8px;
    max-width: 76%;
    padding: 5px 9px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.15;
    text-align: center;
    transform: translateX(-50%);
  }

  .floating-text.show {
    animation: floatTextV22 780ms ease-out both;
  }
}

.cell.gem-inactive {
  border-color: rgba(181, 199, 222, 0.2);
  background:
    radial-gradient(circle at 50% 46%, rgba(177, 202, 229, 0.08), transparent 54%),
    linear-gradient(145deg, #111722, #070a10 74%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -9px 18px rgba(0, 0, 0, 0.46),
    0 6px 14px rgba(0, 0, 0, 0.28);
}

.cell.gem-inactive::after {
  background:
    radial-gradient(circle at 32% 20%, rgba(255, 255, 255, 0.28), transparent 13%),
    linear-gradient(135deg, rgba(205, 219, 235, 0.14), transparent 24% 62%, rgba(0, 0, 0, 0.48)),
    var(--gem);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -11px 16px rgba(0, 0, 0, 0.48),
    0 0 8px color-mix(in srgb, var(--glow), transparent 76%);
  filter: saturate(0.26) brightness(0.56) contrast(1.12);
  opacity: 0.88;
}

.cell.gem-inactive::before {
  content: "";
  position: absolute;
  z-index: 3;
  inset: 18% 35%;
  height: auto;
  border-radius: 0;
  background: linear-gradient(180deg, rgba(236, 244, 252, 0.96), rgba(154, 175, 199, 0.72));
  clip-path: polygon(45% 0, 100% 0, 62% 35%, 100% 35%, 28% 100%, 42% 57%, 0 57%);
  filter:
    drop-shadow(1px 1px 0 rgba(3, 7, 12, 0.96))
    drop-shadow(-1px 0 2px rgba(3, 7, 12, 0.84));
  opacity: 0.9;
  pointer-events: none;
  transform: none;
}

.cell.gem-inactive .power-mark {
  filter: saturate(0.3) brightness(0.72);
  opacity: 0.78;
}

@keyframes floatTextV22 {
  0% {
    opacity: 0;
    transform: translate(-50%, -6px) scale(0.92);
  }
  18%,
  72% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -12px) scale(0.96);
  }
}

/* V23 readable hero super effects. */
.hero-super-effect {
  position: absolute;
  z-index: 18;
  inset: 28px 8px 76px;
  overflow: hidden;
  pointer-events: none;
}

.hero-super-effect i {
  position: absolute;
  display: block;
}

.hero-super-effect.effect-fireballs i {
  left: var(--shot-x);
  bottom: -22px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 32%, #ffffff 0 11%, #ffd166 12% 32%, #ff4f32 45% 70%, transparent 72%);
  box-shadow: 0 0 18px #ff4f32, 0 0 34px rgba(255, 209, 102, 0.8);
  animation: superFireball 620ms cubic-bezier(.18,.82,.24,1) calc(var(--shot) * 55ms) both;
}

.hero-super-effect.effect-freeze i {
  inset: 10% 20%;
  border: 3px solid rgba(170, 245, 255, 0.92);
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.82) 0 2deg, transparent 3deg 28deg),
    radial-gradient(circle, rgba(69, 224, 255, 0.36), transparent 66%);
  box-shadow: 0 0 28px #45e0ff, inset 0 0 24px rgba(255, 255, 255, 0.52);
  animation: superFreeze 760ms ease-out both;
}

.hero-super-effect.effect-heal_shield i {
  left: 50%;
  bottom: 0;
  width: 82%;
  height: 54%;
  border: 3px solid rgba(77, 255, 177, 0.88);
  border-radius: 50% 50% 18% 18%;
  background:
    radial-gradient(circle at 50% 85%, rgba(255, 255, 255, 0.84), rgba(77, 255, 177, 0.28) 34%, transparent 68%);
  box-shadow: 0 0 32px rgba(77, 255, 177, 0.78), inset 0 0 28px rgba(77, 255, 177, 0.35);
  animation: superHealShield 820ms ease-out both;
}

.hero-super-effect.effect-laser i {
  top: 48%;
  left: -15%;
  width: 130%;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #ffd166 12%, #ffffff 38% 62%, #ffd166 88%, transparent);
  box-shadow: 0 0 16px #ffffff, 0 0 34px #ffd166;
  transform: rotate(-16deg) scaleX(0);
  transform-origin: left center;
  animation: superLaser 680ms ease-out both;
}

.hero-super-effect.effect-multi_burst i {
  left: var(--burst-x);
  top: var(--burst-y);
  width: 36px;
  height: 36px;
  border: 3px solid rgba(233, 180, 255, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0 8%, #b84cff 10% 38%, rgba(38, 5, 64, 0.9) 56%, transparent 60%);
  box-shadow: 0 0 22px #b84cff;
  animation: superVoidBurst 620ms ease-out calc(var(--burst) * 65ms) both;
}

@keyframes superFireball {
  0% { opacity: 0; transform: translate(-50%, 0) scale(0.45); }
  22% { opacity: 1; }
  78% { opacity: 1; transform: translate(-50%, -130px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -148px) scale(2.4); }
}

@keyframes superFreeze {
  0% { opacity: 0; transform: scale(0.28) rotate(-30deg); }
  42% { opacity: 1; transform: scale(1.02) rotate(0); }
  100% { opacity: 0; transform: scale(1.2) rotate(18deg); }
}

@keyframes superHealShield {
  0% { opacity: 0; transform: translate(-50%, 36px) scale(0.72); }
  38% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -8px) scale(1.08); }
}

@keyframes superLaser {
  0% { opacity: 0; transform: rotate(-16deg) scaleX(0); }
  26% { opacity: 1; transform: rotate(-16deg) scaleX(1); }
  72% { opacity: 1; transform: rotate(-16deg) scaleX(1); }
  100% { opacity: 0; transform: rotate(-16deg) scaleX(1.08); }
}

@keyframes superVoidBurst {
  0% { opacity: 0; transform: scale(0.2); }
  35% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.2); }
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  .game-phone {
    background:
      radial-gradient(circle at 50% -10%, rgba(69, 224, 255, 0.24), transparent 34%),
      linear-gradient(170deg, #101b2f 0%, #07101d 54%, #140a21 100%);
  }
}

@media (max-width: 390px) {
  .game-phone {
    padding-inline: 10px;
  }

  .board {
    gap: 3px;
  }

  .mission-panel {
    grid-template-columns: 1fr 66px;
  }

  h1 {
    font-size: 28px;
  }

  .round-window,
  .moves-box {
    min-width: 58px;
    padding-inline: 8px;
  }
}

/* V17 deterministic combat engine visuals. */
.cell.cell-empty {
  visibility: hidden;
  pointer-events: none;
}

.cell.power-line-h::before,
.cell.power-line-v::before,
.cell.power-cube::before,
.cell.power-prism::before,
.cell.power-nova::before,
.cell.power-mega::before {
  z-index: 3;
  inset: 3px;
  border: 0;
  border-radius: 12px;
  mix-blend-mode: screen;
}

.cell.power-line-h::before {
  background:
    linear-gradient(90deg, transparent 0 8%, #ffffff 9% 18%, var(--glow) 19% 81%, #ffffff 82% 91%, transparent 92%),
    radial-gradient(circle, rgba(255, 255, 255, 0.74), transparent 58%);
  clip-path: polygon(0 50%, 18% 22%, 18% 39%, 82% 39%, 82% 22%, 100% 50%, 82% 78%, 82% 61%, 18% 61%, 18% 78%);
  animation: lineCoreHorizontal 1.15s ease-in-out infinite;
}

.cell.power-line-v::before {
  background:
    linear-gradient(0deg, transparent 0 8%, #ffffff 9% 18%, var(--glow) 19% 81%, #ffffff 82% 91%, transparent 92%),
    radial-gradient(circle, rgba(255, 255, 255, 0.74), transparent 58%);
  clip-path: polygon(50% 0, 78% 18%, 61% 18%, 61% 82%, 78% 82%, 50% 100%, 22% 82%, 39% 82%, 39% 18%, 22% 18%);
  animation: lineCoreVertical 1.15s ease-in-out infinite;
}

.cell.power-cube::before {
  inset: 7px;
  border: 4px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background:
    radial-gradient(circle, #ffffff 0 9%, var(--glow) 10% 35%, transparent 37%),
    repeating-radial-gradient(circle, rgba(255, 255, 255, 0.72) 0 2px, transparent 3px 8px);
  box-shadow: 0 0 18px var(--glow), inset 0 0 16px var(--glow);
  animation: cubeCorePulse 1.25s ease-in-out infinite;
}

.cell.power-prism::before {
  inset: 5px;
  border-radius: 9px;
  background:
    radial-gradient(circle, #ffffff 0 8%, transparent 9%),
    conic-gradient(from 0deg, #45e0ff, #4dffb1, #ffd166, #ff4f78, #bd42f0, #45e0ff);
  clip-path: polygon(50% 0, 83% 15%, 100% 50%, 82% 85%, 50% 100%, 18% 85%, 0 50%, 17% 15%);
  box-shadow: 0 0 28px rgba(255, 255, 255, 0.88);
  animation: prismSpin 1.25s linear infinite;
}

.cell.power-nova::before {
  inset: 4px;
  background:
    radial-gradient(circle, #ffffff 0 10%, #ffd166 11% 28%, #ff4f78 29% 44%, transparent 45%),
    conic-gradient(from 0deg, transparent 0 7%, #ffffff 8% 12%, transparent 13% 20%, var(--glow) 21% 29%, transparent 30% 100%);
  clip-path: polygon(50% 0, 61% 32%, 88% 12%, 70% 40%, 100% 50%, 70% 60%, 88% 88%, 61% 68%, 50% 100%, 39% 68%, 12% 88%, 30% 60%, 0 50%, 30% 40%, 12% 12%, 39% 32%);
  animation: novaCorePulse 900ms ease-in-out infinite;
}

.cell.power-mega::before {
  inset: 2px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background:
    radial-gradient(circle, #ffffff 0 7%, #07101b 8% 22%, transparent 23%),
    conic-gradient(from 30deg, #45e0ff, #ffd166, #ff4f78, #4dffb1, #bd42f0, #45e0ff);
  clip-path: polygon(50% 0, 64% 24%, 88% 12%, 76% 36%, 100% 50%, 76% 64%, 88% 88%, 64% 76%, 50% 100%, 36% 76%, 12% 88%, 24% 64%, 0 50%, 24% 36%, 12% 12%, 36% 24%);
  filter: saturate(1.35) contrast(1.2);
  animation: megaCoreSpin 1.6s linear infinite;
}

.power-mark.line-h,
.power-mark.line-v,
.power-mark.cube,
.power-mark.prism,
.power-mark.nova,
.power-mark.mega {
  z-index: 5;
  width: 23px;
  height: 23px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  color: #ffffff;
  background: rgba(5, 11, 22, 0.72);
  text-shadow: 0 0 8px #ffffff;
  box-shadow: 0 0 18px var(--glow);
  font-size: 12px;
}

.area-wave,
.board-clear-wave {
  position: absolute;
  z-index: 10;
  pointer-events: none;
}

.area-wave {
  width: 42px;
  height: 42px;
  border: 5px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  box-shadow:
    0 0 22px #ffffff,
    0 0 54px var(--gold);
  transform: translate(-50%, -50%) scale(0.2);
  animation: areaWave 460ms ease-out both;
}

.area-wave.nova {
  border-color: var(--rose);
  box-shadow:
    0 0 28px #ffffff,
    0 0 70px var(--rose),
    0 0 110px var(--cyan);
  animation-duration: 620ms;
}

.board-clear-wave {
  left: 2%;
  width: 96%;
  height: 16%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #ffffff 18% 26%, var(--cyan) 42%, var(--rose) 64%, #ffffff 78% 84%, transparent);
  box-shadow: 0 0 36px rgba(255, 255, 255, 0.94);
  transform: translateY(-50%) scaleX(0.05);
  animation: boardClearSweep 420ms ease-out both;
}

.cell.queue-hit,
.cell.prism-hit {
  animation: queuedHit 360ms ease-out both;
}

@keyframes lineCoreHorizontal {
  50% { transform: scaleX(1.13); filter: brightness(1.45); }
}

@keyframes lineCoreVertical {
  50% { transform: scaleY(1.13); filter: brightness(1.45); }
}

@keyframes cubeCorePulse {
  50% { transform: scale(1.12); opacity: 0.72; }
}

@keyframes novaCorePulse {
  50% { transform: scale(1.14) rotate(15deg); filter: brightness(1.5); }
}

@keyframes megaCoreSpin {
  to { transform: rotate(360deg); }
}

@keyframes areaWave {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.18); }
  22% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(4.2); }
}

@keyframes boardClearSweep {
  0% { opacity: 0; transform: translateY(-50%) scaleX(0.04); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-50%) scaleX(1.08); }
}

@keyframes queuedHit {
  45% { transform: scale(1.18); filter: brightness(2.1); }
}

/* V18 hero charge, boss telegraph and dungeon flow. */
.boss-intent {
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  color: #d9f7ff;
  background: rgba(5, 12, 24, 0.48);
  font-size: 9px;
  font-weight: 950;
}

.boss-intent.danger {
  color: #fff4c2;
  border-color: rgba(255, 79, 120, 0.76);
  background: rgba(132, 12, 48, 0.62);
  box-shadow: 0 0 18px rgba(255, 79, 120, 0.58);
  animation: bossIntentPulse 760ms ease-in-out infinite;
}

.battle-alert {
  position: absolute;
  z-index: 12;
  top: 30%;
  left: 50%;
  min-width: 170px;
  max-width: 86%;
  padding: 9px 14px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  color: #ffffff;
  background: rgba(8, 15, 31, 0.9);
  text-align: center;
  font-size: 16px;
  font-weight: 950;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, -50%) scale(0.72);
}

.battle-alert.show {
  animation: battleAlertPop 1s ease-out both;
}

.battle-alert.boss-warning,
.battle-alert.hero-ko-alert {
  background: rgba(126, 12, 42, 0.94);
  box-shadow: 0 0 36px rgba(255, 79, 120, 0.72);
}

.hero-energy {
  position: relative;
  height: 5px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.46);
}

.hero-energy i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--hero-glow), #ffffff);
  box-shadow: 0 0 10px var(--hero-glow);
  transition: width 260ms ease-out;
}

.hero-card {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.hero-card.super-ready {
  border-color: #ffffff;
  filter: brightness(1.16);
  box-shadow:
    0 0 0 2px var(--hero-glow),
    0 0 18px #ffffff,
    0 0 34px var(--hero-glow),
    inset 0 0 18px color-mix(in srgb, var(--hero-glow), transparent 46%);
  animation: heroReady 820ms ease-in-out infinite;
}

.hero-card.super-ready:active {
  transform: translateY(0) scale(0.96);
  filter: brightness(1.45);
}

.hero-card.super-queued {
  box-shadow:
    0 0 0 3px #ffffff,
    0 0 28px var(--hero-glow),
    inset 0 0 20px var(--hero-glow);
}

.hero-card.super-queued .super-callout {
  color: #ffffff;
  background: #07101b;
}

.hero-card.super-ready .hero-energy {
  background: #ffffff;
}

.hero-card.super-ready .hero-energy i {
  width: 100% !important;
  background: #ffffff;
}

.hero-damage-number {
  position: absolute;
  z-index: 12;
  top: 8px;
  left: 50%;
  color: #ffffff;
  font-size: 18px;
  font-weight: 950;
  text-shadow: 0 2px 0 #8b1238, 0 0 12px #ff4f78;
  pointer-events: none;
  animation: heroDamageNumber 860ms ease-out both;
}

.hero-damage-number.ko-hit {
  color: #ffd166;
  font-size: 22px;
}

.battle-stage.boss-charging .enemy-sprite {
  filter: brightness(1.5) saturate(1.45);
  animation: bossCharge 420ms ease-in both;
}

.enemy-sprite.boss-lunge {
  animation: bossLunge 360ms ease-in-out both;
}

.battle-stage.hero-super::after {
  content: "";
  position: absolute;
  z-index: 8;
  inset: -8px;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 35%, #ffffff 0 7%, var(--super-color, #45e0ff) 8% 24%, transparent 48%),
    linear-gradient(115deg, transparent 35%, color-mix(in srgb, var(--super-color, #45e0ff), transparent 4%) 47% 53%, transparent 65%);
  mix-blend-mode: screen;
  animation: heroSuperFlash 740ms ease-out both;
}

.battle-stage.hero-super-rose { --super-color: #ff365f; }
.battle-stage.hero-super-cyan { --super-color: #35dfff; }
.battle-stage.hero-super-mint { --super-color: #35f0a0; }
.battle-stage.hero-super-gold { --super-color: #ffd34e; }
.battle-stage.hero-super-violet { --super-color: #b84cff; }

.demo-banner {
  position: absolute;
  z-index: 14;
  top: 10px;
  left: 50%;
  width: max-content;
  max-width: 90%;
  padding: 8px 13px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 9px;
  opacity: 0;
  color: #ffffff;
  background: rgba(8, 15, 31, 0.88);
  font-size: 13px;
  font-weight: 950;
  text-align: center;
  transform: translateX(-50%) translateY(-12px);
  pointer-events: none;
}

.demo-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

@keyframes bossIntentPulse {
  50% { transform: scale(1.05); filter: brightness(1.35); }
}

@keyframes battleAlertPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.72); }
  18%, 72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -68%) scale(1.08); }
}

@keyframes heroReady {
  50% { transform: translateY(-2px) scale(1.035); }
}

@keyframes heroDamageNumber {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.7); }
  22%, 66% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(1.2); }
}

@keyframes bossCharge {
  0% { transform: scale(1); }
  100% { transform: scale(1.18); }
}

@keyframes bossLunge {
  0% { transform: translateY(0) scale(1); }
  45% { transform: translateY(30px) scale(1.32); filter: brightness(1.8); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes heroSuperFlash {
  0% { opacity: 0; transform: scale(0.55); }
  22%, 62% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.25); }
}

@media (max-width: 860px) {
  .boss-intent {
    padding: 2px 5px;
    font-size: 8px;
  }

  .hero-energy {
    height: 4px;
  }

  .battle-alert {
    font-size: 13px;
  }

  .demo-banner {
    top: 7px;
    font-size: 11px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* V11 phone app fit: one compact gameplay viewport, not a tall web page. */
@media (max-width: 860px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .game-shell {
    height: 100dvh;
    overflow: hidden;
    background: linear-gradient(180deg, #ffe66d 0%, #9ff7e9 48%, #ffd2e1 100%);
  }

  .game-phone {
    --screen-w: min(100vw, 430px);
    --gutter: 10px;
    --content-w: calc(var(--screen-w) - 20px);
    --board-size: min(calc(var(--screen-w) - 32px), calc(100dvh - 535px), 388px);
    width: var(--screen-w);
    height: 100dvh;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: max(8px, env(safe-area-inset-top)) var(--gutter) calc(58px + env(safe-area-inset-bottom));
    overflow: hidden;
    border-radius: 0;
  }

  .hud-top,
  .battle-stage,
  .mission-panel,
  .objective-rack,
  .score-row,
  .board-frame,
  .booster-row,
  .status-strip,
  .bottom-actions {
    width: var(--content-w);
    max-width: var(--content-w);
    margin-left: auto;
    margin-right: auto;
  }

  .hud-top {
    min-height: 38px;
    margin-bottom: 0;
  }

  .kicker,
  .label {
    font-size: 9px;
    margin-bottom: 2px;
  }

  h1 {
    font-size: 22px;
    line-height: 1;
  }

  .round-window,
  .moves-box {
    min-width: 50px;
    padding: 6px 8px;
    border-radius: 13px;
  }

  .round-window span,
  .moves-box span,
  .score-row span {
    font-size: 9px;
  }

  .round-window strong,
  .moves-box strong {
    font-size: 18px;
  }

  .battle-stage {
    flex: 0 0 clamp(150px, 23dvh, 192px);
    margin-bottom: 0;
    padding: 8px;
    border-radius: 18px;
  }

  .battle-topline {
    font-size: 10px;
  }

  .battle-topline strong {
    font-size: 12px;
  }

  .enemy-zone {
    min-height: clamp(74px, 11.5dvh, 106px);
    padding-top: 0;
  }

  .enemy-sprite {
    width: clamp(92px, 26vw, 126px);
    height: clamp(74px, 11dvh, 98px);
  }

  .enemy-art {
    width: clamp(96px, 29vw, 132px);
    height: clamp(78px, 12dvh, 106px);
  }

  .enemy-core {
    width: 24px;
    height: 24px;
  }

  .enemy-hp {
    left: 18px;
    right: 18px;
    height: 8px;
  }

  .damage-number {
    top: 10px;
    right: -8px;
    font-size: 25px;
  }

  .damage-number.critical {
    font-size: 30px;
  }

  .hero-row {
    gap: 5px;
    margin-top: 6px;
  }

  .hero-card {
    min-height: 58px;
    padding: 4px 3px;
    border-radius: 12px;
  }

  .hero-portrait {
    width: clamp(34px, 10vw, 42px);
    height: clamp(40px, 11.5vw, 50px);
    border-radius: 8px;
  }

  .hero-card strong {
    margin-top: 2px;
    font-size: 9px;
  }

  .hero-card small {
    display: none;
  }

  .hero-meta {
    margin-top: 2px;
    gap: 1px;
  }

  .hero-level {
    font-size: 8px;
    padding: 0 4px;
  }

  .mission-panel {
    min-height: 42px;
    grid-template-columns: 1fr 54px;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 0;
    border-radius: 14px;
  }

  .mission-panel strong {
    font-size: 13px;
    line-height: 1.1;
  }

  .objective-rack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-bottom: 0;
  }

  .goal-chip {
    min-height: 36px;
    grid-template-columns: 16px 1fr;
    grid-template-areas:
      "orb label"
      "orb value";
    gap: 2px 5px;
    padding: 5px 6px;
    border-radius: 11px;
  }

  .goal-orb {
    grid-area: orb;
    width: 16px;
    height: 16px;
  }

  .goal-chip span:not(.goal-orb) {
    grid-area: label;
    font-size: 8px;
    line-height: 1;
  }

  .goal-chip strong {
    grid-area: value;
    font-size: 12px;
    line-height: 1;
  }

  .score-row {
    grid-template-columns: 1fr 52px 48px;
    gap: 5px;
    margin-bottom: 0;
  }

  .score-row > div,
  .small-action {
    min-height: 36px;
    padding: 5px 8px;
    border-radius: 12px;
  }

  .score-row strong {
    font-size: 14px;
  }

  .board-frame {
    flex: 0 0 var(--board-size);
    width: var(--board-size);
    height: var(--board-size);
    max-width: var(--board-size);
    min-height: 0;
    max-height: 388px;
    padding: 6px;
    border-radius: 20px;
  }

  .board-glow {
    inset: 8px;
    border-radius: 16px;
  }

  .board {
    height: 100%;
    gap: 4px;
  }

  .cell {
    border-radius: 11px;
  }

  .cell::after {
    inset: 3px;
    border-radius: 10px;
  }

  .power-mark,
  .wall-hp {
    width: 21px;
    height: 21px;
    font-size: 11px;
  }

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

  .booster {
    min-height: 42px;
    padding: 5px;
    border-radius: 12px;
  }

  .booster-icon {
    width: 21px;
    height: 12px;
    margin-bottom: 1px;
  }

  .booster strong {
    font-size: 11px;
  }

  .booster small {
    display: none;
  }

  .status-strip {
    min-height: 32px;
    margin: 0;
    padding: 7px 10px;
    border-radius: 12px;
    font-size: 10px;
    line-height: 1.2;
  }

  .bottom-actions {
    left: 10px;
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    grid-template-columns: 1fr 86px;
    gap: 8px;
  }

  .bottom-actions button,
  .primary,
  .text-button {
    min-height: 46px;
    border-radius: 14px;
    font-size: 13px;
  }

  .floating-text {
    font-size: 21px;
    padding: 9px 13px;
    border-radius: 12px;
  }
}

@media (max-width: 390px) {
  .game-phone {
    --gutter: 8px;
    --content-w: calc(var(--screen-w) - 16px);
    --board-size: min(calc(var(--screen-w) - 26px), calc(100dvh - 500px), 360px);
    gap: 5px;
  }

  .battle-stage {
    flex-basis: clamp(140px, 22dvh, 178px);
  }

  .mission-panel {
    min-height: 38px;
  }

  .status-strip {
    display: none;
  }
}

/* V12 fullscreen gameplay: board first, dashboard chrome removed. */
@media (max-width: 860px) {
  .game-phone {
    --screen-w: 100vw;
    --gutter: 6px;
    --content-w: calc(100vw - 12px);
    --board-size: min(calc(100vw - 14px), calc(100dvh - 270px));
    gap: 4px;
    padding: max(5px, env(safe-area-inset-top)) var(--gutter) calc(48px + env(safe-area-inset-bottom));
    background:
      radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.88), transparent 18%),
      linear-gradient(180deg, rgba(255, 249, 209, 0.96), rgba(172, 249, 236, 0.96) 44%, rgba(255, 221, 236, 0.96));
  }

  .hud-top {
    min-height: 32px;
    flex: 0 0 32px;
  }

  .hud-top .kicker {
    display: none;
  }

  h1 {
    font-size: 19px;
  }

  .round-window {
    min-width: 48px;
    padding: 4px 7px;
  }

  .battle-stage {
    flex: 0 0 clamp(112px, 17dvh, 148px);
    padding: 6px;
    border-radius: 16px;
  }

  .battle-topline {
    font-size: 9px;
    line-height: 1;
  }

  .battle-topline strong {
    font-size: 11px;
  }

  .enemy-zone {
    min-height: clamp(56px, 8dvh, 78px);
  }

  .enemy-sprite {
    width: clamp(78px, 20vw, 108px);
    height: clamp(58px, 8dvh, 78px);
  }

  .enemy-art {
    width: clamp(84px, 23vw, 116px);
    height: clamp(64px, 8.5dvh, 88px);
  }

  .enemy-core {
    width: 20px;
    height: 20px;
  }

  .enemy-hp {
    left: 14px;
    right: 14px;
    bottom: -1px;
    height: 7px;
  }

  .hero-row {
    gap: 4px;
    margin-top: 4px;
  }

  .hero-card {
    min-height: 44px;
    padding: 3px;
    border-radius: 10px;
  }

  .hero-portrait {
    width: clamp(28px, 8vw, 36px);
    height: clamp(32px, 9vw, 42px);
    border-width: 1px;
  }

  .hero-card strong {
    display: none;
  }

  .hero-meta {
    margin-top: 2px;
  }

  .hero-hp,
  .hero-xp {
    height: 3px;
  }

  .mission-panel,
  .score-row,
  .status-strip {
    display: none;
  }

  .objective-rack {
    flex: 0 0 34px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .goal-chip {
    min-height: 32px;
    padding: 4px 5px;
    border-radius: 10px;
  }

  .goal-chip span:not(.goal-orb) {
    font-size: 8px;
  }

  .goal-chip strong {
    font-size: 12px;
  }

  .goal-orb {
    width: 15px;
    height: 15px;
  }

  .board-frame {
    flex: 1 1 auto;
    width: var(--board-size);
    height: var(--board-size);
    max-width: var(--board-size);
    max-height: var(--board-size);
    align-self: center;
    padding: 5px;
    border-radius: 20px;
  }

  .board {
    gap: 4px;
  }

  .cell {
    border-radius: 12px;
  }

  .cell::after {
    inset: 2px;
    border-radius: 10px;
  }

  .booster-row {
    flex: 0 0 39px;
    gap: 5px;
  }

  .booster {
    min-height: 38px;
    padding: 4px;
  }

  .bottom-actions {
    left: 6px;
    right: 6px;
    bottom: max(5px, env(safe-area-inset-bottom));
    grid-template-columns: 1fr 76px;
    gap: 6px;
  }

  .bottom-actions button,
  .primary,
  .text-button {
    min-height: 39px;
    border-radius: 12px;
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  .game-phone {
    --board-size: min(calc(100vw - 12px), calc(100dvh - 252px));
  }

  .battle-stage {
    flex-basis: clamp(102px, 16dvh, 136px);
  }

  .booster-row {
    display: none;
  }
}

/* V19 final mobile overrides after legacy responsive layers. */
@media (max-width: 860px) {
  .combat-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .battle-stage {
    flex: 0 0 clamp(184px, 23dvh, 198px);
  }

  .mission-panel {
    min-height: 34px;
    padding: 6px 12px;
  }

  .mission-panel .label {
    display: inline;
    margin-right: 6px;
  }

  .mission-panel strong {
    display: inline;
    font-size: 13px;
  }

  .hero-card {
    min-height: 78px;
    padding: 3px 3px 19px;
  }

  .hero-portrait {
    width: clamp(40px, 11vw, 50px);
    height: clamp(45px, 12vw, 54px);
  }

  .hero-card strong {
    display: block;
    margin-top: 1px;
    font-size: 9px;
    line-height: 1;
  }

  .hero-card small,
  .hero-xp {
    display: none;
  }

  .hero-meta {
    position: static;
    margin: 0;
  }

  .hero-level {
    position: absolute;
    z-index: 4;
    top: 4px;
    right: 4px;
    padding: 2px 4px;
    background: rgba(4, 10, 20, 0.78);
  }

  .hero-hp {
    position: absolute;
    right: 4px;
    bottom: 13px;
    left: 4px;
    height: 4px;
  }

  .hero-energy {
    position: absolute;
    right: 4px;
    bottom: 4px;
    left: 4px;
    height: 7px;
    border-color: rgba(255, 255, 255, 0.72);
  }

  .hero-energy-label {
    position: absolute;
    z-index: 5;
    right: 0;
    bottom: 3px;
    left: 0;
    display: block;
    color: #ffffff;
    font-size: 7px;
    font-weight: 950;
    line-height: 1;
    text-align: center;
    text-shadow: 0 1px 3px #000000;
  }
}

/* V21 final authority. Keep this block last. */
@media (max-width: 860px) {
  html,
  body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #07101d;
  }

  body {
    position: fixed;
    inset: 0;
  }

  .game-shell {
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    display: block;
    padding: 0;
    overflow: hidden;
    background: #07101d;
  }

  .game-phone {
    --app-top: max(8px, env(safe-area-inset-top));
    --app-bottom: max(8px, env(safe-area-inset-bottom));
    --app-gutter: clamp(8px, 2.5vw, 12px);
    width: 100%;
    max-width: 430px;
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background:
      radial-gradient(circle at 50% -10%, rgba(69, 224, 255, 0.22), transparent 34%),
      linear-gradient(170deg, #101b2f 0%, #07101d 54%, #140a21 100%);
    box-shadow: none;
  }

  .main-menu {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: clamp(10px, 1.8dvh, 16px);
    padding:
      calc(var(--app-top) + 8px)
      var(--app-gutter)
      calc(var(--app-bottom) + 8px);
    overflow: hidden;
  }

  .menu-header {
    min-height: 58px;
    align-items: center;
  }

  .menu-header h1 {
    max-width: none;
    margin: 0;
    font-size: clamp(25px, 7vw, 31px);
  }

  .menu-squad,
  .dungeon-browser {
    min-height: 0;
  }

  .menu-hero-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .menu-hero {
    height: clamp(112px, 15dvh, 132px);
  }

  .menu-hero img {
    height: clamp(54px, 8.4dvh, 70px);
  }

  .dungeon-browser {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .dungeon-list {
    min-height: 0;
    display: flex;
    gap: 10px;
    padding: 2px 9% 8px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 9%;
    scrollbar-width: none;
    touch-action: pan-x;
    align-items: center;
  }

  .dungeon-entry {
    flex: 0 0 82%;
    width: 82%;
    height: min(330px, 100%);
    max-height: 330px;
    min-height: 218px;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto auto;
    align-items: stretch;
    justify-items: stretch;
    gap: 6px;
    scroll-snap-align: center;
  }

  .dungeon-card-top,
  .dungeon-copy,
  .dungeon-card-stats,
  .dungeon-card-action {
    width: 100%;
    justify-self: stretch;
  }

  .dungeon-copy {
    text-align: center;
  }

  .dungeon-card-stats {
    display: flex;
  }

  .dungeon-card-action {
    display: grid;
  }

  .menu-actions {
    position: static;
    min-height: 40px;
    display: flex;
    gap: 8px;
  }

  .combat-screen {
    width: 100%;
    height: 100dvh;
    display: grid;
    grid-template-rows: auto minmax(204px, 1fr) auto;
    align-content: start;
    gap: 5px;
    padding:
      calc(var(--app-top) + 5px)
      var(--app-gutter)
      var(--app-bottom);
    overflow: hidden;
  }

  .hud-top {
    width: 100%;
    min-height: 42px;
    display: grid;
    grid-template-columns: 40px 1fr 40px 58px;
    gap: 7px;
    margin: 0;
  }

  .hud-top h1 {
    color: #ffffff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.42);
  }

  .battle-stage {
    width: 100%;
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    flex: none;
    margin: 0;
  }

  .enemy-zone {
    min-height: 0;
  }

  .hero-row {
    margin-top: 4px;
  }

  .mission-panel,
  .objective-rack,
  .score-row,
  .status-strip,
  .bottom-actions {
    display: none !important;
  }

  .board-frame {
    --board-fit: min(calc(100vw - (var(--app-gutter) * 2)), 406px);
    width: var(--board-fit);
    height: var(--board-fit);
    max-width: 100%;
    max-height: calc(100dvh - var(--app-top) - var(--app-bottom) - 258px);
    align-self: start;
    justify-self: center;
    margin: 0 auto;
    aspect-ratio: 1;
  }

  .board {
    width: 100%;
    height: 100%;
  }
}
