:root {
  color-scheme: dark;
  --bg: #0f1020;
  --panel: #1a1b28;
  --panel-2: #212233;
  --line: #2f3148;
  --accent: #6842ff;
  --accent-hi: #8c6dff;
  --text: #fff;
  --muted: #aaadbe;
  --secondary: #2a2b3d;
  --p0: #ffb020;
  --p1: #2fb8ff;
  font-family:
    "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system,
    "Segoe UI", sans-serif;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  min-width: 0;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
body {
  padding: 10px;
  overflow-x: hidden;
  font-weight: 700;
}
button {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 3px solid #b9a6ff;
  outline-offset: 2px;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.pb {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
}

/* ---------- HUD ---------- */
.pb-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}
.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 7px 12px 7px 7px;
  border-radius: 18px;
  background: linear-gradient(180deg, #232438, #1a1b28);
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.06),
    0 0 0 2px #26283d;
  transition:
    box-shadow 0.25s,
    transform 0.25s,
    opacity 0.25s;
  opacity: 0.72;
}
#card-1 {
  flex-direction: row-reverse;
  padding: 7px 7px 7px 12px;
  text-align: right;
}
#card-1 .player-line {
  flex-direction: row-reverse;
}
#card-1 .mini-balls {
  justify-content: flex-end;
}
.player-card.is-active {
  opacity: 1;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.08),
    0 0 0 2px var(--accent),
    0 0 22px rgb(104 66 255 / 0.55);
  transform: translateY(-1px);
}
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-weight: 900;
  font-size: 15px;
  color: #1b1100;
  background: linear-gradient(160deg, #ffd66b, var(--p0));
  box-shadow:
    inset 0 -3px 0 rgb(0 0 0 / 0.18),
    inset 0 2px 0 rgb(255 255 255 / 0.5);
}
.avatar-1 {
  color: #00203a;
  background: linear-gradient(160deg, #8fe0ff, var(--p1));
}
.player-info {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.player-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.player-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 900;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.group-tag {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--secondary);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.group-tag.is-set {
  background: rgb(104 66 255 / 0.28);
  color: #d8ceff;
}
.mini-balls {
  display: flex;
  gap: 3px;
  min-height: 17px;
}
.mini-ball {
  position: relative;
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset -2px -3px 4px rgb(0 0 0 / 0.35);
  transition:
    opacity 0.3s,
    transform 0.3s;
}
.mini-ball.stripe {
  background: linear-gradient(
    180deg,
    #f4efe4 0 26%,
    var(--c) 26% 74%,
    #f4efe4 74%
  );
}
.mini-ball::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle at 32% 28%,
    rgb(255 255 255 / 0.85) 0 12%,
    transparent 38%
  );
}
.mini-ball.gone {
  opacity: 0.18;
  transform: scale(0.8);
}
.mini-ball.empty {
  background: #2a2b3d;
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 0.5);
}
.mini-ball.empty::after {
  display: none;
}
.hud-mid .vs {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(160deg, #8c6dff, #5130e0);
  font-weight: 900;
  font-size: 13px;
  box-shadow:
    inset 0 -3px 0 rgb(0 0 0 / 0.25),
    0 6px 16px rgb(104 66 255 / 0.4);
}

/* ---------- play area ---------- */
.pb-play {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.pb-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  aspect-ratio: 1092 / 592;
  border-radius: 22px;
  overflow: hidden;
  background: #151631;
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.5);
}
.pb-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: crosshair;
}
.pb-stage.shake {
  animation: shake 0.42s ease-in-out;
}
@keyframes shake {
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(2px);
  }
}

