@font-face {
  font-family: "Ubuntu";
  src: url("../assets/fonts/ubuntu-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Ubuntu";
  src: url("../assets/fonts/ubuntu-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Ubuntu";
  src: url("../assets/fonts/ubuntu-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: "Ubuntu", "Segoe UI", system-ui, -apple-system, sans-serif;
  --ink: #10261d;
  --ink-soft: #5c7468;
  --line: rgba(20, 70, 55, 0.13);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --field: rgba(255, 255, 255, 0.66);
  --field-strong: rgba(20, 80, 60, 0.06);
  --glass: rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.88);
  --track: rgba(16, 60, 45, 0.14);
  --accent: #23b57e;
  --accent-strong: #149a6a;
  --accent-soft: rgba(35, 181, 126, 0.14);
  --danger: #e35d6a;
  --warning: #c97412;
  --warning-soft: rgba(255, 177, 92, 0.2);
  --invert: #7a3ff2;
  --invert-soft: rgba(122, 63, 242, 0.14);
  --halo: rgba(246, 252, 248, 0.58);
  --shadow:
    0 34px 90px -34px rgba(12, 67, 49, 0.5), 0 4px 18px rgba(12, 67, 49, 0.08);
  --radius: 26px;
  --safe-top: max(16px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #ecf7f1;
  --ink-soft: #90a99d;
  --line: rgba(160, 220, 190, 0.15);
  --panel: rgba(13, 26, 21, 0.93);
  --panel-solid: #0d1a15;
  --field: rgba(255, 255, 255, 0.055);
  --field-strong: rgba(255, 255, 255, 0.09);
  --glass: rgba(10, 22, 18, 0.65);
  --glass-strong: rgba(14, 28, 23, 0.9);
  --track: rgba(255, 255, 255, 0.16);
  --accent-soft: rgba(45, 200, 140, 0.18);
  --danger: #ff7b87;
  --warning: #ffbf74;
  --warning-soft: rgba(255, 177, 92, 0.16);
  --invert: #c9a6ff;
  --invert-soft: rgba(150, 90, 255, 0.2);
  --halo: rgba(4, 12, 9, 0.62);
  --shadow:
    0 34px 90px -30px rgba(0, 0, 0, 0.85), 0 4px 18px rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #f6fcf8;
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: none;
  -webkit-tap-highlight-color: transparent;
}

[data-theme="dark"] body {
  background: #0d1613;
}

body {
  position: fixed;
  inset: 0;
  user-select: none;
  touch-action: none;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

input {
  user-select: text;
  -webkit-user-select: text;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

#arena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* ------------------------------------------------------------------ */
/* Screens                                                             */
/* ------------------------------------------------------------------ */

.screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: var(--safe-top) 18px var(--safe-bottom);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-screen {
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.55), transparent 62%),
    radial-gradient(90% 60% at 50% 100%, rgba(20, 90, 65, 0.14), transparent 70%),
    rgba(246, 252, 248, 0.32);
}

[data-theme="dark"] .menu-screen {
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(60, 160, 120, 0.12), transparent 62%),
    radial-gradient(90% 60% at 50% 100%, rgba(0, 0, 0, 0.5), transparent 75%),
    rgba(4, 12, 9, 0.42);
}

.scrim {
  z-index: 30;
  background: rgba(10, 34, 25, 0.28);
  backdrop-filter: blur(9px) saturate(120%);
  -webkit-backdrop-filter: blur(9px) saturate(120%);
}

[data-theme="dark"] .scrim {
  background: rgba(0, 0, 0, 0.52);
}

/* ------------------------------------------------------------------ */
/* Brand                                                               */
/* ------------------------------------------------------------------ */

.brand {
  position: relative;
  text-align: center;
  pointer-events: none;
}

.brand::before {
  content: "";
  position: absolute;
  inset: -42px -80px;
  z-index: -1;
  background: radial-gradient(58% 58% at 50% 50%, var(--halo), transparent 72%);
}

.brand-mark {
  position: relative;
  width: 62px;
  height: 62px;
  margin: 0 auto 12px;
  animation: brand-float 6s ease-in-out infinite;
}

@keyframes brand-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.brand-mark i {
  position: absolute;
  display: block;
  border-radius: 50%;
  box-shadow: 0 10px 24px -10px rgba(10, 60, 45, 0.5);
}

.brand-mark i:nth-child(1) {
  width: 46px;
  height: 46px;
  left: 2px;
  bottom: 2px;
  background: linear-gradient(145deg, #4fd8a1, #1da873);
}

.brand-mark i:nth-child(2) {
  width: 24px;
  height: 24px;
  right: 0;
  top: 2px;
  background: linear-gradient(145deg, #ffd86b, #f2a93b);
}

.brand-mark i:nth-child(3) {
  width: 17px;
  height: 17px;
  right: 3px;
  bottom: 3px;
  background: linear-gradient(145deg, #ff8fa5, #f05d78);
}

.brand h1 {
  margin: 0;
  font-size: clamp(36px, 6vw, 54px);
  line-height: 0.94;
  letter-spacing: -0.035em;
  font-weight: 700;
  text-shadow: 0 2px 30px rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] .brand h1 {
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.55);
}

.brand h1 em {
  font-style: normal;
  color: var(--accent);
}

.brand p {
  margin: 9px 0 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-shadow: 0 1px 10px var(--halo), 0 0 3px var(--halo);
}

/* ------------------------------------------------------------------ */
/* Panels                                                              */
/* ------------------------------------------------------------------ */

.panel {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  padding: 22px;
}

.screen:not(.is-hidden) .panel {
  animation: rise 0.42s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.menu-panel {
  width: min(392px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-footer {
  margin: 0;
  font-size: 11.5px;
  color: var(--ink-soft);
  text-align: center;
  opacity: 0.85;
}

@keyframes rise {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.965);
  }
  68% {
    opacity: 1;
    transform: translateY(-2px) scale(1.012);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ------------------------------------------------------------------ */
/* Form controls                                                       */
/* ------------------------------------------------------------------ */

.field {
  display: block;
}

.field > span {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-left: 3px;
}

.field input {
  width: 100%;
  height: 50px;
  margin-top: 7px;
  padding: 0 15px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 17px;
  font-weight: 700;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.field input::placeholder {
  color: var(--ink-soft);
  opacity: 0.55;
  font-weight: 500;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: var(--panel-solid);
}

.skin-picker {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 9px 13px 9px 9px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--field);
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.12s ease;
}

.skin-picker:hover {
  background: var(--panel-solid);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.skin-preview {
  position: relative;
  width: 50px;
  height: 50px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  overflow: hidden;
  background: conic-gradient(#dcebe4 25%, #f5fbf8 0 50%, #dcebe4 0 75%, #f5fbf8 0) 0 0 /
    14px 14px;
  box-shadow: inset 0 0 0 1px var(--line);
}

.skin-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.skin-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4fd8a1, #1da873);
  box-shadow: inset -4px -6px 0 rgba(0, 0, 0, 0.12);
}

.skin-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.skin-copy b {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}

.skin-copy small {
  font-size: 10.5px;
  color: var(--ink-soft);
}

.chevron {
  font-size: 22px;
  line-height: 1;
  color: var(--ink-soft);
  opacity: 0.7;
}

.button {
  border: 0;
  border-radius: 14px;
  background: var(--field);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s cubic-bezier(0.2, 1.2, 0.3, 1),
    background 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.button:hover {
  transform: translateY(-2px) scale(1.012);
}

.button:active {
  transform: translateY(0) scale(0.985);
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 14px 30px -14px rgba(24, 160, 110, 0.9);
}

.button.primary:hover {
  background: var(--accent-strong);
  box-shadow: 0 18px 34px -14px rgba(24, 160, 110, 0.95);
}

.button.big {
  width: 100%;
  height: 53px;
  font-size: 17px;
  border-radius: 16px;
}

.button.ghost {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
}

.button.ghost:hover {
  background: var(--field);
}

.button.small {
  padding: 0 16px;
  font-size: 12.5px;
  border-radius: 12px;
  background: var(--field-strong);
}

.text-button {
  border: 0;
  background: transparent;
  padding: 5px 2px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s ease;
}

.text-button:hover {
  color: var(--accent);
}

.menu-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: -4px;
}

.menu-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-soft);
}

.menu-meta > span {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.menu-meta b {
  color: var(--ink);
  font-weight: 700;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  flex: none;
}

/* ------------------------------------------------------------------ */
/* HUD                                                                 */
/* ------------------------------------------------------------------ */

.hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  color: var(--ink);
}

.hud-top {
  position: absolute;
  top: var(--safe-top);
  left: 14px;
  right: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.score-pod {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 17px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 12px 34px -22px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.score-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

#score-value {
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: transform 0.2s cubic-bezier(0.2, 1.4, 0.3, 1);
  transform-origin: left center;
  will-change: transform;
}

#score-value.bump {
  transform: scale(1.2);
}

.best-chip {
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-soft);
  padding-left: 8px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.best-chip b {
  font-weight: 700;
  color: var(--ink);
}

.desktop-hint {
  position: absolute;
  top: calc(var(--safe-top) + 9px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  opacity: 0.78;
  white-space: nowrap;
  pointer-events: none;
}

.desktop-hint i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

body.touch .desktop-hint {
  display: none;
}

.status-stack {
  position: absolute;
  top: calc(var(--safe-top) + 58px);
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.status-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 10px 28px -22px rgba(0, 0, 0, 0.55);
  animation: status-in 0.28s cubic-bezier(0.2, 1.2, 0.3, 1);
}

.status-chip i {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.status-chip.drain {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-chip.invert {
  color: var(--invert);
  background: var(--invert-soft);
}

.status-chip.drain i {
  animation: drain-pulse 1.1s ease-in-out infinite;
}

@keyframes drain-pulse {
  50% {
    opacity: 0.3;
    transform: scale(0.7);
  }
}

@keyframes status-in {
  0% {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
  70% {
    opacity: 1;
    transform: translateY(1px) scale(1.015);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--glass);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 12px 30px -22px rgba(0, 0, 0, 0.5);
  transition:
    background 0.15s ease,
    transform 0.12s ease;
  pointer-events: auto;
}

.icon-button:hover {
  background: var(--glass-strong);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  fill: none;
}

#pause-button {
  flex: none;
}

.leaderboard {
  position: absolute;
  top: calc(var(--safe-top) + 54px);
  right: 14px;
  width: 222px;
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: 0 16px 44px -30px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}

.leaderboard h2 {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

#leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

#leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 5px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  min-width: 0;
}

#leaderboard-list li.me {
  background: var(--accent-soft);
  font-weight: 700;
}

#leaderboard-list li.top-three .lb-rank {
  color: var(--warning);
  font-weight: 700;
}

.lb-rank {
  width: 15px;
  flex: none;
  font-size: 10.5px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.lb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.lb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-mass {
  flex: none;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

#leaderboard-list li.me .lb-mass {
  color: var(--ink);
}

/* A player who left the match: their score stays on the board, frozen and greyed out. */
#leaderboard-list li.left {
  opacity: 0.42;
  font-style: italic;
}

#leaderboard-list li.left .lb-dot {
  background: var(--ink-soft) !important;
}

.minimap-pod {
  position: absolute;
  right: 14px;
  bottom: var(--safe-bottom);
  width: 150px;
  height: 150px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 44px -28px rgba(0, 0, 0, 0.6);
}

.minimap-pod.is-dim {
  opacity: 0;
  visibility: hidden;
}

#minimap {
  display: block;
  width: 100%;
  height: 100%;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 70px);
  transform: translate(-50%, 10px);
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(12, 30, 24, 0.86);
  color: #f3fff9;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.32s cubic-bezier(0.2, 1.3, 0.3, 1);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ------------------------------------------------------------------ */
/* Actions & joystick                                                 */
/* ------------------------------------------------------------------ */

.actions {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 4px);
  transform: translateX(-50%);
  display: none;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

body.playing .actions {
  display: flex;
}

.action-button {
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px 9px 11px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--glass-strong);
  color: var(--ink);
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 14px 34px -18px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  transition:
    transform 0.18s cubic-bezier(0.2, 1.2, 0.3, 1),
    background 0.15s ease,
    opacity 0.15s ease;
}

.action-button:hover {
  transform: translateY(-2px) scale(1.02);
}

.action-button:active {
  transform: scale(0.96);
}

.action-button:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
}

.action-button.primary {
  background: var(--accent);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 16px 36px -14px rgba(24, 160, 110, 0.85);
}

.action-button svg {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.action-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.05;
}

.action-copy b {
  font-size: 13px;
  font-weight: 700;
}

.action-copy small {
  display: none; /* the button name is enough; keys are in the desktop hint line */
}

.joystick {
  position: fixed;
  left: 0;
  top: 0;
  width: 122px;
  height: 122px;
  margin: -61px 0 0 -61px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.62);
  background: rgba(10, 30, 24, 0.14);
  box-shadow:
    0 16px 44px -20px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    inset 0 0 24px rgba(255, 255, 255, 0.06);
  z-index: 9;
  pointer-events: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #cfe6dc);
  box-shadow:
    0 10px 24px -8px rgba(0, 0, 0, 0.45),
    0 0 0 3px rgba(255, 255, 255, 0.28);
  transform: translate(-50%, -50%);
  transition: transform 0.07s ease-out;
  will-change: transform;
}

.joystick:not(.is-hidden) {
  animation: joystick-in 0.18s cubic-bezier(0.2, 1.2, 0.3, 1);
}

@keyframes joystick-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ------------------------------------------------------------------ */
/* Dialogs                                                             */
/* ------------------------------------------------------------------ */

.dialog-panel {
  width: min(368px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
  padding: 26px 24px 24px;
}

.eyebrow {
  margin: 0;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.dialog-panel h2 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.02em;
  line-height: 1;
}

.dialog-panel .button.big {
  margin-top: 4px;
}

.dialog-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 2px;
}

.dialog-row .button {
  height: 44px;
  font-size: 13px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 10px;
}

.result-grid > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 6px;
  border-radius: 14px;
  background: var(--field-strong);
}

.result-grid small {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.result-grid strong {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#final-score {
  color: var(--accent);
}

/* ------------------------------------------------------------------ */
/* Gallery                                                             */
/* ------------------------------------------------------------------ */

.gallery-panel {
  width: min(880px, 100%);
  max-height: min(88dvh, 780px);
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 10px;
}

.compact-panel {
  width: min(440px, 100%);
  max-height: min(88dvh, 720px);
  display: flex;
  flex-direction: column;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.close-button {
  width: 36px;
  height: 36px;
  flex: none;
}

.gallery-tools {
  display: flex;
  gap: 9px;
}

.search {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 14px;
  font-weight: 500;
  outline: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 7px;
  overflow-y: auto;
  padding: 4px 4px 8px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--track) transparent;
}

.skin-grid::-webkit-scrollbar {
  width: 10px;
}

.skin-grid::-webkit-scrollbar-thumb {
  background: var(--track);
  border-radius: 999px;
}

.skin-tile {
  border: 0;
  background: transparent;
  border-radius: 14px;
  padding: 7px 5px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition:
    background 0.14s ease,
    transform 0.18s cubic-bezier(0.2, 1.2, 0.3, 1),
    box-shadow 0.14s ease;
}

.skin-tile:hover {
  background: var(--field-strong);
  transform: translateY(-2px) scale(1.02);
}

.skin-tile.selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.skin-thumb {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  overflow: hidden;
  background: conic-gradient(#dcebe4 25%, #f5fbf8 0 50%, #dcebe4 0 75%, #f5fbf8 0) 0 0 /
    14px 14px;
  box-shadow: inset 0 0 0 1px var(--line);
}

[data-theme="dark"] .skin-thumb,
[data-theme="dark"] .skin-preview {
  background: conic-gradient(#1c2c26 25%, #0f1b16 0 50%, #1c2c26 0 75%, #0f1b16 0) 0 0 /
    14px 14px;
}

.skin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.skin-tile span {
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9.5px;
  font-weight: 500;
  color: var(--ink-soft);
  text-transform: capitalize;
}

.skin-tile.selected span {
  color: var(--ink);
  font-weight: 700;
}

.gallery-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  font-size: 10.5px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* Settings                                                            */
/* ------------------------------------------------------------------ */

.settings-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  margin-top: 6px;
  padding-right: 4px;
  scrollbar-width: thin;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.switch-row > span {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.switch-row b {
  font-size: 13px;
  font-weight: 700;
}

.switch-row small {
  font-size: 10.5px;
  color: var(--ink-soft);
}

.switch-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-row i {
  position: relative;
  flex: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--track);
  transition: background 0.18s ease;
}

.switch-row i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.switch-row input:checked + i {
  background: var(--accent);
}

.switch-row input:checked + i::after {
  transform: translateX(18px);
}

.switch-row input:focus-visible + i {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.select-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.select-row > span {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.select-row b {
  font-size: 13px;
  font-weight: 700;
}

.select-row small {
  font-size: 10.5px;
  color: var(--ink-soft);
}

.mini-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--field);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
    linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) 50%,
    calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 700;
  padding: 8px 30px 8px 11px;
  cursor: pointer;
}

.mini-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.range-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 2px 4px;
  font-size: 12.5px;
  font-weight: 700;
}

.range-row input {
  flex: 1;
  accent-color: var(--accent);
}

.range-row input:disabled {
  opacity: 0.35;
}

/* ------------------------------------------------------------------ */
/* How to play                                                         */
/* ------------------------------------------------------------------ */

.howto {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.howto-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.key {
  flex: none;
  min-width: 64px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--field-strong);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.howto-row p {
  margin: 1px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
}

.howto-tip {
  margin: 4px 0 0;
  padding: 12px 14px;
  border-radius: 13px;
  background: var(--accent-soft);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  margin: 0;
  background: #f6fcf8;
  color: #10261d;
  font-family: var(--font);
}

/* ------------------------------------------------------------------ */
/* Multiplayer                                                         */
/* ------------------------------------------------------------------ */

.match-clock {
  position: absolute;
  top: var(--safe-top);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: 0 12px 30px -22px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.match-clock b {
  font-size: 15px;
  letter-spacing: 0;
  color: var(--ink);
}

.respawn-banner {
  position: absolute;
  top: calc(var(--safe-top) + 54px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 18px;
  border-radius: 15px;
  border: 1px solid rgba(255, 123, 135, 0.35);
  background: var(--glass-strong);
  box-shadow: 0 18px 44px -26px rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  text-align: center;
  white-space: nowrap;
  animation: status-in 0.28s cubic-bezier(0.2, 1.2, 0.3, 1);
}

.respawn-banner strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
}

.respawn-banner span {
  font-size: 10.5px;
  color: var(--ink-soft);
}

.respawn-banner span b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

body.multiplayer .desktop-hint,
body.multiplayer #pause-button {
  display: none;
}

.mp-panel {
  width: min(430px, 100%);
  max-height: min(88dvh, 760px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--track) transparent;
}

.mp-panel .panel-header {
  align-items: flex-start;
}

.mp-panel .eyebrow {
  margin: 0 0 3px;
}

.mp-panel .panel-header h2 {
  margin: 0;
}

.mp-room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  flex-wrap: wrap;
}

.mp-room {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.mp-room b {
  font-size: 19px;
  line-height: 1;
  letter-spacing: 0.1em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.mp-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.mp-status i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
  flex: none;
}

.mp-status.ok i {
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.mp-status.warn i {
  background: var(--danger);
  animation: drain-pulse 1s ease-in-out infinite;
}

.mp-lobby-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 30vh;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--track) transparent;
  font-size: 12px;
}

.mp-pl {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink-soft);
  font-weight: 500;
}

.mp-pl.ok {
  color: var(--ink);
}

.mp-av {
  width: 27px;
  height: 27px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 700;
}

.mp-nm {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
}

.mp-tag {
  flex: none;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.mp-in {
  flex: none;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.mp-in.wait {
  color: var(--ink-soft);
  opacity: 0.7;
}

.mp-opts {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 2px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}

.mp-opts label {
  display: flex;
  align-items: center;
  gap: 7px;
}

.mp-opts select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 700;
  padding: 7px 24px 7px 9px;
  cursor: pointer;
}

.mp-tip {
  padding: 9px 11px;
  border-radius: 11px;
  border: 1px dashed var(--line);
  background: var(--field);
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.mp-result-panel {
  width: min(470px, 100%);
  max-height: min(90dvh, 820px);
  gap: 8px;
}

.mp-result-panel h2 {
  margin-bottom: 2px;
}

.mp-result-list {
  margin: 6px 0 4px;
  max-height: 42vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--track) transparent;
}

.mp-result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.mp-result-table th {
  position: sticky;
  top: 0;
  padding: 6px 5px;
  background: var(--panel-solid);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-align: right;
}

.mp-result-table th:nth-child(2) {
  text-align: left;
}

.mp-result-table td {
  padding: 7px 5px;
  border-top: 1px solid var(--line);
  text-align: right;
}

.mp-result-table td:nth-child(2) {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-weight: 700;
}

.mp-result-table tr.me td {
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.mp-result-table td.bot {
  color: var(--ink-soft);
  font-weight: 500;
}

.mp-result-table tr.left td {
  opacity: 0.42;
  font-style: italic;
}

.mp-result-wait {
  margin: 0;
  font-size: 11px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 1100px) {
  .desktop-hint {
    display: none;
  }
}

@media (max-width: 760px), (pointer: coarse) {
  .desktop-hint {
    display: none;
  }

  .leaderboard {
    width: 172px;
    padding: 10px 11px;
    top: calc(var(--safe-top) + 50px);
  }

  .leaderboard h2 {
    font-size: 8.5px;
    margin-bottom: 6px;
  }

  #leaderboard-list {
    gap: 1px;
  }

  #leaderboard-list li {
    font-size: 11px;
    padding: 2px 4px;
    gap: 5px;
  }

  .minimap-pod {
    left: 14px;
    right: auto;
    width: 106px;
    height: 106px;
    border-radius: 14px;
    bottom: calc(var(--safe-bottom) + 2px);
  }

  .score-pod {
    padding: 8px 13px;
    gap: 8px;
    border-radius: 15px;
  }

  #score-value {
    font-size: 22px;
  }

  .best-chip {
    display: none;
  }

  .toast {
    bottom: calc(var(--safe-bottom) + 120px);
  }

  .status-stack {
    top: calc(var(--safe-top) + 52px);
  }

  .status-chip {
    padding: 6px 10px;
    font-size: 8.5px;
  }

  .actions {
    left: auto;
    right: 14px;
    transform: none;
    gap: 11px;
  }

  .action-button {
    width: 62px;
    height: 62px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
    text-align: center;
  }

  .action-button.primary {
    width: 76px;
    height: 76px;
  }

  .action-copy {
    display: none; /* icon only on small screens */
  }

  .action-button svg {
    width: 22px;
    height: 22px;
  }

  .action-button.primary svg {
    width: 26px;
    height: 26px;
  }

  .menu-meta {
    font-size: 10.5px;
  }

  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
    gap: 5px;
  }

  .skin-thumb {
    width: 58px;
    height: 58px;
  }

  .skin-tile span {
    max-width: 74px;
    font-size: 9px;
  }

  .dialog-panel h2 {
    font-size: 27px;
  }

  .result-grid strong {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .brand-mark {
    width: 52px;
    height: 52px;
    margin-bottom: 9px;
  }

  .brand-mark i:nth-child(1) {
    width: 39px;
    height: 39px;
  }

  .brand-mark i:nth-child(2) {
    width: 21px;
    height: 21px;
  }

  .brand-mark i:nth-child(3) {
    width: 15px;
    height: 15px;
  }

  .brand h1 {
    font-size: clamp(32px, 11vw, 44px);
  }

  .menu-panel {
    padding: 18px;
    gap: 12px;
    border-radius: 22px;
  }

  .field input {
    height: 47px;
    font-size: 16px;
  }

  .button.big {
    height: 50px;
  }

  .screen {
    gap: 12px;
  }

  .action-button {
    width: 56px;
    height: 56px;
  }

  .action-button.primary {
    width: 68px;
    height: 68px;
  }

  .action-button svg {
    width: 20px;
    height: 20px;
  }

  .action-button.primary svg {
    width: 23px;
    height: 23px;
  }

  .gallery-panel,
  .compact-panel {
    padding: 15px;
    border-radius: 22px;
  }

  .skin-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  }

  .skin-thumb {
    width: 54px;
    height: 54px;
  }

  .leaderboard {
    width: 154px;
  }

  .menu-footer {
    display: none;
  }
}

