/* Breakaway Rush — neon night rink design */

:root {
  color-scheme: dark;
  --night: #04060d;
  --night-soft: #0a1024;
  --panel: rgba(10, 16, 36, 0.92);
  --panel-solid: #0c1430;
  --panel-deep: rgba(5, 8, 20, 0.94);
  --ink: #eef4ff;
  --muted: #93a5c8;
  --line: rgba(150, 180, 235, 0.16);
  --line-bright: rgba(150, 180, 235, 0.34);
  --home: #57b6ff;
  --home-soft: rgba(87, 182, 255, 0.16);
  --away: #ff8a3d;
  --away-soft: rgba(255, 138, 61, 0.15);
  --gold: #ffd35c;
  --goal: #ff3355;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --radius: 14px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
}

.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;
}

.skip-link {
  position: fixed;
  top: -4rem;
  left: 1rem;
  z-index: 60;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  background: var(--home);
  color: #04121f;
  font-weight: 700;
  text-decoration: none;
  transition: top 160ms ease;
}

.skip-link:focus-visible {
  top: 0.75rem;
}

/* ---------------------------------------------------------------------
   Shell
   --------------------------------------------------------------------- */

.game-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  background:
    radial-gradient(120% 90% at 50% -20%, rgba(64, 110, 220, 0.16), transparent 60%),
    var(--night);
}

.scorebug {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(0.55rem + env(safe-area-inset-top)) 0.9rem 0.55rem;
  background: linear-gradient(180deg, rgba(6, 10, 26, 0.98), rgba(6, 10, 26, 0.82));
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.game-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.game-brand .brand-mark {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex: none;
  background:
    radial-gradient(circle at 50% 50%, var(--night) 0 26%, transparent 27%),
    conic-gradient(from 40deg, var(--home), #8fd4ff, var(--home));
  box-shadow: 0 0 14px rgba(87, 182, 255, 0.55);
}

.game-brand strong {
  display: block;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  line-height: 1.05;
}

.game-brand small {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--home);
}

.bug {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  margin-inline: auto;
  padding: 0.28rem;
  border-radius: 999px;
  background: rgba(4, 8, 20, 0.85);
  border: 1px solid var(--line-bright);
  box-shadow: inset 0 0 18px rgba(20, 40, 90, 0.5), 0 6px 24px rgba(0, 0, 0, 0.4);
}

.bug-team {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.8rem;
  border-radius: 999px;
  font-weight: 700;
}

.bug-team-home {
  background: var(--home-soft);
}

.bug-team-away {
  background: var(--away-soft);
}

.bug-team .team-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  flex: none;
}

.bug-team-home .team-swatch {
  background: var(--home);
  box-shadow: 0 0 10px var(--home);
}

.bug-team-away .team-swatch {
  background: var(--away);
  box-shadow: 0 0 10px var(--away);
}

.bug-team .team-name {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.bug-team output {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.bug-clock {
  display: grid;
  place-items: center;
  padding: 0.15rem 0.9rem;
  border-radius: 999px;
  background: rgba(12, 20, 48, 0.9);
  border: 1px solid var(--line);
  line-height: 1.05;
  text-align: center;
}

.bug-clock strong {
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}

.bug-clock output {
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
  background: rgba(12, 20, 48, 0.85);
  color: var(--ink);
  font-size: 1rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  flex: none;
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.icon-button:not(:disabled):hover {
  border-color: var(--home);
}

/* ---------------------------------------------------------------------
   Scene
   --------------------------------------------------------------------- */

.scene-shell {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}

#game-canvas:focus-visible {
  box-shadow: inset 0 0 0 2px var(--home);
}

.loading-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 0.6rem;
  text-align: center;
  background: radial-gradient(60% 60% at 50% 45%, rgba(20, 34, 74, 0.85), rgba(4, 6, 13, 0.97));
  z-index: 5;
}

.loading-panel strong {
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.loading-panel span:not(.loading-puck) {
  color: var(--muted);
  font-size: 0.85rem;
}

.loading-puck {
  width: 1.6rem;
  height: 1.6rem;
  margin-inline: auto;
  border-radius: 50%;
  background: #0b0e16;
  border: 2px solid rgba(220, 235, 255, 0.9);
  box-shadow: 0 0 18px rgba(87, 182, 255, 0.6);
  animation: puck-slide 1.1s ease-in-out infinite alternate;
}

@keyframes puck-slide {
  from { transform: translateX(-2.4rem); }
  to { transform: translateX(2.4rem); }
}

.render-fallback {
  position: absolute;
  inset: auto 1rem 1rem;
  z-index: 6;
  margin: 0;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line-bright);
}

.render-fallback a {
  color: var(--home);
}

/* ---------------------------------------------------------------------
   Touch controls
   --------------------------------------------------------------------- */

.touch-controls {
  position: absolute;
  inset: auto 0 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 1rem calc(0.9rem + env(safe-area-inset-bottom));
  pointer-events: none;
  z-index: 4;
}

@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
}

.touch-joystick {
  position: relative;
  width: 7.4rem;
  height: 7.4rem;
  pointer-events: auto;
  touch-action: none;
}

.joystick-base {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(40, 64, 130, 0.5), rgba(8, 14, 34, 0.75));
  border: 1.5px solid var(--line-bright);
  box-shadow: inset 0 0 24px rgba(20, 40, 90, 0.6);
}

.joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3rem;
  height: 3rem;
  margin: -1.5rem 0 0 -1.5rem;
  border-radius: 50%;
  background: radial-gradient(circle at 42% 34%, #9fd0ff, var(--home) 70%);
  box-shadow: 0 0 16px rgba(87, 182, 255, 0.65);
  transition: transform 40ms linear;
}