/* power bar */
.power {
  flex: none;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  gap: 6px;
  width: 58px;
  padding: 8px 6px;
  border-radius: 20px;
  background: linear-gradient(180deg, #232438, #1a1b28);
  box-shadow: 0 0 0 2px #26283d;
  touch-action: none;
  cursor: ns-resize;
  -webkit-user-select: none;
  user-select: none;
}
.power.is-disabled {
  opacity: 0.45;
  cursor: default;
}
.power-track {
  position: relative;
  width: 30px;
  height: 100%;
  min-height: 120px;
  border-radius: 15px;
  overflow: hidden;
  background: #11121c;
  box-shadow: inset 0 3px 8px rgb(0 0 0 / 0.6);
}
.power-fill {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 55%;
  border-radius: 15px;
  background: linear-gradient(180deg, #3cf08b, #ffd43b 55%, #ff4d4d);
  background-size: 100% var(--track, 300px);
  box-shadow: inset 0 2px 0 rgb(255 255 255 / 0.35);
}
.power-cue {
  position: absolute;
  left: 50%;
  top: 0;
  width: 10px;
  height: 70%;
  margin-left: -5px;
  border-radius: 5px;
  background: linear-gradient(
    180deg,
    #4f8cff 0 4%,
    #f5f0e6 4% 9%,
    #f1d7a3 9% 60%,
    #6a3a1c 60% 100%
  );
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.5);
  transform: translateY(var(--pull, 0px));
  pointer-events: none;
}
.power-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}

/* toast */
.toast {
  position: absolute;
  left: 50%;
  top: 14%;
  z-index: 3;
  max-width: 88%;
  padding: 10px 20px;
  border-radius: 22px;
  background: rgb(15 16 32 / 0.86);
  box-shadow:
    0 0 0 2px rgb(255 255 255 / 0.1),
    0 10px 30px rgb(0 0 0 / 0.4);
  font-size: clamp(14px, 2.2vw, 19px);
  font-weight: 900;
  text-align: center;
  line-height: 1.25;
  width: max-content;
  opacity: 0;
  transform: translate(-50%, -8px) scale(0.9);
  transition:
    opacity 0.2s,
    transform 0.25s cubic-bezier(0.2, 1.4, 0.4, 1);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}
.toast.foul {
  background: linear-gradient(180deg, #ff5a6a, #d61f3c);
}
.toast.good {
  background: linear-gradient(180deg, #8c6dff, #5a34f0);
}

/* overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 12px;
  background: radial-gradient(
    ellipse at center,
    rgb(15 16 32 / 0.55),
    rgb(15 16 32 / 0.88)
  );
  backdrop-filter: blur(3px);
}
.overlay[hidden] {
  display: none;
}
.overlay-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(400px, 100%);
  padding: 18px 18px 16px;
  border-radius: 26px;
  background: linear-gradient(180deg, #25263b, #1a1b28);
  box-shadow:
    0 0 0 2px #303250,
    0 24px 60px rgb(0 0 0 / 0.55);
  text-align: center;
  animation: pop-in 0.38s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
}
.logo-ball {
  width: 64px;
  height: 64px;
  margin-top: -4px;
  filter: drop-shadow(0 8px 12px rgb(0 0 0 / 0.5));
  animation: bob 2.4s ease-in-out infinite;
}
@keyframes bob {
  50% {
    transform: translateY(-5px) rotate(-8deg);
  }
}
.overlay-title {
  margin: 0;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  background: linear-gradient(180deg, #fff 30%, #c9bcff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #4a2ed0);
}
.overlay-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}
.overlay-stats {
  margin: 0;
  min-height: 1em;
  color: var(--muted);
  font-size: 12px;
}
.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.seg {
  display: flex;
  gap: 4px;
  width: 100%;
  padding: 4px;
  border-radius: 999px;
  background: #121320;
  box-shadow: inset 0 2px 6px rgb(0 0 0 / 0.5);
}
.seg[hidden] {
  display: none;
}
.seg-btn {
  flex: 1;
  min-height: 42px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  font-size: 15px;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}
.seg-small .seg-btn {
  min-height: 40px;
  font-size: 14px;
}
.seg-btn[aria-pressed="true"] {
  background: linear-gradient(180deg, #3a3c58, #2a2b3d);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.12),
    0 3px 8px rgb(0 0 0 / 0.35);
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font-weight: 900;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.12s,
    filter 0.2s;
}
.pill:active {
  transform: scale(0.95);
}
.pill-primary {
  background: linear-gradient(180deg, #8467ff, var(--accent));
  box-shadow:
    inset 0 -4px 0 rgb(0 0 0 / 0.22),
    inset 0 2px 0 rgb(255 255 255 / 0.25),
    0 8px 20px rgb(104 66 255 / 0.45);
}
.pill-primary:hover {
  filter: brightness(1.08);
}
.pill-secondary {
  background: var(--secondary);
  box-shadow:
    inset 0 -3px 0 rgb(0 0 0 / 0.25),
    inset 0 1px 0 rgb(255 255 255 / 0.08);
}
.pill-big {
  min-width: 170px;
  min-height: 54px;
  font-size: 21px;
}
.pill[hidden] {
  display: none;
}
.pill[disabled] {
  opacity: 0.45;
  cursor: default;
  transform: none;
}
.trophy svg {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 8px 14px rgb(255 160 30 / 0.4));
  animation: bob 2s ease-in-out infinite;
}
.end-stats {
  display: flex;
  gap: 8px;
}
.chip {
  display: grid;
  min-width: 84px;
  padding: 6px 14px;
  border-radius: 16px;
  background: var(--secondary);
}
.chip span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chip strong {
  font-size: 22px;
  font-weight: 900;
}

/* ---------- controls ---------- */
.pb-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--secondary);
  box-shadow:
    inset 0 -3px 0 rgb(0 0 0 / 0.25),
    inset 0 1px 0 rgb(255 255 255 / 0.08);
  cursor: pointer;
  transition: transform 0.12s;
}
.icon-btn:active {
  transform: scale(0.92);
}
.icon-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}
#sound .mute {
  display: none;
}
#sound[aria-pressed="false"] .mute {
  display: inline;
}
#sound[aria-pressed="false"] .wave {
  display: none;
}
.aim-btns {
  display: flex;
  gap: 6px;
  margin-left: auto;
}
.shoot {
  min-width: 108px;
}
.pb-help {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}
.pb-help span {
  display: block;
}
kbd {
  display: inline-block;
  min-width: 1.6em;
  margin-right: 2px;
  padding: 0 4px;
  border-radius: 6px;
  background: var(--secondary);
  box-shadow: 0 2px 0 #14151f;
  color: #fff;
  font: inherit;
  font-size: 0.72rem;
  text-align: center;
}

