:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #07080a;
  color: #f4f7f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(43, 214, 123, 0.08), transparent 260px),
    radial-gradient(circle at 20% -10%, rgba(244, 201, 93, 0.14), transparent 270px),
    #07080a;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  width: min(560px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom));
}

.topbar,
.section-head,
.action-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 16px;
}

.sticky-top {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 8px 0;
  background: rgba(7, 8, 10, 0.88);
  backdrop-filter: blur(14px);
}

.brand,
.section-head > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: #8c98a5;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 31px;
  line-height: 1.02;
}

h2 {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.1;
}

h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

.muted {
  color: #9ca7b4;
}

.stack {
  display: grid;
  gap: 12px;
}

.panel,
.scoreboard {
  border: 1px solid #252b34;
  border-radius: 8px;
  background: rgba(18, 21, 27, 0.94);
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

.scoreboard {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
  padding: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent, #2bd67b) 18%, transparent), transparent 58%),
    #11161c;
}

.hero-arena p,
.scoreboard p {
  margin-bottom: 0;
  color: #b6c1c9;
  line-height: 1.42;
}

.hero-actions,
.actions,
.bottom-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.hero-actions {
  grid-template-columns: 1fr;
}

.bottom-actions {
  position: sticky;
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 4;
  margin-top: 14px;
  padding: 8px;
  border: 1px solid #252b34;
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.9);
  backdrop-filter: blur(16px);
}

.bottom-actions.single {
  grid-template-columns: 1fr;
}

.button {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #2bd67b;
  color: #06110b;
  font-weight: 950;
  cursor: pointer;
}

.button:disabled {
  opacity: 0.45;
}

.button.secondary {
  background: #252b33;
  color: #f4f7f8;
}

.button.ghost {
  background: transparent;
  color: #cbd4dd;
  border: 1px solid #323944;
}

.button.danger {
  background: #ff6b6b;
  color: #170607;
}

.button.compact {
  min-height: 38px;
  padding: 8px 10px;
}

.button.xl {
  min-height: 54px;
  font-size: 16px;
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #f4f7f8;
  color: #11161c;
  font-weight: 950;
}

.grid {
  display: grid;
  gap: 10px;
}

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

.template-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.template-card,
.choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 12px;
  border: 1px solid #252b34;
  border-radius: 8px;
  background: #121720;
  color: #f4f7f8;
  text-align: left;
}

.template-card small,
.choice-subtitle {
  display: block;
  margin-top: 3px;
  color: #99a5b1;
  font-size: 13px;
  line-height: 1.25;
}

.team-editor {
  display: grid;
  gap: 8px;
}

