:root {
  color-scheme: light;
  --ink: #101316;
  --ink-soft: #2b2f33;
  --accent: #ff8a00;
  --accent-2: #ff305f;
  --team-a: #ff8a00;
  --team-b: #4aa3ff;
  --bg-1: #f7f2eb;
  --bg-2: #e6eef7;
  --panel: #ffffff;
  --shadow: 0 18px 50px rgba(23, 30, 40, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, var(--bg-2), var(--bg-1) 55%);
  display: flex;
  justify-content: center;
}

body::before,
body::after {
  content: "";
  position: fixed;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  filter: blur(0);
  z-index: -1;
  opacity: 0.35;
}

body::before {
  background: #ffd8b5;
  top: -80px;
  left: -60px;
}

body::after {
  background: #c6e4ff;
  bottom: -90px;
  right: -70px;
}

.shell {
  width: min(1024px, 92vw);
  padding: 32px 0 60px;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 24px;
}

.brand-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-select {
  border-radius: 10px;
  border: 1px solid #d9dde3;
  padding: 6px 10px;
  font-size: 12px;
  background: #ffffff;
  color: var(--ink);
}

.logo {
  font-family: "Unbounded", "Space Grotesk", sans-serif;
  font-weight: 800;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.tag {
  font-size: 14px;
  color: var(--ink-soft);
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
  animation: rise 0.45s ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  background: var(--panel);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.card.hero {
  text-align: left;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
  align-items: center;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #101316;
  color: #f4f4f4;
  font-size: 12px;
  margin-bottom: 14px;
}

.hero-preview {
  display: grid;
  gap: 16px;
}

.preview-card {
  background: linear-gradient(145deg, #ffffff 0%, #f3f4f6 100%);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #6b7380;
}

.preview-head .dot {
  color: var(--accent-2);
}

.preview-bar {
  position: relative;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 138, 0, 0.25), #f1f3f6, rgba(74, 163, 255, 0.25));
}

.preview-fill {
  position: absolute;
  left: 50%;
  top: 3px;
  height: 12px;
  width: 38%;
  border-radius: 999px;
  background: linear-gradient(120deg, #101316, var(--accent), var(--accent-2));
}

.preview-knot {
  position: absolute;
  left: 62%;
  top: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #101316;
  box-shadow: 0 6px 12px rgba(16, 19, 22, 0.25);
}

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

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.mini-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.card h1,
.card h2 {
  margin: 0 0 12px;
  font-family: "Unbounded", sans-serif;
}

.card p {
  margin: 0 0 22px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.action-block {
  display: grid;
  gap: 6px;
}

.join {
  display: flex;
  gap: 10px;
  align-items: center;
}

input {
  border-radius: 12px;
  border: 1px solid #d9dde3;
  padding: 10px 14px;
  font-size: 14px;
  min-width: 200px;
}

.fine {
  margin-top: 18px;
  font-size: 13px;
  color: #6b7380;
}

.hint {
  font-size: 12px;
  color: #6b7380;
}

.hint.center {
  text-align: center;
  margin-top: 10px;
}

.btn {
  border: none;
  border-radius: 14px;
  padding: 12px 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn.small {
  padding: 8px 14px;
  font-size: 12px;
  border-radius: 10px;
}

.btn.icon-btn {
  padding: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: #101316;
}

.btn.icon-btn svg {
  width: 20px;
  height: 20px;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 10px 20px rgba(255, 120, 60, 0.25);
}

.btn.ghost {
  background: #eef0f3;
  color: var(--ink);
}

.btn.key {
  min-width: 120px;
  font-size: 22px;
  padding: 18px;
  background: #101316;
  color: #f4f4f4;
  position: relative;
}

.btn.key.is-next {
  box-shadow: 0 0 0 3px rgba(255, 138, 0, 0.35), 0 10px 20px rgba(255, 120, 60, 0.4);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lobby-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 20px;
}

.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin: 18px 0 20px;
}

.team-card {
  background: #f6f7f9;
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: inset 0 0 0 1px rgba(16, 19, 22, 0.06);
}

.team-card.spectators {
  background: #f1f3f6;
}

.team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-header h3 {
  margin: 0;
  font-size: 18px;
}

.team-count {
  font-size: 12px;
  color: #6b7380;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 999px;
}

.team-color {
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-color input[type="color"] {
  width: 36px;
  height: 28px;
  border: none;
  padding: 0;
  background: transparent;
}

.team-players,
.spectator-list {
  display: grid;
  gap: 8px;
  min-height: 48px;
}

.player-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #ffffff;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 13px;
}

.player-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.crown {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23f5b400'%3E%3Cpath d='M4 18h16v2H4v-2Zm0-9 4 3 4-6 4 6 4-3 2 8H2l2-8Z'/%3E%3C/svg%3E") no-repeat center;
  background-size: contain;
}

.player-chip .badge {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #eef0f3;
  color: #6b7380;
}

.player-chip.ready .badge {
  background: rgba(15, 125, 74, 0.15);
  color: #0f7d4a;
}

.copy-row {
  display: flex;
  gap: 10px;
}

.status {
  font-weight: 600;
  color: #40506a;
}

.meta {
  margin-top: 8px;
  font-size: 13px;
  color: #6b7380;
}

.hud {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.panel {
  background: var(--panel);
  padding: 16px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6b7380;
  margin-bottom: 6px;
}

.stat,
.next {
  font-size: 26px;
  font-weight: 700;
}

.next {
  font-family: "Unbounded", sans-serif;
}

.stat.muted {
  color: #6b7380;
}

.team-scores {
  display: grid;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
}

.team-score {
  display: flex;
  gap: 8px;
  align-items: center;
}

.team-label {
  display: flex;
  justify-content: space-between;
}

.balance-wrap {
  margin: 32px 0 20px;
}

.balance-track {
  height: 22px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--team-a) 25%, #fff) 0%, #f3f5f8 50%, color-mix(in srgb, var(--team-b) 25%, #fff) 100%);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(16, 19, 22, 0.08);
}

.balance-lane {
  position: absolute;
  inset: 6px 12px;
  border-radius: 999px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.6) 0,
    rgba(255, 255, 255, 0.6) 10px,
    rgba(255, 255, 255, 0) 10px,
    rgba(255, 255, 255, 0) 20px
  );
  opacity: 0.6;
}

.balance-core {
  position: absolute;
  top: 4px;
  height: 14px;
  width: 0;
  background: linear-gradient(120deg, #101316, var(--team-a), var(--team-b));
  border-radius: 999px;
  transition: width 0.08s linear;
}

.balance-knot {
  position: absolute;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #101316;
  box-shadow: 0 6px 12px rgba(16, 19, 22, 0.25);
  transform: translateX(-50%);
  transition: left 0.08s linear;
}

.marker {
  position: absolute;
  left: 50%;
  top: -6px;
  width: 2px;
  height: 32px;
  background: #101316;
  opacity: 0.35;
}

.balance-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #6b7380;
  margin-top: 6px;
}

.team-a-text {
  color: var(--team-a);
  font-weight: 600;
}

.team-b-text {
  color: var(--team-b);
  font-weight: 600;
}

#share-link{
    width: 100%;
}

.controls {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 24px;
}

.feedback {
  text-align: center;
  margin-top: 16px;
  font-weight: 600;
  min-height: 20px;
}

.toast {
  position: absolute;
  right: 32px;
  bottom: 20px;
  background: #101316;
  color: #f4f4f4;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 12px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

body.theme-dark {
  color-scheme: dark;
  --ink: #f2f4f8;
  --ink-soft: #c2c8d3;
  --accent: #ff9b3d;
  --accent-2: #ff4f7b;
  --bg-1: #0b0d11;
  --bg-2: #141a23;
  --panel: #12151c;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  background: radial-gradient(circle at top, #1a2230, #0b0d11 55%);
}

body.theme-dark::before {
  background: rgba(255, 110, 40, 0.25);
}

body.theme-dark::after {
  background: rgba(80, 140, 255, 0.25);
}

body.theme-dark .btn.ghost {
  background: #1b2029;
  color: var(--ink);
}

body.theme-dark .btn.icon-btn {
  color: #f4f4f4;
}

body.theme-dark .lang-select {
  background: #0f1218;
  border-color: #2a2f3a;
  color: var(--ink);
}

body.theme-dark input {
  background: #0f1218;
  border-color: #2a2f3a;
  color: var(--ink);
}

body.theme-dark .preview-card,
body.theme-dark .mini-card,
body.theme-dark .panel,
body.theme-dark .team-card,
body.theme-dark .roster-team {
  background: #141922;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

body.theme-dark .player-chip {
  background: #10141b;
}

body.theme-dark .preview-bar {
  background: linear-gradient(90deg, rgba(255, 155, 61, 0.2), #1a1f2a, rgba(74, 163, 255, 0.2));
}

body.theme-dark .balance-track {
  background: linear-gradient(90deg, rgba(255, 155, 61, 0.2) 0%, #1a1f2a 50%, rgba(74, 163, 255, 0.2) 100%);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 20px 0 10px;
}

.roster-team {
  background: #f6f7f9;
  border-radius: 16px;
  padding: 12px;
  box-shadow: inset 0 0 0 1px rgba(16, 19, 22, 0.05);
}

.roster-team.team-a {
  border-left: 4px solid var(--team-a);
}

.roster-team.team-b {
  border-left: 4px solid var(--team-b);
}

.roster-list {
  display: grid;
  gap: 8px;
}

.player-chip .cps {
  font-size: 11px;
  color: #40506a;
}

.game-help {
  text-align: center;
  font-size: 13px;
  color: #6b7380;
  margin-top: 14px;
}

.feedback.ok {
  color: #0f7d4a;
}

.feedback.bad {
  color: #b62c36;
}

@media (max-width: 720px) {
  .brand {
    flex-direction: column;
    gap: 6px;
  }

  .controls {
    flex-direction: column;
  }

  .btn.key {
    width: 100%;
  }
}