/* ---------- portrait / phone layout ---------- */
.pb.is-portrait .pb-hud {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.pb.is-portrait .hud-mid {
  display: none;
}
.pb.is-portrait .player-card {
  gap: 7px;
  padding: 6px 8px 6px 6px;
  border-radius: 16px;
}
.pb.is-portrait #card-1 {
  padding: 6px 6px 6px 8px;
}
.pb.is-portrait .avatar {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 13px;
}
.pb.is-portrait .player-name {
  font-size: 13px;
}
.pb.is-portrait .group-tag {
  padding: 1px 6px;
  font-size: 10px;
}
.pb.is-portrait .mini-balls {
  gap: 2px;
}
.pb.is-portrait .mini-ball {
  width: 13px;
  height: 13px;
}
.pb.is-portrait .pb-play {
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
}
.pb.is-portrait .pb-stage {
  width: min(100%, 330px);
  flex: none;
  aspect-ratio: 592 / 1092;
  border-radius: 20px;
}
.pb.is-portrait .power {
  grid-template-rows: none;
  grid-template-columns: 1fr auto;
  align-items: center;
  width: min(100%, 330px);
  height: 50px;
  padding: 6px 12px 6px 8px;
  cursor: ew-resize;
}
.pb.is-portrait .power-track {
  width: 100%;
  height: 26px;
  min-height: 0;
}
.pb.is-portrait .power-fill {
  top: 0;
  bottom: 0;
  left: 0;
  width: 55%;
  height: auto;
  background: linear-gradient(90deg, #3cf08b, #ffd43b 55%, #ff4d4d);
  background-size: var(--track, 300px) 100%;
}
.pb.is-portrait .power-cue {
  top: 50%;
  left: 0;
  width: 70%;
  height: 8px;
  margin: -4px 0 0;
  background: linear-gradient(
    270deg,
    #4f8cff 0 4%,
    #f5f0e6 4% 9%,
    #f1d7a3 9% 60%,
    #6a3a1c 60% 100%
  );
  transform: translateX(var(--pull, 0px));
}
.pb.is-portrait .pb-help {
  display: none;
}
.pb.is-portrait .pb-controls {
  width: min(100%, 330px);
  margin: 0 auto;
}
.pb.is-portrait .shoot {
  min-width: 0;
  flex: 1;
  padding: 0 12px;
}
.pb.is-portrait .aim-btns {
  margin-left: 0;
}
.pb.is-portrait .overlay-card {
  padding: 16px 14px 14px;
}

@media (hover: none) {
  .help-keys {
    display: none !important;
  }
}

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