:root {
  --bg: #11131a;
  --panel: #202534;
  --ink: #e8ecff;
  --muted: #a6b0cc;
  --line: #3a4568;
  --good: #72f27a;
  --bad: #ff7f7f;
  --player: #89b4ff;
  --bot: #9da6ba;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Press Start 2P', system-ui, sans-serif;
}

.game-shell {
  width: 100vw;
  height: 100vh;
  padding: 1rem;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.95rem;
  max-width: 1400px;
  margin: 0 auto;
}

.hidden {
  display: none;
}

.screen-panel {
  width: min(1100px, 100%);
  border: 2px solid var(--line);
  background: rgba(23, 30, 49, 0.92);
  padding: clamp(0.9rem, 2vw, 1.35rem);
  text-align: center;
  display: grid;
  gap: 0.85rem;
}

.screen-panel.compact {
  width: min(620px, 100%);
}

.screen-panel.wide {
  width: 100%;
}

.centered-panel {
  margin-inline: auto;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(1rem, 2.1vw, 1.45rem);
  letter-spacing: 1px;
  text-align: center;
}

.subtitle,
.muted,
.label,
.status,
button,
select,
input,
summary,
legend {
  font-size: clamp(0.55rem, 1vw, 0.75rem);
  line-height: 1.5;
}

.subtitle,
.muted {
  color: var(--muted);
  margin: 0;
  text-align: center;
}

.label {
  margin-top: 0.45rem;
  text-align: left;
}

.select,
.sprite-input,
.primary-btn,
.secondary-btn,
.volume-slider {
  width: 100%;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0.72rem;
  font: inherit;
  border-radius: 0;
}

.primary-btn,
.secondary-btn,
summary,
.capsule {
  cursor: pointer;
}

.primary-btn {
  border-color: #5a86d8;
}

.secondary-btn {
  border-color: #8b95b4;
}

.music-panel,
.sprite-panel {
  border: 2px solid var(--line);
  padding: 0.7rem;
  background: #1a1f2d;
  text-align: left;
}

.music-panel legend {
  padding: 0 0.35rem;
}

.volume-slider {
  padding: 0.3rem;
}

.sprite-panel summary {
  margin-bottom: 0.7rem;
}

.xp-loader {
  width: 100%;
  border: 2px solid var(--line);
  background: #1b2132;
  height: 22px;
}

.xp-loader-fill {
  height: 100%;
  width: 0;
  background: #8ce2ff;
  transition: width 120ms linear;
}

#gameScreen.active {
  justify-content: stretch;
  align-items: stretch;
}

.hud {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 0.8rem;
  align-items: stretch;
}

.score-card,
.center-info {
  background: var(--panel);
  border: 2px solid var(--line);
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.score-card.enemy {
  border-color: #6e778a;
}

.center-info {
  align-items: center;
}

.score {
  margin: 0.45rem 0 0;
  font-size: clamp(0.95rem, 2vw, 1.35rem);
}

.status {
  min-height: 2.1em;
  margin-top: 0.45rem;
}

.status.good { color: var(--good); }
.status.bad { color: var(--bad); }

.arena {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 2px solid var(--line);
  background: #0f1321;
  overflow: hidden;
}

.arena-background {
  position: absolute;
  inset: 0;
  background-color: #151b2d;
  background-size: cover;
  background-position: center;
  image-rendering: pixelated;
}

.capsule {
  position: absolute;
  width: clamp(52px, 6vw, 78px);
  height: clamp(52px, 6vw, 78px);
  background: #d8e2ff;
  border: 3px solid #26355d;
  border-radius: 10px;
  z-index: 3;
  display: grid;
  place-items: center;
  image-rendering: pixelated;
  padding: 0;
  animation: bob 1s steps(2) infinite;
  transition: left 320ms linear, top 320ms linear;
}

#capsuleSprite {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

#capsuleLabel {
  color: #1f2e56;
  font-size: clamp(0.55rem, 1vw, 0.72rem);
}

.claim-hand {
  position: absolute;
  width: clamp(96px, 12vw, 160px);
  height: auto;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  image-rendering: pixelated;
  transform: translate3d(0, 0, 0);
  transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 120ms linear;
}

.claim-hand.show {
  opacity: 1;
}

.claim-hand.player {
  filter: drop-shadow(2px 2px 0 #000);
}

.claim-hand.bot {
  filter: saturate(0) brightness(1.08) contrast(0.9) drop-shadow(2px 2px 0 #000);
}

.game-actions {
  margin-top: 0.7rem;
  display: flex;
  justify-content: center;
}

.game-actions .secondary-btn {
  width: min(280px, 100%);
}

.result-actions {
  display: grid;
  gap: 0.6rem;
}

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

@media (max-width: 760px) {
  .hud {
    grid-template-columns: 1fr;
  }
}
