:root {
  --bg: #07131f;
  --bg-alt: #0d1d2f;
  --panel: rgba(9, 20, 35, 0.78);
  --panel-border: rgba(126, 241, 255, 0.22);
  --text: #eef8ff;
  --muted: #9eb8ce;
  --accent: #78fff1;
  --accent-strong: #23dfff;
  --accent-warm: #ff4fcf;
  --success: #9df65e;
  --danger: #ff6c8a;
  --shadow: rgba(0, 0, 0, 0.32);
  --table-surface-a: #071722;
  --table-surface-b: #0c2636;
  --table-line: rgba(182, 248, 255, 0.92);
  --table-glow: rgba(89, 251, 255, 0.55);
  --left-player: #66fff0;
  --right-player: #ff5fcb;
  --puck: #ffffff;
  --goal-left: rgba(102, 255, 240, 0.22);
  --goal-right: rgba(255, 95, 203, 0.22);
}

body[data-theme="ice"] {
  --bg: #081220;
  --bg-alt: #102640;
  --panel: rgba(8, 23, 41, 0.78);
  --panel-border: rgba(131, 211, 255, 0.24);
  --accent: #9be2ff;
  --accent-strong: #59bdff;
  --accent-warm: #d0f6ff;
  --table-surface-a: #0b2138;
  --table-surface-b: #13395b;
  --table-line: rgba(215, 243, 255, 0.92);
  --table-glow: rgba(98, 180, 255, 0.55);
  --left-player: #90e9ff;
  --right-player: #f5f6ff;
  --puck: #f9ffff;
  --goal-left: rgba(144, 233, 255, 0.2);
  --goal-right: rgba(245, 246, 255, 0.18);
}

body[data-theme="sunset"] {
  --bg: #170913;
  --bg-alt: #30152a;
  --panel: rgba(34, 10, 23, 0.78);
  --panel-border: rgba(255, 189, 92, 0.22);
  --accent: #ffb969;
  --accent-strong: #ff7f4f;
  --accent-warm: #ffd452;
  --table-surface-a: #25101c;
  --table-surface-b: #552137;
  --table-line: rgba(255, 226, 171, 0.94);
  --table-glow: rgba(255, 176, 83, 0.55);
  --left-player: #ffca7b;
  --right-player: #ff7d7d;
  --puck: #fff4e5;
  --goal-left: rgba(255, 202, 123, 0.2);
  --goal-right: rgba(255, 125, 125, 0.2);
}

* {
  box-sizing: border-box;
}

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

body {
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at top left, rgba(76, 232, 255, 0.14), transparent 32%),
    radial-gradient(circle at 85% 12%, rgba(255, 85, 205, 0.14), transparent 28%),
    linear-gradient(140deg, var(--bg) 0%, var(--bg-alt) 55%, #03070c 100%);
  color: var(--text);
  font-family: "Rajdhani", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior-x: none;
  overscroll-behavior-y: auto;
  touch-action: auto;
}

body.is-playing {
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: auto;
  overscroll-behavior-y: auto;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
}

.app-shell.is-playing {
  min-height: calc(100svh + 140px);
  align-items: flex-start;
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: calc(140px + env(safe-area-inset-bottom));
}

.ambient,
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.ambient-one {
  background:
    radial-gradient(circle at 18% 20%, rgba(92, 255, 232, 0.16), transparent 28%),
    radial-gradient(circle at 76% 14%, rgba(255, 98, 205, 0.12), transparent 24%);
  filter: blur(18px);
}

.ambient-two {
  background:
    radial-gradient(circle at 50% 88%, rgba(41, 138, 255, 0.14), transparent 24%),
    radial-gradient(circle at 82% 82%, rgba(255, 175, 87, 0.1), transparent 18%);
  filter: blur(22px);
}

.grain {
  opacity: 0.06;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
  background-size: 4px 4px;
  mix-blend-mode: soft-light;
}

.screen {
  position: relative;
  width: min(100%, 1420px);
  z-index: 1;
}

[hidden] {
  display: none !important;
}

.panel {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 26px 70px var(--shadow),
    inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.hero-panel,
.result-panel {
  border-radius: 28px;
  padding: 28px;
}

.hero-panel h1,
.result-panel h2 {
  margin: 8px 0 10px;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2.2rem, 5vw, 4rem);
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow,
.section-title,
.player-tag,
.match-target {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.92rem;
}

.eyebrow::before {
  content: "";
  width: 38px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent));
}

.lead {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  line-height: 1.4;
}

.menu-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 22px;
}

.settings-panel,
.info-panel,
.hud,
.table-wrap {
  border-radius: 24px;
  padding: 22px;
}

.section-title {
  margin-bottom: 16px;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
}

.mode-selector,
.button-row,
.goal-control,
.hud-controls {
  display: flex;
  gap: 12px;
}

