:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --accent: #6842ff;
  --accent-2: #8a6bff;
  --secondary: #2a2b3d;
  --text: #fff;
  --muted: #aaadbe;
  --hud-h: 50px;
  --help-h: 22px;
  font-family:
    "Nunito",
    ui-rounded,
    "SF Pro Rounded",
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-weight: 800;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
body {
  padding: 8px 10px 6px;
  background:
    radial-gradient(120% 70% at 50% 0%, #1d1b44 0%, rgba(15, 16, 32, 0) 60%),
    var(--bg);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}
:focus-visible {
  outline: 3px solid #ffd84a;
  outline-offset: 2px;
}
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  margin: 0 1px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #121324;
  color: #fff;
  font: inherit;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.shell {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* HUD */
.hud {
  width: 100%;
  min-height: var(--hud-h);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.brand-icon {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 3px 6px rgba(104, 66, 255, 0.45));
}
.brand h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fff, #c9b9ff 55%, #8a6bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.chips {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}
.chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  padding: 7px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #26273b, var(--panel));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 #0a0b16;
}
.chip span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.chip strong {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.chip-main strong {
  color: #b9a6ff;
}
.chip-kills strong {
  color: #ff8fa8;
}
.chip.pop strong {
  animation: pop 0.32s cubic-bezier(0.3, 1.8, 0.5, 1);
}
@keyframes pop {
  50% {
    transform: scale(1.35);
  }
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.12s ease,
    filter 0.12s ease;
}
.pill:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
}
.pill:disabled {
  opacity: 0.45;
  cursor: default;
}
.pill-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.25),
    0 4px 0 #3f22b8,
    0 10px 24px rgba(104, 66, 255, 0.4);
}
.pill-primary:hover {
  filter: brightness(1.08);
}
.pill-secondary {
  background: var(--secondary);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 3px 0 #15162a;
}
.pill-secondary:hover:not(:disabled) {
  background: #34354b;
}
.pill-big {
  min-height: 56px;
  min-width: 190px;
  font-size: 22px;
}
.pause-button {
  flex: 0 0 auto;
  padding: 0 14px;
}
.pause-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Board */
.board {
  position: relative;
  width: 100%;
  height: max(300px, calc(100svh - 14px - var(--hud-h) - var(--help-h) - 16px));
  border-radius: 22px;
  padding: 6px;
  background: linear-gradient(180deg, #2c2d52, #1b1c34);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    0 6px 0 #0b0c1a,
    0 18px 40px rgba(0, 0, 0, 0.45);
}
.board.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}
@keyframes shake {
  10%,
  90% {
    transform: translate(-2px, 1px);
  }
  20%,
  80% {
    transform: translate(4px, -2px);
  }
  30%,
  50%,
  70% {
    transform: translate(-7px, 2px);
  }
  40%,
  60% {
    transform: translate(7px, -1px);
  }
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 17px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
canvas:focus-visible {
  outline: 3px solid rgba(138, 107, 255, 0.8);
  outline-offset: 2px;
}

/* Leaderboard */
.leaders {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 196px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 14px;
  background: rgba(20, 21, 40, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  font-size: 12px;
}
.leaders:empty {
  display: none;
}
.leaders li {
  display: grid;
  grid-template-columns: 16px 12px 1fr auto;
  align-items: center;
  gap: 5px;
  padding: 3px 5px;
  border-radius: 8px;
  color: #dfe0ee;
  white-space: nowrap;
}
.leaders li.me {
  background: rgba(104, 66, 255, 0.45);
  color: #fff;
}
.leaders .pos {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.leaders .dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.leaders .nm {
  overflow: hidden;
  text-overflow: ellipsis;
}
.leaders .cpu {
  margin-right: 4px;
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.04em;
  vertical-align: 1px;
}
.leaders .pc {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 6px;
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: 17px;
  background: rgba(12, 12, 30, 0.42);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
}
.overlay[hidden] {
  display: none;
}
.card {
  width: min(380px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 18px 18px 16px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(180deg, #25264a, var(--panel));
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.1),
    0 8px 0 #0b0c1a,
    0 24px 50px rgba(0, 0, 0, 0.5);
  animation: card-in 0.38s cubic-bezier(0.3, 1.5, 0.5, 1);
}
@keyframes card-in {
  from {
    transform: scale(0.85);
    opacity: 0;
  }
}
.card-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.card-title {
  margin: 2px 0 6px;
  font-size: clamp(38px, 10vw, 54px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 10%, #c3b2ff 50%, #7a55ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #2d1a7a);
}
.card.lost .card-title {
  background-image: linear-gradient(180deg, #ffe0e6, #ff6b8a 55%, #e2335a);
  filter: drop-shadow(0 4px 0 #6b1530);
}
.card.won .card-title {
  background-image: linear-gradient(180deg, #fffbe0, #ffd84a 50%, #ff9f1c);
  filter: drop-shadow(0 4px 0 #7a4a00);
}
.card-copy {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.final {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 0 14px;
}
.final[hidden] {
  display: none;
}
.final-score {
  font-size: 54px;
  font-weight: 900;
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 0 #3f22b8;
  font-variant-numeric: tabular-nums;
}
.final-label {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.final-stats {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.final-stats span {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--muted);
  font-size: 13px;
}
.final-stats b {
  color: #fff;
}
.badge {
  margin-top: 10px;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe066, #ffb020);
  color: #3b2400;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 3px 0 #b36b00;
  animation: badge 0.9s ease-in-out infinite alternate;
}
.badge[hidden] {
  display: none;
}
@keyframes badge {
  to {
    transform: scale(1.08) rotate(-2deg);
  }
}
.card-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.card-hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.9;
}

.help {
  min-height: var(--help-h);
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 640px) {
  :root {
    --hud-h: 88px;
  }
  .hud {
    flex-wrap: wrap;
    justify-content: space-between;
  }
  .chips {
    order: 3;
    flex: 1 1 100%;
    gap: 4px;
  }
  .chip {
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 5px 4px;
    border-radius: 14px;
  }
  .chip span {
    font-size: 10px;
  }
  .chip strong {
    font-size: 16px;
  }
  .leaders {
    top: 12px;
    right: 12px;
    width: 156px;
    font-size: 11px;
  }
  .leaders li:nth-child(n + 4):not(.me) {
    display: none;
  }
  .help {
    display: none;
  }
  :root {
    --help-h: 0px;
  }
}
@media (max-width: 360px) {
  .pause-text {
    display: none;
  }
  .brand h1 {
    font-size: 21px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
