:root {
  --accent1: #00e5ff;
  --accent2: #ff2bd6;
  --accent3: #fff36d;
  --bg0: #02030a;
  --bg1: #071123;
  --panel: rgba(5, 10, 24, 0.82);
  --panel-strong: rgba(3, 7, 18, 0.94);
  --line: rgba(255, 255, 255, 0.16);
  --text: #eefcff;
  --muted: #9fb7c4;
  --shadow: rgba(0, 0, 0, 0.55);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% 15%, color-mix(in srgb, var(--accent1) 20%, transparent), transparent 36%),
    radial-gradient(circle at 88% 74%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 32%),
    linear-gradient(135deg, var(--bg0), var(--bg1));
}

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  padding: 54px 14px 84px;
}

.hud {
  position: fixed;
  top: 10px;
  left: 50%;
  z-index: 5;
  width: min(760px, calc(100vw - 20px));
  height: 46px;
  display: grid;
  grid-template-columns: 112px 1fr 112px;
  align-items: center;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-strong) 84%, transparent);
  box-shadow: 0 12px 28px var(--shadow), 0 0 26px color-mix(in srgb, var(--accent1) 22%, transparent);
  backdrop-filter: blur(14px);
}

.hud-player {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.hud-left {
  color: var(--accent1);
}

.hud-right {
  color: var(--accent2);
}

.hud-label,
.hud-center small {
  color: var(--muted);
  font-size: 0.76rem;
}

.hud-player strong {
  min-width: 32px;
  font-size: 1.8rem;
  line-height: 1;
  text-shadow: 0 0 12px currentColor;
}

.hud-player strong.pop {
  animation: scorePop 460ms cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

@keyframes scorePop {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.55);
    filter: brightness(1.5);
  }
  100% {
    transform: scale(1);
  }
}

.hud-center {
  min-width: 0;
  text-align: center;
}

#matchState {
  display: block;
  overflow: hidden;
  font-size: 0.95rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#matchMeta {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arena-wrap {
  position: relative;
  width: min(100%, 1100px);
  height: 100%;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

canvas {
  display: block;
  width: min(100%, 1100px);
  max-height: calc(100vh - 150px);
  aspect-ratio: 3 / 2;
  height: auto;
  border: 1px solid color-mix(in srgb, var(--accent1) 52%, var(--line));
  border-radius: var(--radius);
  background: #02040a;
  box-shadow:
    0 28px 54px rgba(0, 0, 0, 0.72),
    0 0 34px color-mix(in srgb, var(--accent1) 22%, transparent),
    inset 0 0 34px rgba(255, 255, 255, 0.04);
}

.quickbar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 5;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--panel-strong) 82%, transparent);
  box-shadow: 0 14px 26px var(--shadow);
  backdrop-filter: blur(14px);
}

.icon-btn,
.primary-btn,
.secondary-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, border-color 140ms ease;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}

.primary-btn {
  min-width: 148px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #031018;
  font-weight: 900;
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent1) 34%, transparent);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: var(--text);
  font-weight: 700;
}

button:hover {
  filter: saturate(1.12) brightness(1.08);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45) brightness(0.75);
  opacity: 0.48;
  transform: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  background:
    radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--accent1) 18%, transparent), transparent 36%),
    radial-gradient(circle at 80% 80%, color-mix(in srgb, var(--accent2) 18%, transparent), transparent 38%),
    rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(18px);
}

.hidden {
  display: none !important;
}

.panel {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.start-panel {
  text-align: center;
}

.compact-panel {
  width: min(520px, 100%);
  text-align: center;
}

.settings-panel {
  width: min(820px, 100%);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent1);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4rem);
  letter-spacing: 0;
  text-shadow: 0 0 18px color-mix(in srgb, var(--accent1) 54%, transparent);
}

h2 {
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.lead {
  max-width: 560px;
  margin: 10px auto 18px;
  color: var(--muted);
}

.menu-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
  text-align: left;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

label span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

select,
input[type="range"],
input[type="color"] {
  width: 100%;
}

select,
input[type="color"] {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.34);
  color: var(--text);
}

input[type="range"] {
  accent-color: var(--accent1);
}

.rules,
.toggle-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.rules span,
.toggle-grid label {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.86rem;
}

.toggle-grid label {
  justify-content: flex-start;
}

.actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 16px;
}

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 10px;
}

.settings-actions {
  justify-content: space-between;
}

.countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--accent3);
  font-size: clamp(4rem, 18vw, 11rem);
  font-weight: 1000;
  text-shadow: 0 0 24px var(--accent3), 0 0 56px var(--accent2);
  pointer-events: none;
}

.mobile-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 64px;
  z-index: 6;
  display: none;
  justify-content: space-between;
  padding: 0 12px;
  pointer-events: none;
}

.mobile-controls.visible {
  display: flex;
}

.stick-zone {
  width: min(34vw, 150px);
  display: grid;
  gap: 6px;
  justify-items: center;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  pointer-events: auto;
}

.stick-zone.hidden-stick {
  visibility: hidden;
  pointer-events: none;
}

.stick-base {
  position: relative;
  width: min(30vw, 132px);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05), 0 0 20px rgba(0, 0, 0, 0.42);
  touch-action: none;
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent1) 44%, transparent);
}

@media (max-width: 760px) {
  .game-shell {
    padding: 58px 8px 160px;
  }

  .hud {
    grid-template-columns: 76px 1fr 76px;
  }

  .hud-label {
    display: none;
  }

  .quickbar {
    width: calc(100vw - 20px);
    justify-content: center;
  }

  .icon-btn {
    flex: 1;
    padding: 0 8px;
  }

  .menu-grid,
  .settings-grid,
  .rules,
  .toggle-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  canvas {
    max-height: calc(100vh - 230px);
  }
}
