:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #1b1d23;
  --panel-soft: #242832;
  --text: #f4f5f7;
  --muted: #a6adbb;
  --line: #343946;
  --stage-bg: rgba(27, 29, 35, 0.88);
  --surface-bg: rgba(36, 40, 50, 0.68);
  --soft-bg: rgba(36, 40, 50, 0.72);
  --deep-bg: rgba(16, 17, 20, 0.55);
  --deeper-bg: rgba(13, 14, 17, 0.5);
  --subtle-line: rgba(255, 255, 255, 0.07);
  --success-text: #d9ffe2;
  --fail-text: #ffdede;
  --gold: #f6c85f;
  --steel: #dce4ef;
  --danger: #ff6b6b;
  --success: #70e08b;
  --accent: #77a7ff;
}

body.light {
  color-scheme: light;
  --bg: #edf1f7;
  --panel: #ffffff;
  --panel-soft: #e9edf5;
  --text: #151922;
  --muted: #5f6878;
  --line: #cfd6e3;
  --stage-bg: rgba(255, 255, 255, 0.94);
  --surface-bg: rgba(247, 249, 253, 0.92);
  --soft-bg: rgba(233, 237, 245, 0.94);
  --deep-bg: rgba(255, 255, 255, 0.72);
  --deeper-bg: rgba(247, 249, 253, 0.9);
  --subtle-line: rgba(21, 25, 34, 0.1);
  --success-text: #155c2c;
  --fail-text: #9b1c1c;
  --gold: #b87912;
  --danger: #d93636;
  --success: #248a45;
  --accent: #2f68d8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 18%, rgba(119, 167, 255, 0.2), transparent 28rem),
    linear-gradient(135deg, #14161b, var(--bg));
  color: var(--text);
  font-family:
    Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.light {
  background:
    radial-gradient(circle at 50% 18%, rgba(47, 104, 216, 0.18), transparent 28rem),
    linear-gradient(135deg, #f8fafc, var(--bg));
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

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

.game {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 22rem;
  gap: 0.85rem;
  width: min(68rem, calc(100% - 2rem));
  min-height: calc(100vh - 2rem);
  margin: 1rem auto;
}

.destroyed-banner {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 20;
  padding: 0.4rem 1.2rem;
  color: #ff3d3d;
  font-size: clamp(3rem, 12vw, 8rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow:
    0 0.15rem 0 #3d0000,
    0 0 1.5rem rgba(255, 61, 61, 0.9),
    0 0 3rem rgba(255, 61, 61, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.55) rotate(-4deg);
}

.destroyed-banner.show {
  animation: destroyed-flash 1.15s ease-out both;
}

.item-depleted-banner {
  position: fixed;
  left: 50%;
  top: 32%;
  z-index: 22;
  width: min(92vw, 48rem);
  padding: 0.8rem 1rem;
  color: var(--gold);
  font-size: clamp(1.45rem, 5.4vw, 3.8rem);
  font-weight: 1000;
  line-height: 1.08;
  text-align: center;
  text-shadow:
    0 0.12rem 0 #3f2a05,
    0 0 1.2rem rgba(246, 200, 95, 0.8),
    0 0 2.5rem rgba(246, 200, 95, 0.42);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.75);
}

.item-depleted-banner.show {
  animation: item-depleted-flash 1.45s ease-out both;
}

.reset-corner {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  min-width: 5rem;
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.9rem;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 900;
  box-shadow: 0 0.75rem 1.8rem rgba(0, 0, 0, 0.28);
}

.mobile-settings-button {
  display: none;
}

.mobile-inventory-button,
.mobile-status-bar {
  display: none;
}

.fireworks-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.fireworks-layer span {
  position: absolute;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  box-shadow: 0 0 0.8rem currentColor;
  animation: firework-spark 1.25s ease-out both;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  padding: 1rem;
  place-items: center;
  background: rgba(0, 0, 0, 0.56);
}

.modal-card {
  width: min(28rem, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: var(--stage-bg);
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.35);
}

.completion-card {
  text-align: center;
}

.modal-card h2 {
  margin-bottom: 0.55rem;
  color: var(--gold);
  font-size: 2rem;
}

.modal-card p {
  color: var(--muted);
  line-height: 1.45;
}

.modal-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.ranking-register {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  margin: 1rem 0 0.5rem;
}

.ranking-register input {
  min-width: 0;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.8rem;
  background: var(--deeper-bg);
  color: var(--text);
  font: inherit;
  font-weight: 900;
  text-transform: uppercase;
}

.auth-form {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.auth-form input {
  min-width: 0;
  min-height: 3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.8rem;
  background: var(--deeper-bg);
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.auth-actions {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.modal-hint {
  min-height: 1.35rem;
  margin-bottom: 0.8rem;
  font-size: 0.85rem;
}

.coffee-card {
  text-align: left;
}

.coffee-pay-button {
  display: flex;
  width: 100%;
  margin-top: 1rem;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.bank-transfer-box {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: var(--surface-bg);
}

.bank-transfer-box span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.bank-transfer-box strong {
  color: var(--gold);
  font-size: 1.1rem;
  line-height: 1.2;
}

.coffee-button {
  margin-top: 0.45rem;
  border: 1px solid rgba(246, 196, 83, 0.5);
  border-radius: 8px;
  padding: 0.54rem 0.84rem;
  background: rgba(246, 196, 83, 0.12);
  color: var(--gold);
  font: inherit;
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.coffee-button:hover {
  border-color: rgba(246, 196, 83, 0.85);
  background: rgba(246, 196, 83, 0.2);
  transform: translateY(-1px);
}

.gamble-card {
  width: min(34rem, 100%);
}

.gamble-wallet {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  background: var(--surface-bg);
  color: var(--gold);
  font-weight: 900;
}

.gamble-bet-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 0.6rem;
  margin: 0.75rem 0;
  color: var(--muted);
  font-weight: 900;
}

.gamble-bet-row > span {
  min-height: 2.8rem;
  display: inline-flex;
  align-items: center;
}

.gamble-bet-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}

.gamble-bet-options .secondary {
  min-height: 3.1rem;
  padding: 0.4rem 0.45rem;
  font-size: 0.86rem;
  font-weight: 900;
}

.gamble-bet-options .selected {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(246, 200, 95, 0.22);
}

.gamble-custom-bet {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.gamble-custom-bet input {
  min-width: 0;
  min-height: 2.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.65rem;
  background: var(--deeper-bg);
  color: var(--text);
  font: inherit;
  font-weight: 900;
}

.gamble-custom-bet em {
  color: var(--gold);
  font-style: normal;
  font-weight: 900;
  min-width: 4.4rem;
  text-align: right;
  white-space: nowrap;
}

.gamble-tabs,
.gamble-choice-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.gamble-tabs {
  margin-bottom: 0.75rem;
}

.gamble-tabs .secondary,
.gamble-choice-row button {
  min-height: 3rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.92rem;
  font-weight: 900;
}

.gamble-tabs .selected {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(246, 200, 95, 0.22);
}

.gamble-game {
  display: grid;
  gap: 0.75rem;
}

.odd-even-stage,
.ladder-stage {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--surface-bg);
}

.odd-even-stage {
  display: grid;
  justify-items: center;
  gap: 0.55rem;
}

.odd-even-orb {
  display: grid;
  width: 5.25rem;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid rgba(246, 200, 95, 0.72);
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 30%, #fff3bd, var(--gold) 48%, #684407 100%);
  color: #2d1d03;
  font-size: 2rem;
  font-weight: 1000;
  box-shadow: 0 0.8rem 1.7rem rgba(0, 0, 0, 0.3);
}

.odd-even-stage.rolling .odd-even-orb {
  animation: odd-even-roll 1s ease-in-out both;
}

.odd-even-result,
.ladder-result {
  min-height: 1.4rem;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
}

.odd-even-stage.success .odd-even-result,
.ladder-stage.success .ladder-result {
  color: var(--success);
}

.odd-even-stage.fail .odd-even-result,
.ladder-stage.fail .ladder-result {
  color: var(--danger);
}

.ladder-board {
  position: relative;
  width: min(19rem, 100%);
  height: 13.5rem;
  margin: 0 auto 0.75rem;
}

.ladder-line,
.ladder-rung {
  position: absolute;
  background: rgba(119, 167, 255, 0.68);
  box-shadow: 0 0 0.7rem rgba(119, 167, 255, 0.24);
}

.ladder-line {
  top: 0;
  bottom: 0;
  width: 0.26rem;
  border-radius: 999px;
  transform: translateX(-50%);
}

.ladder-line.lane-1 {
  left: 0;
}

.ladder-line.lane-2 {
  left: 50%;
}

.ladder-line.lane-3 {
  left: 100%;
}

.ladder-rung {
  width: 50%;
  height: 0.24rem;
  border-radius: 999px;
}

.ladder-marker {
  position: absolute;
  left: -0.55rem;
  top: -0.55rem;
  z-index: 2;
  width: 1.1rem;
  aspect-ratio: 1;
  border: 2px solid #fff6c7;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 1rem rgba(246, 200, 95, 0.8);
  opacity: 0;
  transition: left 280ms ease, top 280ms ease, opacity 140ms ease;
}

.ladder-marker.show {
  opacity: 1;
}

.ladder-stage.running .ladder-marker {
  animation: ladder-marker-pulse 620ms ease-in-out infinite;
}

#ladderGame .gamble-choice-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.ranking-list {
  display: grid;
  gap: 0.45rem;
  max-height: 22rem;
  overflow: auto;
}

.ranking-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.ranking-tabs .secondary {
  min-height: 2.45rem;
  padding: 0 0.5rem;
  font-size: 0.85rem;
}

.ranking-tabs .selected {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(246, 200, 95, 0.24);
}

.ranking-row {
  display: grid;
  grid-template-columns: 2.4rem minmax(0, 1fr);
  align-items: start;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--surface-bg);
}

.ranking-row strong {
  color: var(--gold);
  font-size: 1.2rem;
}

.ranking-row span {
  overflow: hidden;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
  margin-top: 0.25rem;
}

.ranking-metric {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 900;
}

.ranking-icon {
  position: relative;
  display: inline-block;
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.ranking-icon.time {
  border: 0.14rem solid #77a7ff;
  border-radius: 999px;
}

.ranking-icon.time::before,
.ranking-icon.time::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 999px;
  background: #dce9ff;
  transform-origin: left center;
}

.ranking-icon.time::before {
  width: 0.34rem;
  height: 0.11rem;
  transform: translate(-0.02rem, -0.05rem) rotate(-90deg);
}

.ranking-icon.time::after {
  width: 0.42rem;
  height: 0.11rem;
  transform: translate(-0.02rem, -0.05rem) rotate(22deg);
}

.ranking-row em,
.ranking-empty {
  color: var(--muted);
  font-style: normal;
  font-size: 0.85rem;
}

.ranking-empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  background: var(--surface-bg);
  text-align: center;
}

.stage,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--stage-bg);
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.24);
}

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
  min-height: 34rem;
  padding: 1.25rem;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
}

