:root {
  --ink: #111827;
  --panel: #f8fafc;
  --line: rgba(148, 163, 184, 0.32);
  --muted: #94a3b8;
  --night: #101827;
  --blue: #38bdf8;
  --green: #22c55e;
  --yellow: #facc15;
  --red: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #07111f;
  color: #e5e7eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #082f49;
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
}

button:hover {
  filter: brightness(1.06);
}

.arena-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  min-height: 100vh;
}

.stage-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.9);
}

.back-link {
  color: #e5e7eb;
  font-weight: 800;
  text-decoration: none;
}

.score-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.score-strip span,
.score-strip strong {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(30, 41, 59, 0.7);
  color: #e5e7eb;
  font-size: 0.9rem;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overscroll-behavior: contain;
  padding: 16px;
}

#arenaCanvas {
  display: block;
  width: min(100%, 1800px);
  aspect-ratio: 3 / 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--night);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  touch-action: none;
  user-select: none;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  border-left: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.96);
  padding: 18px;
  overflow-y: auto;
}

.panel-block,
.join-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.72);
  padding: 14px;
}

.panel-block h1,
.panel-block h2 {
  margin: 0;
  font-size: 1.05rem;
}

.panel-block p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.join-form {
  display: grid;
  gap: 10px;
}

.join-form label {
  color: #cbd5e1;
  font-size: 0.9rem;
  font-weight: 800;
}

.join-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #f8fafc;
  outline: 0;
  padding: 0 12px;
}

.join-form input:focus {
  border-color: var(--blue);
}

.player-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.player-card {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.72);
  padding: 9px;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
}

.player-card strong,
.player-card small {
  display: block;
  overflow-wrap: anywhere;
}

.player-card small {
  color: var(--muted);
  margin-top: 2px;
}

.player-card em {
  color: var(--yellow);
  font-style: normal;
  font-weight: 800;
}

@media (max-width: 1020px) {
  .arena-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .score-strip {
    justify-content: flex-start;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  #arenaCanvas {
    width: 100%;
    max-height: 66vh;
  }
}
