:root {
  color-scheme: dark;
  --bg: #0d1117;
  --bg-elev: #121826;
  --panel: #141c2b;
  --ink: #f2f6ff;
  --muted: #b9c6d9;
  --accent: #2dd4bf;
  --accent-strong: #22c1b3;
  --target: #ff6b6b;
  --score: #2dd4bf;
  --attempts: #f2c46d;
  --rounds: #8b7bf0;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 60px rgba(4, 9, 20, 0.5);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Avenir", "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 15% -10%, rgba(45, 212, 191, 0.22), transparent 60%),
    radial-gradient(900px 460px at 110% 10%, rgba(59, 130, 246, 0.18), transparent 55%),
    linear-gradient(180deg, #0b0f16 0%, #0f1624 100%);
  min-height: 100vh;
  touch-action: manipulation;
}

h1,
h2,
h3 {
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.info-toggle-wrap {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 30;
}

.info-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.info-panel {
  position: absolute;
  right: 0;
  top: 40px;
  min-width: 220px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.info-panel.hidden {
  display: none;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.small {
  font-size: 0.75rem;
  color: var(--muted);
}

.auth-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.auth-btn {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

.lang-toggle {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--ink);
  font-size: 0.8rem;
  cursor: pointer;
}

.room-page {
  background: var(--bg);
  color: var(--ink);
}

.room-page .wrap {
  max-width: 1280px;
  padding: 1.5rem;
}

.room-wrap {
  max-width: 1280px;
}

.double-layout {
  display: grid;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
}

.double-layout.dimmed {
  opacity: 0.35;
}

.top-meta {
  display: grid;
  gap: 4px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.mt-20 {
  margin-top: 1.25rem;
}

.grid.cols-120 {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.inline-check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

label {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input,
select {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.65rem 0.8rem;
  font-size: 1rem;
  background: var(--bg-elev);
  color: var(--ink);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #051319;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(45, 212, 191, 0.25);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--ink);
}

.status {
  margin-top: 0.75rem;
  color: var(--muted);
  min-height: 1.2rem;
}

.room-layout {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(320px, 1.4fr);
  gap: 1.5rem;
  align-items: start;
}

.video-panel {
  display: grid;
  gap: 1rem;
}

.video-card {
  position: relative;
  background: var(--bg-elev);
  border-radius: 18px;
  overflow: hidden;
  min-height: 220px;
}

.video-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card .tag {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 12px;
}

.player-box {
  border: 2px solid var(--target);
  border-radius: 8px;
  padding: 8px;
  min-height: 90px;
  display: grid;
  gap: 6px;
  background: var(--bg-elev);
}

.player-box.active {
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.4);
}

.player-name {
  font-size: 12px;
  color: var(--muted);
}

.player-double {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.player-score {
  background: var(--score);
  border-radius: 4px;
  padding: 6px 8px;
  font-weight: 700;
  text-align: center;
  color: #051319;
}

.attempts-bar,
.rounds-bar {
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
}

.attempts-bar {
  background: var(--attempts);
  color: #2b220c;
}

.rounds-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: stretch;
}

.rounds-bar {
  background: var(--rounds);
  color: var(--text);
  justify-content: flex-start;
  gap: 12px;
}

.strike-indicator {
  font-size: 20px;
  line-height: 1;
  min-width: 24px;
  text-align: center;
}

.throw-icons {
  display: flex;
  gap: 6px;
  margin-left: auto;
  font-size: 20px;
  line-height: 1;
}

.throw-icon {
  opacity: 0.95;
  filter: saturate(1.1);
}

.throw-icon.used {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.controls-inline {
  display: grid;
  gap: 8px;
}

.video-stage {
  border: 3px solid var(--accent);
  border-radius: 10px;
  min-height: 220px;
  position: relative;
  overflow: hidden;
  background: #000;
}

.video-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-stage video.mirrored {
  transform: scaleX(-1);
}

.video-pip {
  position: absolute;
  width: 38%;
  height: 32%;
  right: 10px;
  bottom: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
}

.video-pip {
  display: none !important;
}

.video-stage .spectator-note {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: 999px;
}

.game-panel {
  display: grid;
  gap: 1rem;
}

.game-header {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}


.room-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.room-label #room-label {
  text-transform: none;
  letter-spacing: normal;
}

.players {
  display: grid;
  gap: 1rem;
}

.player-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.06);
}

.player-card.active {
  border-color: var(--accent);
  box-shadow: 0 10px 20px rgba(15, 61, 62, 0.15);
}

.player-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.player-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 0.6rem;
}

.stat-box {
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
}

.stat-box span {
  font-size: 1.15rem;
  font-weight: 700;
}

.stat-target {
  background: var(--target);
}

.stat-score {
  background: var(--score);
}

.stat-attempts {
  background: var(--attempts);
  color: #2b220c;
}

.stat-rounds {
  background: var(--rounds);
}

.player-footer {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.controls {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.35);
  display: grid;
  gap: 1rem;
}

.throw-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.throw-slot {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.8rem 0.5rem;
  text-align: center;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}

.throw-slot.hit {
  background: rgba(125, 215, 125, 0.18);
  border-color: #7dd77d;
  color: #dff3df;
}

.throw-slot.miss {
  background: rgba(255, 107, 107, 0.18);
  border-color: var(--danger);
  color: #ffd9d9;
}

.control-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.control-buttons button {
  flex: 1 1 120px;
}

.spectator-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 18, 30, 0.6);
  padding: 1.5rem;
  z-index: 10;
}

.modal-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow);
  display: grid;
  gap: 1rem;
}

@media (max-width: 900px) {
  .double-layout {
    max-width: 100%;
  }
}

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

  .throw-row {
    grid-template-columns: repeat(3, minmax(60px, 1fr));
  }

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

  .controls-inline {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .video-pip {
    width: 42%;
    height: 30%;
  }
}