.topbar > div:first-child {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 6vw, 4.75rem);
  line-height: 1;
  word-break: keep-all;
}

#swordName {
  max-width: min(36rem, calc(100vw - 12rem));
  overflow: hidden;
  font-size: clamp(1.45rem, 4vw, 2.8rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-view h1 {
  font-size: clamp(1.6rem, 4vw, 3rem);
  line-height: 1.05;
}

.icon-button,
.secondary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.icon-button {
  flex: 0 0 auto;
  min-height: 2.85rem;
  padding: 0.35rem 0.9rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.top-actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  max-width: min(100%, 31rem);
}

.compact-action {
  min-height: 2.85rem;
  padding: 0.35rem 0.85rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.top-enhance-settings {
  position: absolute;
  top: calc(100% + 0.55rem);
  right: 0;
  z-index: 12;
  width: min(22rem, calc(100vw - 2rem));
  grid-template-columns: 1fr;
  justify-items: stretch;
  gap: 0.4rem;
  padding: 0.55rem;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.28);
}

.auto-target-controls {
  display: grid;
  grid-template-columns: 2.5rem minmax(6.5rem, 1fr) 2.5rem;
  justify-self: stretch;
  width: 100%;
  gap: 0.4rem;
}

.top-enhance-settings .stage-step {
  width: 2.5rem;
  min-height: 2.5rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.top-enhance-settings .stage-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  min-height: 2.5rem;
  padding: 0 0.45rem;
}

.top-enhance-settings .stage-readout span {
  flex: 0 0 auto;
  font-size: 0.76rem;
  line-height: 1;
  white-space: nowrap;
}

.top-enhance-settings .stage-readout strong {
  flex: 0 0 auto;
  font-size: 1.2rem;
  line-height: 1;
  white-space: nowrap;
}

.top-enhance-settings #autoEnhanceStartButton {
  grid-column: 1 / -1;
  justify-self: center;
  width: 100%;
  min-width: 7.5rem;
  min-height: 2.3rem;
  padding: 0 0.9rem;
  font-size: 0.85rem;
  line-height: 1;
}

