:root {
  --bg-top: #071126;
  --bg-bottom: #1b1030;
  --panel: rgba(10, 18, 40, 0.74);
  --panel-border: rgba(255, 255, 255, 0.12);
  --highlight: #7df9ff;
  --highlight-warm: #ffd166;
  --danger: #ff6577;
  --boss: #ff9f68;
  --mint: #9ff7d4;
  --text-main: #f7f4ea;
  --text-soft: rgba(247, 244, 234, 0.72);
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI Variable Text", "Trebuchet MS", "Verdana", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at top, rgba(125, 249, 255, 0.18), transparent 34%),
    radial-gradient(circle at 80% 20%, rgba(255, 209, 102, 0.16), transparent 28%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 92%);
  pointer-events: none;
}

.background-glow {
  position: fixed;
  width: 40vw;
  height: 40vw;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  pointer-events: none;
}

.background-glow-left {
  top: 12%;
  left: -10%;
  background: rgba(125, 249, 255, 0.45);
}

.background-glow-right {
  right: -10%;
  bottom: 8%;
  background: rgba(255, 101, 119, 0.35);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding:
    max(28px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(28px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}

.game-card {
  width: min(100%, 780px);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 32px;
  padding: 24px;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(125, 249, 255, 0.16), transparent 26%),
    radial-gradient(circle at 100% 100%, rgba(255, 209, 102, 0.12), transparent 30%);
  pointer-events: none;
}

.panel-header,
.controls,
.boss-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.panel-header {
  margin-bottom: 20px;
}

.panel-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--highlight);
  font-size: 0.72rem;
}

.player-tag {
  display: inline-flex;
  align-items: center;
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(159, 247, 212, 0.1);
  border: 1px solid rgba(159, 247, 212, 0.24);
  color: var(--mint);
  font-size: 0.92rem;
}

h1,
h2 {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  letter-spacing: 0.04em;
}

h1 {
  font-size: clamp(2rem, 6vw, 3.2rem);
}

.ghost-button,
.primary-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.ghost-button {
  min-height: 48px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font-weight: 700;
}

.ghost-button.ready {
  background: linear-gradient(135deg, #7df9ff 0%, #ffd166 100%);
  color: #071126;
  box-shadow: 0 14px 28px rgba(125, 249, 255, 0.22);
}

.ghost-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  min-height: 52px;
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--highlight) 0%, #4ca5ff 100%);
  color: #071126;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(76, 165, 255, 0.28);
}

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.hud-block,
.control-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 14px 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hud-label,
.control-title {
  display: block;
  color: var(--text-soft);
  font-size: 0.84rem;
  margin-bottom: 6px;
}

.hud strong {
  font-size: 1.35rem;
  display: block;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.boss-panel {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 20px;
  background: rgba(255, 159, 104, 0.08);
  border: 1px solid rgba(255, 159, 104, 0.22);
}

.boss-panel.active {
  opacity: 1;
  transform: translateY(0);
}

.boss-meta {
  font-size: 0.9rem;
  color: var(--text-main);
  margin-bottom: 10px;
}

.boss-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.35);
}

.boss-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6577 0%, #ff9f68 55%, #ffd166 100%);
  box-shadow: 0 0 18px rgba(255, 159, 104, 0.45);
  transition: width 120ms linear;
}