.touch-buttons {
  display: grid;
  grid-template-columns: repeat(3, auto);
  grid-template-areas:
    "boost pass shoot"
    "switch check shoot";
  gap: 0.5rem;
  pointer-events: auto;
}

.touch-button {
  min-width: 4.1rem;
  min-height: 3.2rem;
  padding: 0.4rem 0.6rem;
  border-radius: 1rem;
  border: 1.5px solid var(--line-bright);
  background: rgba(10, 18, 42, 0.8);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.touch-button:active {
  transform: scale(0.94);
  border-color: var(--home);
  box-shadow: 0 0 14px rgba(87, 182, 255, 0.5);
}

.touch-boost { grid-area: boost; }
.touch-pass { grid-area: pass; }
.touch-check { grid-area: check; }
.touch-switch { grid-area: switch; }

.touch-shoot {
  grid-area: shoot;
  min-height: 100%;
  background: linear-gradient(160deg, rgba(255, 211, 92, 0.24), rgba(120, 70, 10, 0.4));
  border-color: rgba(255, 211, 92, 0.55);
  color: var(--gold);
}

/* ---------------------------------------------------------------------
   Event strip
   --------------------------------------------------------------------- */

.event-strip {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 0.9rem calc(0.5rem + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(6, 10, 26, 0.98), rgba(6, 10, 26, 0.85));
  border-top: 1px solid var(--line);
  z-index: 10;
}

.event-strip strong {
  flex: none;
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}

.event-strip p {
  margin: 0;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.event-strip button {
  margin-left: auto;
  flex: none;
}

/* ---------------------------------------------------------------------
   Buttons and dialogs
   --------------------------------------------------------------------- */

.primary-button,
.secondary-button,
.event-strip button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.3rem;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}

.primary-button {
  background: linear-gradient(150deg, #8fd4ff, var(--home));
  color: #04121f;
  box-shadow: 0 6px 24px rgba(87, 182, 255, 0.35);
}

.primary-button:hover {
  filter: brightness(1.08);
}

.secondary-button,
.event-strip button {
  background: rgba(12, 20, 48, 0.85);
  border-color: var(--line-bright);
  color: var(--ink);
}

.secondary-button:hover,
.event-strip button:hover {
  border-color: var(--home);
}

.game-dialog {
  margin: auto;
  max-width: min(30rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--line-bright);
  border-radius: 20px;
  background: var(--panel-deep);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.game-dialog::backdrop {
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(6px);
}

.dialog-rink {
  height: 9.5rem;
  background:
    radial-gradient(90% 130% at 50% 120%, rgba(87, 182, 255, 0.35), transparent 60%),
    linear-gradient(160deg, #16224a, #0a1024);
  position: relative;
}

.dialog-rink span {
  position: absolute;
  inset: 18% 12%;
  border: 2px solid rgba(210, 228, 255, 0.35);
  border-radius: 999px;
  box-shadow: 0 0 30px rgba(87, 182, 255, 0.25) inset;
}

.dialog-body {
  padding: 1.4rem 1.5rem 1.5rem;
}

.dialog-body > small {
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--home);
  margin-bottom: 0.5rem;
}

.dialog-body h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  line-height: 1.15;
}

.dialog-body p {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.controls-primer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 1rem;
  margin: 0 0 1.2rem;
  padding: 0;
  list-style: none;
}

.controls-primer li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.8rem;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  background: rgba(18, 28, 62, 0.55);
}

.controls-primer strong {
  color: var(--ink);
}

.controls-primer span {
  color: var(--muted);
  text-align: right;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.menu-stack {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.rules-drawer {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.rules-drawer summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--home);
}

.rules-drawer div {
  padding-top: 0.6rem;
}

.rules-drawer p {
  font-size: 0.86rem;
}

.last-result {
  margin: 0.8rem 0 0;
  font-size: 0.78rem;
  color: var(--gold);
}

.game-log {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  max-height: 50dvh;
  overflow-y: auto;
  display: grid;
  gap: 0.4rem;
}

.game-log li {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  background: rgba(18, 28, 62, 0.45);
  font-size: 0.85rem;
}

.game-log li small {
  flex: none;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  font-weight: 700;
}

.final-score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.4rem;
  margin: 1rem 0;
  padding: 0.9rem;
  border-radius: var(--radius);
  background: rgba(18, 28, 62, 0.55);
}

.final-score span {
  display: grid;
  place-items: center;
  gap: 0.15rem;
}

.final-score strong {
  font-size: 2.4rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.final-score small {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.final-score i {
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold);
}

.result-stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.3rem 1rem;
  margin: 0 0 1.1rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  background: rgba(18, 28, 62, 0.35);
  font-size: 0.84rem;
}

.result-stats dt {
  color: var(--muted);
  font-weight: 700;
}

.result-stats dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------------------------------------------------------------------
   Noscript and small screens
   --------------------------------------------------------------------- */

.noscript-panel {
  max-width: 26rem;
  margin: 4rem auto;
  padding: 2rem;
  border-radius: var(--radius);
  background: var(--panel);
  text-align: center;
}

.noscript-panel a {
  color: var(--home);
}

@media (max-width: 560px) {
  .bug-team .team-name {
    display: none;
  }

  .bug-clock {
    padding-inline: 0.6rem;
  }

  .game-brand small {
    display: none;
  }

  .controls-primer {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 420px) {
  .scorebug {
    padding-block: 0.3rem;
  }

  .event-strip {
    padding-block: 0.3rem;
  }

  .event-strip strong {
    display: none;
  }

  .touch-joystick {
    width: 6rem;
    height: 6rem;
  }

  .touch-button {
    min-height: 2.6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loading-puck {
    animation: none;
  }

  .touch-button:active {
    transform: none;
  }

  .skip-link {
    transition: none;
  }
}