.auto-item-status {
  display: grid;
  grid-column: 1 / -1;
  width: 100%;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--deep-bg);
}

.auto-item-title {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.auto-item-title + .auto-item-row {
  border-top: 0;
}

.auto-item-row {
  display: grid;
  grid-template-columns: 1.45rem minmax(0, 1fr);
  align-items: start;
  gap: 0.38rem;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 0.45rem 0.35rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.auto-item-row:first-of-type {
  border-top: 0;
}

.auto-item-row .item-object {
  width: 1.3rem;
  margin-top: 0.05rem;
}

.auto-item-text {
  display: grid;
  min-width: 0;
  gap: 0.16rem;
}

.auto-item-name {
  min-width: 0;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
}

.auto-item-row strong {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: left;
  white-space: nowrap;
}

.auto-item-row.selected strong {
  color: var(--gold);
}

.auto-item-row.selected {
  box-shadow: inset 0.18rem 0 0 var(--gold);
  background: rgba(246, 196, 83, 0.09);
}

.auto-item-row:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.sword-area {
  position: relative;
  display: grid;
  min-height: 18.5rem;
  place-items: center;
}

.monster-area {
  position: relative;
  display: grid;
  min-height: 18.5rem;
  place-items: center;
}

.monster-shadow {
  position: absolute;
  bottom: 2.5rem;
  width: 16rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  filter: blur(0.25rem);
}

.monster {
  position: relative;
  width: min(19rem, 74vw);
  height: min(19rem, 74vw);
  background-image: url("assets/monsters/stages-20-centered-transparent/monster-stage-01.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transform-origin: bottom center;
  transition: transform 120ms ease, filter 120ms ease, background 180ms ease;
}

.monster-eye {
  display: none;
  position: absolute;
  top: 38%;
  width: 1.2rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #111318;
}

.monster-eye.left {
  left: 33%;
}

.monster-eye.right {
  right: 33%;
}

.monster-mouth {
  display: none;
  position: absolute;
  left: 50%;
  top: 57%;
  width: 3rem;
  height: 1.4rem;
  border-bottom: 0.35rem solid #111318;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.monster-stage {
  position: absolute;
  right: 1rem;
  top: 1rem;
  bottom: auto;
  min-width: 7rem;
  border: 1px solid rgba(119, 167, 255, 0.45);
  border-radius: 8px;
  padding: 0.7rem 1rem;
  background: rgba(16, 17, 20, 0.78);
  color: var(--accent);
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
}

body.light .monster-stage,
body.light .level-badge {
  background: rgba(255, 255, 255, 0.86);
}

.glow {
  position: absolute;
  width: 11.5rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(119, 167, 255, 0.14);
  filter: blur(1.5rem);
  transform: scale(1);
  transition: background 180ms ease, transform 180ms ease;
}

.sword {
  position: relative;
  width: min(13.8rem, 54vw);
  height: min(16.7rem, 58vw);
  background-image: url("assets/swords/stages-30-final-transparent/sword-stage-01.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 1.2rem 1.4rem rgba(0, 0, 0, 0.34));
  transform: scale(1);
  transition: transform 160ms ease, filter 160ms ease;
}

.attack-sword {
  position: absolute;
  left: 2%;
  top: 9%;
  z-index: 3;
  width: min(13.5rem, 44vw);
  height: min(16.2rem, 52vw);
  pointer-events: none;
  opacity: 0;
  background-image: url("assets/swords/stages-30-final-transparent/sword-stage-01.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 0 1.1rem rgba(119, 167, 255, 0.9));
  transform: translate(-50%, 26%) rotate(58deg) scale(var(--attack-scale, 1));
}

.attack-sword.slash {
  animation: sword-slash 260ms cubic-bezier(0.18, 0.86, 0.28, 1) both;
}

.coin-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.coin {
  position: absolute;
  left: 50%;
  top: 45%;
  display: grid;
  width: 2.4rem;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid #ffe39a;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, #fff7c6, var(--gold) 48%, #b87a18 100%);
  color: #5a3600;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 0.65rem 1rem rgba(0, 0, 0, 0.3);
  animation: coin-drop 900ms ease-out both;
  transform: translate(var(--coin-x, 0), 0);
}

.gold-coin-icon {
  display: inline-grid;
  flex: 0 0 auto;
  width: 0.95em;
  aspect-ratio: 1;
  margin-left: 0.16em;
  place-items: center;
  vertical-align: -0.12em;
  border: 1px solid #ffe39a;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, #fff7c6, var(--gold) 48%, #b87a18 100%);
  box-shadow: 0 0.08em 0.18em rgba(0, 0, 0, 0.3);
}

button .gold-coin-icon,
.shop-price .gold-coin-icon,
.shop-price-list .gold-coin-icon,
.ranking-meta .gold-coin-icon,
.log .gold-coin-icon,
.notice .gold-coin-icon {
  width: 0.86em;
}

.coin-value {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 4;
  color: var(--gold);
  font-size: 1.4rem;
  font-weight: 900;
  text-shadow: 0 0.25rem 0.7rem rgba(0, 0, 0, 0.75);
  animation: coin-value-rise 900ms ease-out both;
  transform: translateX(-50%);
  pointer-events: none;
}

.item-drop {
  position: absolute;
  left: 50%;
  top: 36%;
  z-index: 6;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.85);
  transform: translateX(-50%);
  animation: item-drop-pop 1.45s ease-out both;
  pointer-events: none;
}

.item-drop .item-object {
  width: 4rem;
  filter:
    drop-shadow(0 0.35rem 0.5rem rgba(0, 0, 0, 0.45))
    drop-shadow(0 0 1rem rgba(246, 200, 95, 0.5));
}

.damage-number {
  position: absolute;
  left: 50%;
  top: 36%;
  z-index: 5;
  color: #ff7777;
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 900;
  text-shadow:
    0 0.2rem 0 #5c1111,
    0 0 0.75rem rgba(255, 107, 107, 0.75);
  animation: damage-pop 620ms ease-out both;
  transform: translateX(calc(-50% + var(--damage-x, 0rem)));
  pointer-events: none;
}

.blade {
  display: none;
  position: absolute;
  left: 50%;
  top: 0;
  width: 2.2rem;
  height: 12.5rem;
  border-radius: 1.2rem 1.2rem 0.35rem 0.35rem;
  background: linear-gradient(90deg, #aeb8c6 0%, var(--steel) 45%, #ffffff 55%, #8c98a8 100%);
  clip-path: polygon(50% 0, 100% 18%, 80% 100%, 20% 100%, 0 18%);
  transform: translateX(-50%);
}

.guard {
  display: none;
  position: absolute;
  left: 50%;
  top: 12.25rem;
  width: 5rem;
  height: 0.9rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #976d23, var(--gold), #976d23);
  transform: translateX(-50%);
}

.grip {
  display: none;
  position: absolute;
  left: 50%;
  top: 13rem;
  width: 1.05rem;
  height: 4.1rem;
  border-radius: 999px;
  background: repeating-linear-gradient(180deg, #70452e 0 0.45rem, #4d3022 0.45rem 0.9rem);
  transform: translateX(-50%);
}

.pommel {
  display: none;
  position: absolute;
  left: 50%;
  bottom: 0.7rem;
  width: 1.7rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold), #8d651d);
  transform: translateX(-50%);
}

.level-badge {
  position: absolute;
  right: 10%;
  bottom: 12%;
  min-width: 4.4rem;
  border: 1px solid rgba(246, 200, 95, 0.45);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  background: rgba(16, 17, 20, 0.78);
  color: var(--gold);
  font-size: 1.7rem;
  font-weight: 900;
  text-align: center;
}

.notice {
  min-height: 2.9rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 0.9rem;
  background: var(--deep-bg);
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.inventory-block,
.drop-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  background: var(--deep-bg);
}

.inventory-block h2,
.drop-block h2 {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.inventory-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.inventory-item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  grid-template-areas:
    "icon title count"
    "icon desc desc";
  align-items: center;
  column-gap: 0.5rem;
  min-height: 4.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: var(--soft-bg);
  text-align: left;
}

.inventory-item.selected {
  border-color: var(--gold);
  background: rgba(246, 200, 95, 0.14);
  box-shadow: inset 0 0 0 1px rgba(246, 200, 95, 0.2);
}

.inventory-item strong,
.inventory-item em {
  font-style: normal;
  font-weight: 900;
  font-size: 0.86rem;
}

.inventory-item strong {
  grid-area: title;
  min-width: 0;
}

.inventory-item .item-description {
  grid-area: desc;
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}

.inventory-item em {
  grid-area: count;
  color: var(--gold);
  font-size: 0.8rem;
}

.item-object {
  position: relative;
  grid-area: icon;
  display: block;
  width: 1.85rem;
  aspect-ratio: 1;
  filter: drop-shadow(0 0.25rem 0.45rem rgba(0, 0, 0, 0.35));
}

.item-object::before,
.item-object::after {
  content: "";
  position: absolute;
  inset: 0;
}

.item-object.protect::before {
  border: 0.18rem solid #8fb9ff;
  border-radius: 0.95rem 0.95rem 1.2rem 1.2rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.75), transparent 35%),
    linear-gradient(180deg, #3159a8, #172d62);
  clip-path: polygon(50% 0, 92% 16%, 82% 78%, 50% 100%, 18% 78%, 8% 16%);
}

.item-object.protect::after {
  left: 50%;
  top: 22%;
  width: 0.3rem;
  height: 1.25rem;
  border-radius: 999px;
  background: #dce9ff;
  box-shadow: -0.42rem 0.45rem 0 -0.04rem #dce9ff, 0.42rem 0.45rem 0 -0.04rem #dce9ff;
  transform: translateX(-50%);
}

.item-object.fallProtect::before {
  border: 0.18rem solid #7be4b1;
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.85), transparent 22%),
    linear-gradient(135deg, #1d8b62, #0e3f39);
}

.item-object.fallProtect::after {
  left: 50%;
  top: 18%;
  width: 1.1rem;
  height: 1.1rem;
  border-left: 0.26rem solid #dfffee;
  border-bottom: 0.26rem solid #dfffee;
  transform: translateX(-50%) rotate(-45deg);
}

.item-object.boost5::before,
.item-object.boost10::before {
  border-radius: 999px;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.9), transparent 20%),
    linear-gradient(135deg, #ffe08a, #b86b18);
  box-shadow: inset 0 0 0 0.18rem rgba(255, 255, 255, 0.45);
}

.item-object.boost10::before {
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.9), transparent 20%),
    linear-gradient(135deg, #f0a5ff, #6944d8);
}

.item-object.boost5::after,
.item-object.boost10::after {
  display: grid;
  place-items: center;
  color: #2d1b00;
  font-size: 0.76rem;
  font-weight: 1000;
}

.item-object.boost5::after {
  content: "+3";
}

.item-object.boost10::after {
  content: "+10";
  color: white;
  font-size: 0.68rem;
}

.item-object.empty-slot::before {
  border: 0.16rem dashed var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
}

.drop-rate-table {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--deeper-bg);
}