@media (max-width: 480px) {
  .mp-panel {
    width: 100%;
    max-height: calc(100dvh - 28px);
    gap: 9px;
    padding: 15px;
    border-radius: 20px;
  }

  .mp-lobby-list {
    max-height: 23vh;
  }

  .mp-result-table td:nth-child(2) {
    max-width: 112px;
  }

  .match-clock {
    top: calc(var(--safe-top) + 1px);
    padding: 7px 11px;
  }

  .respawn-banner {
    top: calc(var(--safe-top) + 50px);
    padding-inline: 14px;
  }
}

@media (max-height: 560px) {
  .brand {
    display: none;
  }

  .menu-footer {
    display: none;
  }

  .screen {
    gap: 0;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .menu-panel {
    padding: 15px;
    gap: 10px;
  }

  .field input {
    height: 43px;
  }

  .button.big {
    height: 45px;
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--field);
  color: var(--ink);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  padding: 2px;
}

.stepper:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.stepper button {
  width: 28px;
  height: 26px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.stepper button:hover:not(:disabled) {
  background: var(--line);
}

.stepper button:disabled {
  opacity: 0.35;
  cursor: default;
}

.stepper input {
  width: 42px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.stepper-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.stepper-hint {
  margin: 0 0 14px;
  font-size: 11px;
  color: var(--ink-soft);
}
