:root {
  color-scheme: dark;
  --bg: #111316;
  --panel: rgba(20, 23, 27, 0.72);
  --text: #f8f5ec;
  --muted: #b8b4aa;
  --line: rgba(255, 255, 255, 0.15);
  --gold: #f8c14a;
  --green: #4ade80;
  --blue: #60a5fa;
  --pink: #fb7185;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #090a0c;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.idle-shell {
  position: relative;
  display: grid;
  width: 100%;
  max-width: 520px;
  height: 100svh;
  min-height: 620px;
  margin: 0 auto;
  grid-template-rows: auto 1fr auto auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 15%, rgba(96, 165, 250, 0.16), transparent 33%),
    linear-gradient(180deg, #1a1d22 0%, #111316 58%, #08090b 100%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 24px 80px rgba(0, 0, 0, 0.58);
  touch-action: manipulation;
  user-select: none;
}

.topbar {
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 14px 8px;
}

.topbar > div,
.progress-panel,
.actions button,
.modal-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(16px);
}

.topbar > div {
  min-width: 0;
  padding: 8px 9px;
}

.topbar span,
.progress-panel span,
.actions span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.topbar strong,
.progress-panel strong,
.actions strong {
  display: block;
  overflow: hidden;
  font-size: 18px;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena {
  position: relative;
  display: grid;
  min-height: 0;
  grid-template-rows: auto 1fr auto auto;
  padding: 8px 14px 10px;
}

.stage-label {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.stage-label span {
  font-size: 12px;
}

.stage-label strong {
  max-width: 62%;
  overflow: hidden;
  color: var(--text);
  font-size: 16px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enemy-wrap {
  position: relative;
  display: grid;
  min-height: 220px;
  place-items: center;
}

.enemy {
  position: relative;
  width: clamp(116px, 34vw, 170px);
  aspect-ratio: 1;
  border-radius: 48% 52% 44% 56%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255,255,255,0.55), transparent 11%),
    linear-gradient(145deg, #4ade80, #15803d);
  box-shadow: 0 18px 54px rgba(74, 222, 128, 0.28), inset 0 -18px 32px rgba(0, 0, 0, 0.22);
  transition: transform 120ms ease;
}

.enemy.is-hit {
  transform: scale(0.94) translateY(8px);
}

.enemy-eye {
  position: absolute;
  top: 38%;
  width: 13%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #101114;
}

.enemy-eye.left {
  left: 32%;
}

.enemy-eye.right {
  right: 32%;
}

.skill-ring {
  position: absolute;
  width: 120px;
  aspect-ratio: 1;
  border: 3px solid rgba(96, 165, 250, 0);
  border-radius: 999px;
  pointer-events: none;
}

.skill-ring.cast {
  animation: castRing 420ms ease-out;
}

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

.damage {
  position: absolute;
  left: 50%;
  top: 48%;
  color: var(--gold);
  font-weight: 900;
  text-shadow: 0 2px 0 #5c2f04, 0 0 20px rgba(248, 193, 74, 0.45);
  transform: translate(-50%, -50%);
  animation: damageRise 760ms ease-out forwards;
}

.hpbar,
.expbar {
  height: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
}

.hpbar span,
.expbar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 180ms ease;
}

.hpbar span {
  background: linear-gradient(90deg, #fb7185, #f97316);
}

.expbar span {
  background: linear-gradient(90deg, #60a5fa, #34d399);
}

.hero-wrap {
  position: relative;
  display: grid;
  min-height: 128px;
  place-items: center;
}

.hero-aura {
  position: absolute;
  width: 118px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.24), transparent 66%);
  filter: blur(2px);
}

.hero {
  position: relative;
  width: 72px;
  aspect-ratio: 0.76;
  border-radius: 24px 24px 12px 12px;
  background:
    linear-gradient(180deg, #f8f5ec 0 24%, #60a5fa 25% 68%, #1d4ed8 69%);
  box-shadow: 0 14px 40px rgba(96, 165, 250, 0.25);
}

.hero::before {
  content: "";
  position: absolute;
  right: -20px;
  top: 30%;
  width: 46px;
  height: 10px;
  border-radius: 999px;
  background: #f8c14a;
  transform: rotate(-28deg);
  transform-origin: left center;
}

.strike-btn {
  position: absolute;
  right: 0;
  bottom: 6px;
  min-width: 98px;
  min-height: 44px;
  border-radius: 8px;
  background: var(--text);
  color: #111316;
  font-weight: 900;
}

.progress-panel {
  margin: 0 14px 10px;
  padding: 10px;
}

.progress-panel > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.progress-panel p {
  min-height: 18px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 14px max(14px, env(safe-area-inset-bottom));
}

.actions button {
  min-width: 0;
  min-height: 58px;
  padding: 8px 6px;
  color: var(--text);
}

.actions button:active,
.strike-btn:active {
  transform: translateY(1px) scale(0.99);
}

.actions button[disabled] {
  opacity: 0.45;
}

.offline-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0, 0, 0, 0.54);
}

.modal-box {
  width: min(100%, 340px);
  padding: 20px;
  text-align: center;
}

.modal-box h1 {
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 0.98;
  letter-spacing: 0;
}

.modal-box p {
  margin: 0 0 16px;
  color: var(--muted);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal-actions button {
  min-width: 0;
  min-height: 46px;
  border-radius: 8px;
  background: var(--text);
  color: #111316;
  font-weight: 900;
  font-size: 14px;
}

.modal-actions .secondary {
  background: var(--gold);
}

.ad-toast {
  position: absolute;
  right: 14px;
  bottom: 94px;
  z-index: 21;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.ad-toast p {
  margin: 0;
}

.game-ad {
  position: absolute;
  left: 50%;
  z-index: 18;
  width: min(94%, 468px);
  min-height: 64px;
  transform: translateX(-50%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 23, 27, 0.64);
}

.game-ad-top {
  top: max(72px, calc(env(safe-area-inset-top) + 60px));
}

.game-ad-bottom {
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 72px));
}

.game-ad:empty {
  display: none;
}

@keyframes damageRise {
  0% {
    opacity: 0;
    transform: translate(-50%, 2px) scale(0.72);
  }
  14% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), -88px) scale(1.16);
  }
}

@keyframes castRing {
  0% {
    opacity: 0.95;
    border-color: rgba(96, 165, 250, 0.85);
    box-shadow: 0 0 20px rgba(96, 165, 250, 0.55);
    transform: scale(0.35);
  }
  100% {
    opacity: 0;
    border-color: rgba(248, 193, 74, 0.7);
    box-shadow: 0 0 80px rgba(248, 193, 74, 0.52);
    transform: scale(var(--skill-scale, 2));
  }
}

@media (max-height: 680px) {
  .idle-shell {
    min-height: 560px;
  }

  .enemy-wrap {
    min-height: 188px;
  }

  .hero-wrap {
    min-height: 106px;
  }

  .actions button {
    min-height: 52px;
  }
}