.mode-button,
.primary-button,
.secondary-button,
.button-link,
.ghost-button,
.stepper-button,
.toggle-button,
.input-control,
.goal-input {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition:
    transform 0.14s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.mode-button,
.ghost-button,
.stepper-button,
.toggle-button,
.button-link,
.input-control,
.goal-input {
  min-height: 54px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.mode-button,
.ghost-button,
.stepper-button,
.toggle-button,
.button-link {
  padding: 0 18px;
  font-weight: 700;
}

.mode-button:hover,
.primary-button:hover,
.secondary-button:hover,
.button-link:hover,
.ghost-button:hover,
.stepper-button:hover,
.toggle-button:hover,
.input-control:hover,
.goal-input:hover {
  border-color: rgba(255, 255, 255, 0.22);
}

.mode-button:active,
.primary-button:active,
.secondary-button:active,
.button-link:active,
.ghost-button:active,
.stepper-button:active,
.toggle-button:active {
  transform: translateY(2px) scale(0.99);
}

.mode-button.is-selected,
.toggle-button.is-active,
.ghost-button.is-active {
  background:
    linear-gradient(135deg, rgba(89, 251, 255, 0.16), rgba(255, 120, 198, 0.16)),
    rgba(255, 255, 255, 0.05);
  border-color: rgba(116, 248, 255, 0.45);
  box-shadow: 0 0 0 1px rgba(116, 248, 255, 0.14), 0 10px 26px rgba(25, 172, 213, 0.16);
}

.primary-button,
.secondary-button,
.button-link {
  min-height: 58px;
  padding: 0 22px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent-warm));
  color: #04101a;
  border: none;
  box-shadow: 0 18px 34px rgba(34, 170, 226, 0.24);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.ghost-button {
  padding: 0 14px;
}

.button-row {
  flex-wrap: wrap;
  margin-top: 20px;
}

.button-row.compact {
  justify-content: center;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-top: 18px;
}

.setting-label {
  color: var(--text);
  font-size: 1.04rem;
  font-weight: 600;
}

.input-control {
  min-width: 180px;
  padding: 0 16px;
}

.goal-control {
  align-items: center;
}

.stepper-button {
  width: 54px;
  font-size: 1.4rem;
}

.goal-input {
  width: 90px;
  text-align: center;
  padding: 0 12px;
  font-size: 1.25rem;
  font-weight: 700;
}

.goal-input::-webkit-outer-spin-button,
.goal-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.goal-input[type="number"] {
  appearance: textfield;
}

.feature-list {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.45;
}

.feature-list li + li {
  margin-top: 8px;
}

.control-hint {
  margin-top: 22px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.control-hint strong {
  display: block;
  margin-bottom: 10px;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.control-hint p {
  margin: 8px 0 0;
  color: var(--muted);
}

.control-hint span {
  color: var(--text);
  font-weight: 700;
}

.game-screen {
  display: grid;
  gap: 16px;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  padding-block: 18px;
}

.score-side {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.score-right {
  align-items: flex-end;
}

.player-tag {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.score-value {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.22);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.match-target {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}

.table-wrap {
  position: relative;
  padding: 14px;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 20px;
  touch-action: none;
  cursor: crosshair;
}

.canvas-overlay {
  position: absolute;
  inset: 14px;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.overlay-pill,
.overlay-card {
  background: rgba(4, 12, 22, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
}

.overlay-pill {
  min-width: 140px;
  min-height: 140px;
  padding: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(3rem, 8vw, 5rem);
}

.overlay-card {
  max-width: 460px;
  padding: 24px;
  border-radius: 24px;
  text-align: center;
  pointer-events: auto;
}

.overlay-card h2 {
  margin: 0 0 12px;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.6rem, 5vw, 2.2rem);
}

.overlay-card p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.goal-flash {
  position: absolute;
  inset: 14px;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
}

.goal-flash.is-active {
  animation: goalFlash 0.7s ease-out;
}

@keyframes goalFlash {
  0% {
    opacity: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.28), transparent 54%);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.result-screen {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 9, 15, 0.55);
  backdrop-filter: blur(16px);
}

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

code {
  font-family: "Orbitron", monospace;
  font-size: 0.9em;
  color: var(--accent);
}

@media (max-width: 1080px) {
  .app-shell {
    padding: 14px;
  }

  .menu-grid {
    grid-template-columns: 1fr;
  }

  .hud {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .score-right,
  .score-left {
    align-items: center;
  }

  .hud-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 760px) {
  .hero-panel,
  .settings-panel,
  .info-panel,
  .hud,
  .table-wrap,
  .result-panel {
    border-radius: 22px;
    padding: 18px;
  }

  .setting-row {
    grid-template-columns: 1fr;
  }

  .input-control,
  .goal-control {
    width: 100%;
  }

  .mode-selector,
  .goal-control {
    width: 100%;
  }

  .mode-button,
  .stepper-button,
  .goal-input,
  .input-control,
  .toggle-button,
  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }

  .goal-control {
    display: grid;
    grid-template-columns: 54px 1fr 54px;
  }

  .button-link {
    width: 100%;
  }
}
