:root {
  --bg-1: #0a2f4d;
  --bg-2: #134f63;
  --bg-3: #f8efe2;
  --panel: rgba(255, 255, 255, 0.14);
  --panel-border: rgba(255, 255, 255, 0.35);
  --ink: #0d2438;
  --ink-soft: #f2f7ff;
  --left: #2aa0ff;
  --right: #ff8a3d;
  --accent: #ffd15c;
  --shadow: rgba(2, 10, 18, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink-soft);
  font-family: "Space Grotesk", sans-serif;
}

body {
  background: radial-gradient(circle at 15% 10%, rgba(255, 209, 92, 0.28), transparent 35%),
    radial-gradient(circle at 90% 90%, rgba(42, 160, 255, 0.3), transparent 40%),
    linear-gradient(130deg, var(--bg-1) 0%, var(--bg-2) 45%, #1e6f6f 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 40vmax;
  height: 40vmax;
  border-radius: 50%;
  z-index: -1;
  filter: blur(10px);
  animation: drift 18s ease-in-out infinite alternate;
}

body::before {
  top: -18vmax;
  left: -12vmax;
  background: rgba(255, 138, 61, 0.16);
}

body::after {
  right: -16vmax;
  bottom: -20vmax;
  background: rgba(42, 160, 255, 0.19);
}

@keyframes drift {
  from {
    transform: translateY(-2%) translateX(-2%) scale(1);
  }
  to {
    transform: translateY(2%) translateX(2%) scale(1.08);
  }
}

.app-shell {
  width: min(1200px, 94vw);
  margin: 2rem auto 2.4rem;
  display: grid;
  gap: 1rem;
}

.title-wrap {
  text-align: center;
  animation: fade-up 700ms ease both;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.84rem;
  font-weight: 700;
}

.title-wrap h1 {
  margin: 0.2rem 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: clamp(2.6rem, 8vw, 5rem);
  letter-spacing: 0.05em;
  line-height: 0.9;
}

.brand-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff8e2;
  text-shadow: 0 3px 0 rgba(8, 24, 38, 0.6), 0 12px 26px rgba(0, 0, 0, 0.35);
  padding: 0.12em 0.35em;
  display: inline-block;
  border-radius: 12px;
  background: linear-gradient(115deg, rgba(255, 209, 92, 0.25), rgba(42, 160, 255, 0.22));
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.subtitle {
  margin: 0;
  font-size: 1rem;
  opacity: 0.9;
}

.page-links {
  margin: 0.5rem 0 0;
}

.page-links button {
  display: inline-block;
  text-decoration: none;
  color: #062235;
  background: linear-gradient(90deg, #8bd0ff, #4cb6ff);
  border: none;
  border-radius: 999px;
  padding: 0.38rem 0.78rem;
  font-weight: 700;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.page-links button:hover {
  filter: brightness(1.06);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
}

.modal.is-open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 10, 18, 0.7);
  backdrop-filter: blur(2px);
}

.modal-panel {
  position: relative;
  width: min(760px, 92vw);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  margin: 1.5rem auto;
  background: linear-gradient(150deg, rgba(10, 37, 56, 0.98), rgba(9, 26, 40, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 16px;
  padding: 0.9rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  display: grid;
  gap: 0.75rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.close-btn {
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
  font-weight: 700;
  background: linear-gradient(90deg, #ffe483, #ffc65d);
  color: #062235;
  cursor: pointer;
}

body.modal-open {
  overflow: hidden;
}

.game-wrap {
  display: grid;
  gap: 0.9rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  backdrop-filter: blur(9px);
  box-shadow: 0 22px 44px var(--shadow);
  padding: 1rem;
  animation: fade-up 1s 120ms ease both;
}

.controls-panel,
.net-panel {
  order: 1;
}

.hud,
.canvas-frame {
  order: 2;
}

body.game-started .controls-panel,
body.game-started .net-panel {
  display: none;
}

.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.8rem;
  align-items: center;
}

.score-card {
  background: rgba(8, 24, 38, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.team-left {
  box-shadow: inset 0 0 0 1px rgba(42, 160, 255, 0.4);
}

.team-right {
  box-shadow: inset 0 0 0 1px rgba(255, 138, 61, 0.4);
}

.team-name {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.78rem;
  opacity: 0.95;
}

.score {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.hud-center {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
}

.hud-actions {
  display: flex;
  gap: 0.45rem;
  align-items: center;
}

#statusText {
  font-size: 0.9rem;
  font-weight: 500;
}

#resetBtn {
  border: none;
  border-radius: 999px;
  padding: 0.48rem 0.95rem;
  background: linear-gradient(90deg, #ffe483, #ffc65d);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

#resetBtn:hover {
  transform: translateY(-2px);
}

#resetBtn:active {
  transform: translateY(1px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

#endGameBtn {
  border: none;
  border-radius: 999px;
  padding: 0.48rem 0.95rem;
  background: linear-gradient(90deg, #ffb79f, #ff7f5a);
  color: #3b1409;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.2);
}

#endGameBtn:hover {
  transform: translateY(-2px);
}

#endGameBtn:active {
  transform: translateY(1px);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2);
}

.canvas-frame {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.22);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  background: #0f6a45;
}

.controls-panel {
  border-radius: 12px;
  background: rgba(8, 24, 38, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.85rem 1rem;
}

.net-panel {
  border-radius: 12px;
  background: rgba(7, 20, 30, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 0.85rem 1rem;
}

.controls-panel h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.net-panel h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.controls-grid {
  margin-top: 0.45rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.controls-grid h3 {
  margin: 0;
  font-size: 0.95rem;
}

.controls-grid ul {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
  line-height: 1.55;
  font-size: 0.93rem;
}

.tip {
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
  opacity: 0.9;
}

.mode-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.5rem;
  margin-top: 0.6rem;
  align-items: center;
}

.mode-row label {
  font-size: 0.86rem;
  opacity: 0.9;
}

.mode-display {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(6, 17, 28, 0.66);
  color: var(--ink-soft);
  padding: 0.45rem 0.55rem;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.start-row {
  align-items: center;
}

.start-row > span {
  font-size: 0.86rem;
  opacity: 0.9;
}

#startGameBtn {
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  background: linear-gradient(90deg, #8bd0ff, #4cb6ff);
  color: #062235;
  font-weight: 700;
  cursor: pointer;
}

#startGameBtn:hover {
  filter: brightness(1.05);
}

select,
input,
textarea,
.signal-card button {
  font: inherit;
}

select,
input,
textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(6, 17, 28, 0.66);
  color: var(--ink-soft);
  padding: 0.45rem 0.55rem;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.signal-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
}

.signal-card {
  background: rgba(8, 24, 38, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 0.65rem;
  display: grid;
  gap: 0.45rem;
  align-content: start;
}

.signal-card h3 {
  margin: 0;
  font-size: 0.92rem;
}

.signal-card label {
  font-size: 0.82rem;
  opacity: 0.9;
}

.signal-card button {
  border: none;
  border-radius: 999px;
  padding: 0.42rem 0.8rem;
  background: linear-gradient(90deg, #8bd0ff, #4cb6ff);
  color: #062235;
  font-weight: 700;
  cursor: pointer;
.copy-json-btn {
  margin-top: 0.3rem;
}
}

.signal-card button:hover {
  filter: brightness(1.05);
}

.status-strip {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.status-strip span {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
}

body[data-net-mode="host"] .client-only,
body[data-net-mode="client"] .host-only {
  display: none;
}

body[data-can-host="false"] .host-only {
  display: none;
}

.info-shell .game-wrap {
  gap: 0.75rem;
}

.info-card {
  background: rgba(8, 24, 38, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.info-card h3 {
  margin: 0;
  font-size: 1.02rem;
}

.info-card p,
.info-card li {
  font-size: 0.95rem;
  line-height: 1.55;
}

.info-card ul,
.info-card ol {
  margin: 0.55rem 0 0;
  padding-left: 1.1rem;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 920px) {
  .hud {
    grid-template-columns: 1fr;
  }

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

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

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