.drop-rate-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.drop-rate-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--subtle-line);
}

.drop-rate-table tr:last-child td {
  border-bottom: 0;
}

.drop-rate-table td:last-child {
  color: var(--gold);
  font-weight: 900;
  text-align: right;
}

.shop-items {
  display: grid;
  gap: 0.45rem;
}

.shop-card {
  width: min(38rem, 100%);
}

.shop-item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  grid-template-areas:
    "icon title"
    "icon meta"
    "trade trade";
  align-items: center;
  gap: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--soft-bg);
  text-align: left;
}

.shop-item .item-object {
  grid-area: icon;
  width: 1.65rem;
}

.shop-item-title {
  grid-area: title;
  display: grid;
  min-width: 0;
  gap: 0.18rem;
  align-self: end;
}

.shop-item-title strong {
  min-width: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.shop-item-meta {
  display: flex;
  grid-area: meta;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  min-width: 0;
  align-self: start;
}

.shop-item-meta span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.shop-wallet {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  background: var(--deeper-bg);
  color: var(--gold);
  font-weight: 900;
  text-align: right;
}

.shop-price {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.shop-sell-price {
  color: var(--success-text) !important;
}

.shop-buy-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.shop-trade-row {
  display: grid;
  grid-area: trade;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 0.32rem;
}

.shop-trade-row > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.shop-sell-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.shop-buy,
.shop-sell {
  display: grid;
  place-items: center;
  gap: 0.16rem;
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  background: var(--panel-soft);
  font-size: 0.88rem;
  font-weight: 900;
  line-height: 1.1;
  white-space: nowrap;
}

.shop-buy strong,
.shop-sell strong {
  color: var(--gold);
  font-size: 0.76rem;
  line-height: 1;
}

.shop-sell strong {
  color: var(--success-text);
}

.shop-sell {
  border-color: rgba(112, 224, 139, 0.42);
  color: var(--success-text);
}

.battle-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  background: var(--deep-bg);
}

.battle-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.battle-meta span {
  white-space: nowrap;
}

.hp-bar,
.time-bar {
  height: 1rem;
  overflow: hidden;
  border-radius: 999px;
  background: #0d0e11;
}

.time-bar {
  height: 0.55rem;
  margin-top: 0.55rem;
}

.hp-bar div {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--danger), var(--gold));
  transition: width 160ms ease;
}