.team-config {
  display: grid;
  grid-template-columns: 54px 1fr 54px;
  gap: 8px;
  padding: 8px;
  border: 1px solid color-mix(in srgb, var(--team-color, #2c3440) 48%, #2c3440);
  border-radius: 8px;
  background: #10151c;
  box-shadow: inset 4px 0 0 var(--team-color, #33d6ff);
}

.team-config .input {
  min-height: 40px;
  padding: 8px;
}

.template-icon,
.icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent, #2bd67b) 24%, #1a1f27);
  font-size: 23px;
}

.choice.active {
  border-color: var(--accent, #2bd67b);
  box-shadow: inset 0 0 0 1px var(--accent, #2bd67b);
}

.choice-title {
  display: block;
  font-weight: 950;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: #a7b0bd;
  font-size: 13px;
  font-weight: 900;
}

.input {
  width: 100%;
  min-height: 48px;
  border: 1px solid #2d3440;
  border-radius: 8px;
  padding: 10px 12px;
  background: #0b0f14;
  color: #f4f7f8;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 950;
}

.segmented,
.tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: #0c1015;
}

.segmented button,
.tab {
  min-height: 40px;
  border-radius: 7px;
  background: transparent;
  color: #aab3bd;
  font-weight: 900;
}

.segmented button.active,
.tab.active {
  background: #f4f7f8;
  color: #101318;
}

.tabs {
  grid-template-columns: repeat(3, 1fr);
  margin: 12px 0;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  color: #aab2bd;
  font-size: 13px;
  font-weight: 900;
}

.progress {
  height: 6px;
  flex: 1;
  overflow: hidden;
  border-radius: 999px;
  background: #242a31;
}

.progress.big {
  height: 10px;
}

.progress span {
  display: block;
  height: 100%;
  width: var(--progress);
  border-radius: inherit;
  background: #2bd67b;
}

.room-title {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.room-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
  color: #aab3bd;
  font-size: 12px;
  font-weight: 900;
}

.room-code,
.pill {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: #242a31;
  color: #cbd4dd;
  font-size: 12px;
  font-weight: 950;
}

.room-code {
  letter-spacing: 0.08em;
}

.live-dot {
  padding: 5px 8px;
  border-radius: 999px;
  background: #ff4d4d;
  color: #fff;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
}

.versus-board,
.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: stretch;
}

.team-panel,
.team {
  position: relative;
  display: grid;
  gap: 5px;
  min-height: 76px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--team-color, #2c3440) 48%, #2c3440);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--team-color, #2bd67b) 20%, transparent), transparent 64%),
    #171d25;
  color: #f4f7f8;
  font-weight: 950;
  text-align: left;
  overflow: hidden;
}

.team-panel {
  box-shadow: inset 4px 0 0 var(--team-color, #2bd67b);
}

.team-panel small {
  color: color-mix(in srgb, var(--team-color, #8e99a6) 42%, #c7d0da);
  font-size: 12px;
}

.team-panel.right {
  text-align: right;
  box-shadow: inset -4px 0 0 var(--team-color, #ff6b6b);
}

.team {
  box-shadow: inset 4px 0 0 var(--team-color, #2bd67b);
}

.team.team-b {
  text-align: right;
  box-shadow: inset -4px 0 0 var(--team-color, #ff6b6b);
}

.team-a {
  --team-color: #33d6ff;
}

.team-b {
  --team-color: #ffb020;
}

.team-badge {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  background: var(--team-color, #2bd67b);
  color: #071016;
  font-size: 12px;
  font-weight: 950;
}

.team-panel.right .team-badge,
.team.team-b .team-badge {
  justify-self: end;
}

.team-board {
  display: grid;
  gap: 9px;
}

.team-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--team-color, #2c3440) 52%, #2c3440);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--team-color, #33d6ff) 18%, transparent), transparent 68%),
    #11161c;
  color: #f4f7f8;
  text-align: left;
  box-shadow: inset 4px 0 0 var(--team-color, #33d6ff);
}

.team-card.active {
  box-shadow: inset 4px 0 0 var(--team-color, #33d6ff), 0 0 0 2px var(--team-color, #33d6ff);
}

.team-card-head,
.team-score-row,
.round-score {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

.team-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.team-members span {
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd4dd;
  font-size: 12px;
  font-weight: 850;
}

.team-score-list,
.round-score-grid {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.team-score-row,
.round-score {
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--team-color, #2c3440) 46%, #2c3440);
  border-radius: 8px;
  background: #171d25;
  box-shadow: inset 4px 0 0 var(--team-color, #33d6ff);
}

.team-score-row .input {
  width: 90px;
  min-height: 40px;
  text-align: right;
  font-weight: 950;
}

.score-vs,
.versus {
  display: grid;
  min-width: 42px;
  place-items: center;
  color: #838d99;
  font-size: 12px;
  font-weight: 950;
}

.versus.clickable {
  border-radius: 8px;
  background: #242a31;
  color: #f4f7f8;
}

.list {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid #252b34;
  border-radius: 8px;
  background: #11161c;
}

.match-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid #252b34;
  border-radius: 8px;
  background: #11161c;
}

.match-card.done {
  opacity: 0.82;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-strip span {
  display: grid;
  gap: 3px;
  min-height: 70px;
  align-content: center;
  padding: 10px;
  border-radius: 8px;
  background: #171d25;
}

.stat-strip strong {
  overflow: hidden;
  font-size: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-strip small {
  color: #8e99a6;
  font-weight: 900;
}

.reward-card {
  padding: 14px;
  border: 1px solid #33402c;
  border-radius: 8px;
  background: #151b12;
}

.empty {
  padding: 20px 12px;
  border: 1px dashed #333b46;
  border-radius: 8px;
  color: #8e98a5;
  text-align: center;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: end;
  padding: 12px;
  background: rgba(0, 0, 0, 0.5);
}

.sheet {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 16px;
  border: 1px solid #303844;
  border-radius: 8px;
  background: #11161c;
  box-shadow: 0 -24px 80px rgba(0, 0, 0, 0.45);
}

.score-editor {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.score-editor > div {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--team-color, #2c3440) 48%, #2c3440);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--team-color, #2bd67b) 18%, transparent), transparent 66%),
    #171d25;
  box-shadow: inset 4px 0 0 var(--team-color, #2bd67b);
}

.score-stepper {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
}

.score-stepper button,
.preset-grid button {
  min-height: 42px;
  border-radius: 8px;
  background: #252b33;
  color: #f4f7f8;
  font-weight: 950;
}

.score-stepper span {
  text-align: center;
  font-size: 36px;
  font-weight: 950;
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f4f7f8;
  color: #101318;
  font-weight: 900;
}

@media (max-width: 430px) {
  .grid.two,
  .actions,
  .template-grid,
  .score-editor,
  .stat-strip {
    grid-template-columns: 1fr;
  }

  .hero-actions,
  .bottom-actions {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 27px;
  }

  .versus-board,
  .teams {
    grid-template-columns: 1fr;
  }

  .score-vs,
  .versus {
    min-height: 32px;
  }
}