.hero-note {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(125, 249, 255, 0.12);
  background:
    radial-gradient(circle at top left, rgba(125, 249, 255, 0.12), transparent 35%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.hero-kicker {
  margin: 0 0 10px;
  color: var(--highlight-warm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.hero-copy h2 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
  margin-bottom: 10px;
}

.hero-copy p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.7;
}

.hero-stats {
  display: grid;
  gap: 12px;
}

.hero-stat {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.hero-stat span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.hero-stat strong {
  display: block;
  line-height: 1.45;
}

.playfield-frame {
  position: relative;
  display: grid;
  gap: 14px;
  justify-items: center;
  padding: 18px;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.battle-stage {
  position: relative;
  width: min(100%, 420px);
}

canvas {
  width: 100%;
  height: auto;
  border-radius: 20px;
  display: block;
  background:
    radial-gradient(circle at 50% 10%, rgba(125, 249, 255, 0.18), transparent 42%),
    linear-gradient(180deg, #08101f 0%, #050912 100%);
  box-shadow: inset 0 0 50px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

.arena-hud {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 420px);
  pointer-events: none;
}

.arena-pill {
  min-height: 70px;
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(7, 17, 38, 0.88), rgba(7, 17, 38, 0.66));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.2);
}

.arena-pill-wide {
  grid-column: span 2;
}

.arena-pill-label {
  display: block;
  margin-bottom: 4px;
  color: rgba(247, 244, 234, 0.6);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.arena-pill strong {
  display: block;
  color: var(--text-main);
  font-size: 0.96rem;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.arena-emp-button {
  --emp-progress: 0;
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 2;
  width: 78px;
  height: 78px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  background:
    radial-gradient(circle at 50% 50%, rgba(8, 16, 31, 0.96) 0 56%, transparent 57%),
    conic-gradient(from -90deg, rgba(125, 249, 255, 0.95) calc(var(--emp-progress) * 1%), rgba(255, 255, 255, 0.12) 0);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 12px 24px rgba(0, 0, 0, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.playfield-frame.menu-open .arena-hud {
  display: none;
}

.playfield-frame.menu-open .arena-emp-button {
  opacity: 0;
  pointer-events: none;
}

.arena-emp-button::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(125, 249, 255, 0.12), rgba(8, 16, 31, 0.94) 70%);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.arena-emp-button:disabled {
  cursor: default;
  filter: saturate(0.6) brightness(0.75);
}

.arena-emp-button.ready {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    0 0 22px rgba(125, 249, 255, 0.32),
    0 14px 28px rgba(0, 0, 0, 0.34);
  filter: brightness(1.08);
}

.arena-emp-button:not(:disabled):hover {
  transform: translateY(-1px) scale(1.02);
}

.arena-emp-inner {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  text-align: center;
}

.arena-emp-title {
  display: block;
  margin-top: 14px;
  color: rgba(247, 244, 234, 0.84);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.arena-emp-percent {
  display: block;
  margin-top: -10px;
  color: var(--highlight);
  font-size: 0.92rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.overlay {
  position: absolute;
  inset: 18px;
  z-index: 4;
  display: none;
  justify-items: center;
  align-content: start;
  padding: 18px;
  border-radius: 20px;
  background: rgba(3, 7, 17, 0.72);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.overlay.visible {
  display: grid;
}

.overlay-card {
  width: min(100%, 420px);
  max-width: 420px;
  text-align: center;
}

.overlay-card p {
  color: var(--text-soft);
  line-height: 1.7;
}

.overlay-guide {
  display: grid;
  gap: 10px;
  margin: 16px 0 18px;
  text-align: left;
}

.guide-item {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.guide-title {
  display: block;
  margin-bottom: 6px;
  color: var(--highlight);
  font-weight: 700;
}

.guide-item p {
  margin: 0;
  font-size: 0.95rem;
}

.controls {
  margin-top: 20px;
  flex-wrap: wrap;
}

.control-card p {
  margin: 0;
  color: var(--text-main);
  line-height: 1.6;
}

@media (max-width: 720px) {
  .game-card {
    padding: 18px;
    border-radius: 24px;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .overlay {
    inset: 12px;
    padding: 14px;
  }

  .boss-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .hero-note {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .ghost-button,
  .primary-button {
    width: 100%;
  }

  .hud-block,
  .control-card {
    min-width: calc(50% - 8px);
  }

  .arena-emp-button {
    left: 12px;
    bottom: 12px;
    width: 72px;
    height: 72px;
  }

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

@media (max-width: 520px) {
  .playfield-frame {
    padding: 12px;
    gap: 10px;
  }

  .overlay-card {
    max-width: 100%;
  }

  .overlay-guide {
    gap: 8px;
  }

  .guide-item {
    padding: 9px 10px;
    border-radius: 14px;
  }

  .arena-emp-button {
    left: 10px;
    bottom: 10px;
    width: 68px;
    height: 68px;
  }

  .arena-hud {
    gap: 6px;
  }

  .arena-pill {
    padding: 8px 10px;
    border-radius: 14px;
    min-height: 62px;
  }

  .arena-pill strong {
    font-size: 0.88rem;
  }
}