.time-bar div {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--success), var(--accent));
  transition: width 160ms linear;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.battle-controls {
  grid-template-columns: 1fr 1fr;
}

.monster-settings,
.enhance-settings {
  display: grid;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--deep-bg);
}

.monster-settings {
  grid-template-columns: 4rem 1fr 4rem;
}

.enhance-settings {
  grid-template-columns: 4rem 1fr 4rem minmax(7rem, 1fr);
}

.stage-step {
  min-height: 3.7rem;
  padding: 0;
  font-size: 1.35rem;
}

.stage-readout {
  display: grid;
  min-height: 3.7rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--deeper-bg);
}

.stage-readout span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.stage-readout strong {
  color: var(--accent);
  font-size: 1.55rem;
  line-height: 1;
}

.monster-settings label,
.enhance-settings label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.monster-settings input,
.enhance-settings input {
  min-width: 0;
  height: 2.5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 0.75rem;
  background: #111318;
  color: var(--text);
  font: inherit;
  font-weight: 800;
}

.primary,
.secondary {
  min-height: 3.2rem;
  padding: 0.45rem 0.95rem;
  font-weight: 800;
}

.primary {
  border-radius: 8px;
  background: linear-gradient(135deg, #3d7dff, #8caeff);
  color: white;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.85rem;
  min-width: 0;
}

.settings-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.settings-row .secondary {
  min-height: 3rem;
  width: 100%;
  padding: 0.4rem 0.65rem;
  font-size: 0.82rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem;
  background: var(--surface-bg);
}

.stat span,
.progress-label,
.rates p {
  color: var(--muted);
  font-size: 0.82rem;
}

.stat strong {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.16rem;
}

#attackStat {
  font-size: 1rem;
  white-space: nowrap;
}

.progress-block,
.rates,
.probability-block {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.45rem;
}

.progress {
  height: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: #0d0e11;
}

.progress div {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.rates h2,
.probability-block h2 {
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
}

.probability-table {
  max-height: 18rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--deeper-bg);
}

.probability-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.probability-table th,
.probability-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--subtle-line);
  text-align: right;
  white-space: nowrap;
}

.probability-table th:first-child,
.probability-table td:first-child {
  text-align: left;
}

.probability-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 800;
}

.probability-table tr.current td {
  background: rgba(119, 167, 255, 0.18);
  color: var(--text);
  font-weight: 900;
}

