:root {
  color-scheme: dark;
  --text: #f4f5f7;
  --muted: rgba(244,245,247,0.82);
  --panel: rgba(10, 14, 22, 0.58);
  --panel-border: rgba(255,255,255,0.08);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #04060a;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
}

body {
  touch-action: none;
  overscroll-behavior: none;
}

.game-shell {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100vw;
  height: 100svh;
  height: 100dvh;
  overflow: hidden;
  background: #05070b;
}

.top-hud {
  position: relative;
  z-index: 4;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px;
  background: linear-gradient(180deg, rgba(5,8,14,0.94), rgba(5,8,14,0.7));
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

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

.brand-row {
  margin-bottom: 8px;
}

.brand {
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.92);
}

.hud-pair {
  display: flex;
  gap: 6px;
}

.hud-chip {
  min-width: 60px;
  padding: 6px 8px;
  border-radius: 12px;
  background: rgba(10, 14, 22, 0.3);
  border: 1px solid var(--panel-border);
  text-align: center;
  backdrop-filter: blur(6px);
}

.hud-chip.wide {
  flex: 1;
  min-width: 0;
}

.label {
  display: block;
  font-size: 0.56rem;
  opacity: 0.72;
  text-transform: uppercase;
}

.pause-btn {
  min-width: 72px;
  font: inherit;
  font-weight: 700;
  color: white;
  cursor: pointer;
}

.health-row {
  margin-bottom: 8px;
}

.player-health-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.05);
  overflow: hidden;
}

.player-health-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(121,255,139,0.82), rgba(255,211,111,0.68) 68%, rgba(255,123,123,0.64));
  transform-origin: left center;
}

.hp-inline {
  margin-top: 4px;
  font-size: 0.74rem;
  color: rgba(255,255,255,0.9);
}

.arena-region {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #04060a;
}

.arena-viewport {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

canvas {
  display: block;
  background: #04060a;
  touch-action: none;
}

.status-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 460px);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(7,11,18,0.55);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  z-index: 4;
  pointer-events: none;
}

.controls-band {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px calc(env(safe-area-inset-bottom) + 12px);
  background: linear-gradient(180deg, rgba(10,14,22,0.88), rgba(10,14,22,0.98));
  border-top: 1px solid rgba(255,255,255,0.05);
  z-index: 4;
}

.right-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.joystick-slot {
  display: flex;
  align-items: center;
  justify-content: center;
}

.stick-zone {
  position: relative;
  width: 116px;
  height: 116px;
  touch-action: none;
}

.stick-base,
.stick-knob {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
}

.stick-base {
  left: 12px;
  top: 12px;
  width: 92px;
  height: 92px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.14);
}

.stick-knob {
  left: 38px;
  top: 38px;
  width: 40px;
  height: 40px;
  background: rgba(123,231,255,0.34);
  transition: left 120ms cubic-bezier(0.2, 0.8, 0.2, 1.05), top 120ms cubic-bezier(0.2, 0.8, 0.2, 1.05), opacity 120ms ease;
}

.stick-base.attack {
  background: rgba(255,255,255,0.1);
}

.stick-knob.attack {
  background: rgba(255,168,115,0.34);
}

.special-btn,
.dash-btn {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,140,80,0.22);
  color: white;
  font: inherit;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}

.special-btn {
  background: rgba(118, 82, 255, 0.24);
  border-color: rgba(190, 170, 255, 0.28);
}

.special-btn.ready {
  box-shadow: 0 0 0 2px rgba(190,170,255,0.18), 0 0 18px rgba(150,110,255,0.45), 0 0 32px rgba(150,110,255,0.25);
  animation: specialPulse 900ms ease-in-out infinite;
}

@keyframes specialPulse {
  0%, 100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.2);
  }
}

.pause-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5,7,12,0.42);
  z-index: 6;
}

.pause-panel {
  width: min(92vw, 420px);
  padding: 20px 18px;
  border-radius: 22px;
  background: rgba(10,14,22,0.82);
  border: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  backdrop-filter: blur(10px);
}

.pause-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 2.8rem);
}

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

.overlay-actions {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  height: 44px;
  border: none;
  border-radius: 999px;
  font: inherit;
  font-weight: 800;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, #75ff8d, #4bd2a7);
}

.action-btn.ghost {
  background: rgba(255,255,255,0.1);
}

@media (orientation: landscape) {
  .game-shell {
    display: block;
  }

  .top-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: none;
    border: none;
    padding: calc(env(safe-area-inset-top) + 8px) 14px 0;
    pointer-events: none;
  }

  .top-hud .hud-pair,
  .top-hud .pause-btn {
    pointer-events: auto;
  }

  .brand-row {
    margin-bottom: 4px;
  }

  .hud-chip {
    min-width: 58px;
    padding: 5px 7px;
    background: rgba(10,14,22,0.18);
  }

  .health-row {
    max-width: 320px;
    margin-bottom: 4px;
  }

  .gear-row {
    gap: 6px;
  }

  .hud-chip.wide {
    flex: 0 1 140px;
  }

  .arena-region {
    position: absolute;
    inset: 0;
  }

  .status-toast {
    top: calc(env(safe-area-inset-top) + 58px);
  }

  .controls-band {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: none;
    border: none;
    padding: 0 18px calc(env(safe-area-inset-bottom) + 18px);
    pointer-events: none;
  }

  .left-slot,
  .right-controls,
  .dash-btn,
  .stick-zone {
    pointer-events: auto;
  }

  .right-controls {
    gap: 14px;
  }

  .stick-zone {
    width: 88px;
    height: 88px;
  }

  .stick-base {
    width: 68px;
    height: 68px;
    left: 10px;
    top: 10px;
  }

  .stick-knob {
    left: 24px;
    top: 24px;
  }

  .dash-btn {
    width: 52px;
    height: 52px;
    margin-bottom: 52px;
  }
}
