:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050713;
  color: #f6f7ff;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 18% 8%, rgba(70, 88, 190, .2), transparent 34%),
    radial-gradient(circle at 82% 28%, rgba(91, 42, 145, .17), transparent 38%),
    linear-gradient(155deg, #0c1029, #03050e 72%);
}

button, canvas { -webkit-tap-highlight-color: transparent; }

.game {
  width: min(96vw, 900px);
}

header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.kicker {
  margin: 0 0 3px;
  color: #9eafff;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.25rem);
  line-height: 1;
  letter-spacing: -.035em;
  text-shadow: 0 0 30px rgba(111, 133, 255, .18);
}

h1 span {
  color: #8995cc;
  font-size: .48em;
}

button {
  border: 1px solid rgba(180,192,255,.28);
  border-radius: 12px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #cbd3ff, #899cff);
  color: #090d24;
  font: inherit;
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(82, 103, 217, .24), inset 0 1px rgba(255,255,255,.65);
}

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

.start-screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 5, 15, .78);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.start-screen.hidden { display: none; }

.start-panel {
  width: min(92%, 430px);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid rgba(168,181,255,.22);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0, rgba(112,131,246,.16), transparent 46%),
    rgba(10, 14, 39, .96);
  text-align: center;
  box-shadow: 0 28px 70px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.07);
}

.start-kicker {
  margin: 0 0 7px;
  color: #9eafff;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.start-panel h2 {
  margin: 0;
  font-size: clamp(1.55rem, 5vw, 2.25rem);
}

.start-panel p:not(.start-kicker) {
  margin: 10px 0 20px;
  color: #aab2d2;
}

.player-select {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.player-select button {
  padding: 13px 8px;
}

.start-panel small {
  display: block;
  margin-top: 16px;
  color: #747da8;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.player {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(17,22,54,.92), rgba(7,10,27,.92));
  color: #bfc5e2;
  box-shadow: inset 0 1px rgba(255,255,255,.045), 0 8px 20px rgba(0,0,0,.18);
}

.player.active {
  border-color: var(--player-color);
  color: #fff;
  box-shadow: 0 0 18px color-mix(in srgb, var(--player-color) 35%, transparent);
}

.player-name {
  overflow: hidden;
  font-size: .72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  color: var(--player-color);
  font-size: 1.2rem;
  font-weight: 900;
}

.player-shots {
  color: #737da4;
  font-size: .62rem;
}

.board-wrap {
  position: relative;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid rgba(154,170,255,.2);
  border-radius: 24px;
  background: #070a19;
  box-shadow: 0 30px 85px rgba(0,0,0,.55), inset 0 1px rgba(255,255,255,.06), 0 0 45px rgba(66,82,177,.08);
}

canvas {
  display: block;
  width: 100%;
  height: min(72vh, 690px);
  height: min(72svh, 690px);
  min-height: 440px;
  background: #070a19;
  cursor: grab;
  touch-action: none;
}

canvas.dragging { cursor: grabbing; }

.status {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: max-content;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 7px 12px;
  transform: translateX(-50%);
  border: 1px solid rgba(163,176,255,.18);
  border-radius: 999px;
  background: rgba(5, 8, 24, .84);
  color: #e3e7ff;
  font-size: clamp(.66rem, 2vw, .82rem);
  text-align: center;
  pointer-events: none;
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
}

.help {
  margin: 9px 0 0;
  color: #858fb7;
  font-size: .76rem;
  text-align: center;
}

@media (max-width: 620px) {
  .scoreboard { grid-template-columns: repeat(2, 1fr); }
  header { align-items: center; }
  button { padding: 9px 10px; font-size: .72rem; }
  canvas { height: 65svh; min-height: 420px; }
  .player-select { grid-template-columns: 1fr; }
}

@media (max-height: 650px) {
  .kicker, .help { display: none; }
  .scoreboard { margin-bottom: 6px; }
  canvas { height: 72svh; min-height: 360px; }
}