.log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 7rem;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.log li {
  border-left: 3px solid var(--line);
  padding: 0.55rem 0.65rem;
  background: var(--deep-bg);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.log li.success {
  border-color: var(--success);
  color: var(--success-text);
}

.log li.fail {
  border-color: var(--danger);
  color: var(--fail-text);
}

.developer-message {
  display: grid;
  gap: 0.5rem;
  border-top: 1px solid var(--subtle-line);
  padding-top: 0.75rem;
}

.developer-message h2 {
  color: var(--gold);
  font-size: 1rem;
}

.developer-message textarea {
  width: 100%;
  min-height: 5.4rem;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--deep-bg);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}

.developer-message textarea::placeholder {
  color: var(--muted);
}

.developer-message button {
  width: 100%;
}

.developer-contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--subtle-line);
  border-radius: 8px;
  padding: 0.55rem;
  background: var(--deep-bg);
  color: var(--muted);
  font-size: 0.82rem;
}

.developer-contact strong {
  color: var(--text);
  word-break: break-all;
}

.developer-contact button {
  width: auto;
  min-height: 2.5rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  white-space: nowrap;
}

.developer-message .modal-hint {
  min-height: 1.2rem;
  font-size: 0.78rem;
}

.stage.success .sword {
  filter: drop-shadow(0 0 1rem rgba(112, 224, 139, 0.8));
  transform: scale(1.05);
}

.stage.fail .sword {
  filter: drop-shadow(0 0 1rem rgba(255, 107, 107, 0.7));
  transform: translateY(0.4rem) scale(0.98);
}

.battle-view.hit .monster {
  filter: drop-shadow(0 0 1rem rgba(255, 107, 107, 0.65));
  transform: scale(0.95) translateX(0.25rem);
}

.battle-view.clear .monster {
  filter: drop-shadow(0 0 1rem rgba(112, 224, 139, 0.75));
  transform: scale(1.08);
}

.battle-view.auto .monster {
  filter: drop-shadow(0 0 1.25rem rgba(119, 167, 255, 0.55));
}

.upgrade-view.auto .sword {
  filter: drop-shadow(0 0 1.25rem rgba(246, 200, 95, 0.7));
}

.stage.max .glow {
  background: rgba(246, 200, 95, 0.45);
  transform: scale(1.35);
}

@keyframes sword-slash {
  0% {
    opacity: 0;
    transform: translate(-58%, 34%) rotate(58deg) scale(calc(var(--attack-scale, 1) * 0.9));
  }

  24% {
    opacity: 1;
  }

  58% {
    opacity: 1;
    transform: translate(92%, -6%) rotate(58deg) scale(calc(var(--attack-scale, 1) * 1.14));
  }

  100% {
    opacity: 0;
    transform: translate(128%, -22%) rotate(58deg) scale(calc(var(--attack-scale, 1) * 1.02));
  }
}

@keyframes coin-drop {
  0% {
    opacity: 0;
    transform: translate(var(--coin-x, 0), -4rem) scale(0.55) rotate(0deg);
  }

  18% {
    opacity: 1;
  }

  62% {
    opacity: 1;
    transform: translate(var(--coin-x, 0), 2.8rem) scale(1) rotate(220deg);
  }

  100% {
    opacity: 0;
    transform: translate(var(--coin-x, 0), 5.3rem) scale(0.8) rotate(360deg);
  }
}

@keyframes coin-value-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, 1rem) scale(0.9);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -3rem) scale(1.06);
  }
}

@keyframes odd-even-roll {
  0% {
    filter: blur(0);
    transform: translateY(0) rotate(0deg) scale(1);
  }

  34% {
    filter: blur(0.08rem);
    transform: translateY(-0.65rem) rotate(190deg) scale(1.08);
  }

  68% {
    filter: blur(0.05rem);
    transform: translateY(0.2rem) rotate(420deg) scale(0.96);
  }

  100% {
    filter: blur(0);
    transform: translateY(0) rotate(720deg) scale(1);
  }
}

@keyframes ladder-marker-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.28);
  }
}

@keyframes item-drop-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 2.2rem) scale(0.55) rotate(-8deg);
  }

  16% {
    opacity: 1;
    transform: translate(-50%, -0.4rem) scale(1.12) rotate(3deg);
  }

  72% {
    opacity: 1;
    transform: translate(-50%, -2.2rem) scale(1) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -4.2rem) scale(0.88) rotate(6deg);
  }
}

@keyframes damage-pop {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--damage-x, 0rem)), 0.8rem) scale(0.75);
  }

  18% {
    opacity: 1;
    transform: translate(calc(-50% + var(--damage-x, 0rem)), -0.2rem) scale(1.15);
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--damage-x, 0rem)), -3.4rem) scale(1);
  }
}

@keyframes destroyed-flash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(-8deg);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(2deg);
  }

  38% {
    transform: translate(-50%, -50%) scale(0.98) rotate(-1deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.22) rotate(0deg);
  }
}

@keyframes item-depleted-flash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.72);
  }

  16% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.03);
  }

  72% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -60%) scale(0.94);
  }
}

@keyframes firework-spark {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.25);
  }

  14% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(var(--spark-x), var(--spark-y)) scale(0.9);
  }
}

@media (max-width: 800px) {
  button,
  h1,
  h2,
  .notice,
  .modal-hint,
  .stat span,
  .stat strong,
  .progress-label span,
  .battle-meta span,
  .stage-readout span,
  .stage-readout strong,
  .gamble-wallet,
  .gamble-custom-bet span,
  .gamble-custom-bet em,
  .odd-even-result,
  .ladder-result,
  .inventory-item strong,
  .inventory-item em,
  .inventory-item .item-description,
  .shop-item-title strong,
  .shop-item-meta span,
  .shop-price,
  .shop-sell-price,
  .drop-rate-table td,
  .ranking-row span,
  .ranking-meta em,
  .auth-form label span,
  .developer-contact strong,
  .developer-contact span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: keep-all;
  }

  .game {
    grid-template-columns: 1fr;
    width: min(100% - 1rem, 36rem);
    margin: 0.5rem auto;
  }

  .stage {
    min-height: 31rem;
    padding: 0.85rem;
  }

  .modal-overlay {
    align-items: start;
    padding: 0.5rem;
    overflow-y: auto;
    place-items: start center;
  }

  .modal-card {
    width: min(100%, 32rem);
    max-height: calc(100dvh - 1rem);
    overflow-y: auto;
    padding: 0.85rem;
  }

  .gamble-card {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
  }

  .modal-title-row {
    align-items: center;
    margin-bottom: 0.35rem;
  }

  .modal-card h2 {
    margin-bottom: 0;
    font-size: 1.45rem;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .controls,
  .battle-controls,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .settings-row {
    position: absolute;
    top: 4.2rem;
    right: 0.65rem;
    z-index: 60;
    width: min(12.5rem, calc(100vw - 1.3rem));
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.28rem;
    padding: 0.35rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--stage-bg);
    box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.28);
  }

  .settings-row.open {
    display: grid;
  }

  .mobile-settings-button {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    z-index: 8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 2.7rem;
    padding: 0.45rem 0.75rem;
    box-shadow: 0 0.55rem 1.2rem rgba(0, 0, 0, 0.22);
  }

  .stage > .topbar > div:first-child {
    padding-right: 6.2rem;
  }

  .ranking-register {
    grid-template-columns: 1fr;
  }

  .auth-actions {
    grid-template-columns: 1fr;
  }

  .google-auth-button {
    display: none;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
    width: 100%;
    max-width: none;
    justify-content: stretch;
  }

  .battle-view .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-enhance-settings {
    position: static;
    grid-column: 1 / -1;
    right: 0;
    width: 100%;
    grid-template-columns: 1fr;
  }

  .auto-target-controls {
    width: 100%;
    grid-template-columns: 2.35rem minmax(6.2rem, 1fr) 2.35rem;
  }

  .primary,
  .secondary {
    min-height: 3.6rem;
    padding: 0.55rem 1rem;
    font-size: 0.95rem;
  }

  .settings-row .secondary {
    min-height: 2.35rem;
    padding: 0.28rem 0.35rem;
    font-size: 0.72rem;
  }

  .gamble-bet-row {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .gamble-bet-row > span {
    min-height: 0;
    font-size: 0.86rem;
  }

  .gamble-bet-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .gamble-bet-options .secondary {
    min-height: 3rem;
    padding: 0.45rem 0.4rem;
    font-size: 0.84rem;
  }

  .gamble-custom-bet {
    margin-top: 0;
  }

  .gamble-tabs,
  .gamble-choice-row {
    gap: 0.35rem;
  }

  .gamble-tabs .secondary,
  .gamble-choice-row button {
    min-height: 3.05rem;
    padding: 0.5rem 0.45rem;
    font-size: 0.88rem;
  }

  .developer-contact {
    grid-template-columns: 1fr;
  }

  .developer-contact button {
    width: 100%;
  }

  .compact-action,
  .icon-button {
    min-height: 2.9rem;
    padding: 0.52rem 0.55rem;
    font-size: 0.82rem;
  }

  #swordName {
    max-width: calc(100vw - 2rem);
    font-size: clamp(1.1rem, 5vw, 1.65rem);
  }

  .battle-view h1 {
    max-width: calc(100vw - 7.5rem);
    font-size: clamp(1.15rem, 5vw, 1.65rem);
  }

  .coffee-button {
    padding: 0.58rem 0.7rem;
    font-size: clamp(0.88rem, 3.2vw, 1rem);
  }

  .enhance-settings {
    grid-template-columns: 3.5rem 1fr 3.5rem;
  }

  .enhance-settings #autoEnhanceStartButton {
    grid-column: 1 / -1;
  }

  .top-enhance-settings .stage-step {
    width: 2.35rem;
    min-height: 2.8rem;
    font-size: 1.05rem;
  }

  .top-enhance-settings #autoEnhanceStartButton {
    min-width: 7.5rem;
    min-height: 2.8rem;
    font-size: 0.95rem;
  }

  .auto-item-status {
    padding: 0.45rem;
  }

  .auto-item-row {
    grid-template-columns: 1.2rem minmax(0, 1fr);
    gap: 0.28rem;
    padding: 0.48rem 0.25rem;
  }

  .auto-item-row .item-object {
    width: 1.15rem;
  }

  .auto-item-name {
    font-size: clamp(0.72rem, 3vw, 0.82rem);
  }

  .auto-item-row strong {
    font-size: 0.66rem;
  }

  .shop-item {
    grid-template-columns: 1.35rem minmax(0, 1fr);
    grid-template-areas:
      "icon title"
      "icon meta"
      "trade trade";
    gap: 0.38rem;
    padding: 0.55rem;
  }

  .shop-item .item-object {
    width: 1.35rem;
  }

  .shop-item-title strong {
    font-size: clamp(0.78rem, 3.1vw, 0.9rem);
  }

  .shop-item-meta {
    gap: 0.25rem 0.55rem;
  }

  .shop-price {
    font-size: 0.78rem;
  }

  .shop-trade-row {
    grid-template-columns: 1fr;
  }

  .shop-trade-row > span {
    font-size: 0.72rem;
  }

  .shop-buy-row,
  .shop-sell-row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .shop-buy,
  .shop-sell {
    min-height: 3rem;
    font-size: 0.94rem;
  }

  .monster-settings {
    grid-template-columns: 3.5rem 1fr 3.5rem;
  }

  .battle-meta {
    gap: 0.5rem;
    font-size: 0.82rem;
  }

  .panel {
    min-height: 25rem;
    padding-top: 0.85rem;
  }

  .level-badge {
    right: 0.75rem;
    bottom: 10%;
    min-width: 2.8rem;
    padding: 0.32rem 0.48rem;
    font-size: 1.05rem;
    line-height: 1;
  }

  .monster-stage {
    right: 0.75rem;
    top: 0.75rem;
    bottom: auto;
    min-width: 4.9rem;
    padding: 0.34rem 0.45rem;
    font-size: 0.78rem;
    line-height: 1;
  }

  body {
    min-height: 100dvh;
  }

  .game {
    gap: 0.45rem;
    min-height: auto;
  }

  .stage {
    gap: 0.45rem;
    min-height: calc(100dvh - 1rem);
    padding: 0.65rem;
  }

  .stage > .topbar > div:first-child {
    padding-right: 5.7rem;
  }

  .stage .coffee-button {
    display: none;
  }

  .upgrade-view > .topbar > div:first-child,
  .battle-view > .topbar > div:first-child {
    position: relative;
    padding: 0 5.7rem 0 7.7rem;
    text-align: center;
  }

  .upgrade-view .coffee-button,
  .battle-view .coffee-button {
    position: absolute;
    left: 0;
    top: 0;
    display: inline-flex;
    width: 7.2rem;
    min-height: 1.75rem;
    margin-top: 0;
    align-items: center;
    justify-content: center;
    padding: 0.18rem 0.28rem;
    font-size: 0.42rem;
    font-weight: 900;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
  }

  .upgrade-view .eyebrow,
  .upgrade-view #swordName,
  .battle-view .eyebrow,
  .battle-view #monsterName {
    max-width: 100%;
    text-align: center;
  }

  .mobile-inventory-button {
    display: inline-grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: center;
    gap: 0.28rem;
  }

  .top-actions .compact-action,
  .top-actions .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.85rem;
    padding: 0.48rem 0.42rem;
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1;
    white-space: nowrap;
  }

  .bag-icon {
    position: relative;
    display: inline-block;
    width: 0.92rem;
    height: 0.82rem;
    flex: 0 0 auto;
    border: 0.13rem solid var(--gold);
    border-radius: 0.16rem 0.16rem 0.22rem 0.22rem;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent),
      rgba(246, 200, 95, 0.16);
  }

  .bag-icon::before {
    content: "";
    position: absolute;
    left: 50%;
    top: -0.42rem;
    width: 0.48rem;
    height: 0.42rem;
    border: 0.12rem solid var(--gold);
    border-bottom: 0;
    border-radius: 999px 999px 0 0;
    transform: translateX(-50%);
  }

  .top-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
  }

  .battle-view .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-actions .compact-action,
  .top-actions .icon-button {
    min-height: 2.85rem;
    padding: 0.48rem 0.42rem;
    font-size: 0.82rem;
    line-height: 1;
  }

  .mobile-status-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
  }

  .mobile-status-bar > div {
    display: flex;
    min-height: 2.55rem;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 0.32rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.38rem 0.42rem;
    background: var(--surface-bg);
  }

  .mobile-status-bar span {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    line-height: 1;
  }

  .mobile-status-bar strong {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 0.12rem;
    flex: 1 1 auto;
    overflow: hidden;
    margin-top: 0;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 900;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-status-bar strong .gold-coin-icon,
  #gold .gold-coin-icon,
  #cost .gold-coin-icon,
  #mobileGold .gold-coin-icon,
  #mobileCost .gold-coin-icon,
  #monsterReward .gold-coin-icon,
  .gamble-wallet .gold-coin-icon {
    flex: 0 0 auto;
    margin-left: 0.1em;
  }

  #gold,
  #cost,
  #mobileGold,
  #mobileCost,
  #monsterReward,
  .gamble-wallet,
  .shop-price,
  .shop-sell-price,
  .shop-price-list span,
  .shop-wallet,
  .coin-value {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 0.1em;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sword-area,
  .monster-area {
    min-height: clamp(11rem, 34dvh, 16rem);
  }

  .sword {
    width: min(10.8rem, 44vw);
    height: min(17rem, 45dvh);
  }

  .monster {
    width: min(13rem, 58vw);
    height: min(13rem, 58vw);
  }

  .notice {
    min-height: 2.25rem;
    padding: 0.55rem 0.65rem;
    font-size: 0.78rem;
  }

  .inventory-block,
  .drop-block,
  .battle-view .battle-inventory-block {
    display: none;
  }

  .upgrade-view > .inventory-block,
  .battle-view > .inventory-block,
  .battle-view > .drop-block {
    display: none;
  }

  .controls {
    gap: 0.35rem;
  }

  .controls .primary,
  .controls .secondary {
    min-height: 3.2rem;
  }

  .battle-status,
  .battle-timer,
  .monster-settings {
    padding: 0.55rem;
  }

  .panel {
    min-height: auto;
    padding: 0.65rem;
  }

  .panel .stats-grid,
  .panel .progress-block,
  .panel .rates,
  .panel .probability-block,
  .panel .log {
    display: none;
  }

  .developer-message {
    border-top: 0;
    padding-top: 0;
  }

  .developer-message textarea {
    min-height: 4.4rem;
  }

  .stage > .topbar > div:first-child {
    width: 100%;
    padding-right: 5.7rem;
    text-align: center;
  }

  .upgrade-view .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upgrade-view #autoEnhanceButton {
    grid-column: 1 / -1;
  }

  .top-actions {
    justify-items: stretch;
  }

  .top-actions .compact-action,
  .top-actions .icon-button {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.45rem 0.38rem;
    font-size: 0.8rem;
  }

  .top-enhance-settings {
    justify-items: stretch;
  }

  .auto-target-controls {
    justify-self: stretch;
  }
}
