:root {
  color-scheme: dark;
  --bg: #090a0d;
  --surface: #151820;
  --surface-raised: #1b1f29;
  --surface-soft: #232936;
  --surface-strong: #f4f7fb;
  --ink: #f4f7fb;
  --ink-inverse: #0d1016;
  --muted: #a5afc0;
  --line: #303848;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
  --accent: #5d93ff;
  --accent-dark: #376bd7;
  --danger: #d7263d;
  --orange: #d65f2d;
  --gold: #ffd166;
  --green: #237a3a;
  --teal: #087f8c;
  --blue: #5d93ff;
  --violet: #a78bfa;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(93, 147, 255, 0.12), rgba(43, 192, 200, 0.08) 42%, rgba(255, 209, 102, 0.08)),
    var(--bg);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 12vw, 4.75rem);
  font-weight: 700;
  line-height: 0.92;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
  font-weight: 600;
}

.timer {
  flex: 0 0 auto;
  min-width: 112px;
  padding: 10px 12px;
  color: var(--ink-inverse);
  background: var(--surface-strong);
  border-radius: 8px;
  text-align: right;
  box-shadow: var(--shadow);
}

.timer-label {
  display: block;
  margin-bottom: 2px;
  color: rgba(13, 16, 22, 0.7);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.timer strong {
  display: block;
  font-variant-numeric: tabular-nums;
  font-size: 1.04rem;
  font-weight: 650;
}

.identity-panel,
.main-panel {
  background: rgba(21, 24, 32, 0.92);
  border: 1px solid rgba(48, 56, 72, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.identity-panel {
  padding: 16px;
}

.panel-heading {
  margin-bottom: 16px;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.user-choice {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 600;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease;
}

.user-choice:hover,
.user-choice:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.user-choice.selected {
  color: var(--ink-inverse);
  background: var(--surface-strong);
  border-color: var(--surface-strong);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  transform: translateY(-1px);
}

.user-icon {
  display: inline-block;
  flex: 0 0 auto;
  line-height: 1;
}

.user-name-line,
.person-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.primary-button,
.vote-button,
.secondary-button,
.danger-button,
.scope-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font-weight: 650;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  color: #fff;
  background: var(--accent);
}

.primary-button:disabled,
.vote-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.inline-button {
  width: auto;
  min-width: 106px;
  margin-top: 0;
  padding: 0 16px;
}

.password-panel {
  margin-top: 14px;
  padding: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.password-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.password-heading strong {
  font-weight: 650;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.password-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.password-row input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.password-row input:focus {
  border-color: var(--accent);
  outline: none;
}

.text-input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.text-input:focus {
  border-color: var(--accent);
  outline: none;
}

.main-panel {
  padding: 12px;
}

.hidden {
  display: none !important;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.current-user {
  flex: 1;
  min-height: 48px;
  padding: 8px 10px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.current-user span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.current-user strong {
  display: block;
  font-size: 1.08rem;
  font-weight: 650;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.tab {
  min-height: 42px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 650;
}

.tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.24);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.scope-buttons {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  padding-bottom: 2px;
  overflow-x: auto;
}

.scope-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.scope-button.active {
  color: var(--ink-inverse);
  background: var(--surface-strong);
  border-color: var(--surface-strong);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.vote-list,
.standings-list,
.bracket-list {
  display: grid;
  gap: 10px;
}

.vote-card,
.standing-row,
.bracket-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.vote-card {
  padding: 12px;
}

.vote-card.locked {
  background: rgba(35, 41, 54, 0.72);
}

.vote-card.admin-locked {
  border-color: rgba(255, 209, 102, 0.32);
  background: rgba(255, 209, 102, 0.06);
}

.vote-topline,
.score-line,
.standing-row,
.bracket-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vote-topline {
  justify-content: space-between;
  margin-bottom: 12px;
}

.person-name {
  font-size: 1.12rem;
  font-weight: 650;
}

.lock-badge {
  color: #fff;
  background: var(--green);
}

.score-line {
  justify-content: space-between;
  margin-bottom: 10px;
}

.score-number {
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 750;
  line-height: 1;
}

.bracket-chip {
  min-width: 0;
  max-width: 58%;
  padding: 7px 9px;
  color: var(--bracket-ink, #fff);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
}

.slider {
  width: 100%;
  height: 34px;
  accent-color: var(--accent);
}

.vote-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.vote-button {
  min-width: 96px;
  padding: 0 16px;
  color: var(--ink-inverse);
  background: var(--surface-strong);
}

.secondary-button {
  min-width: 82px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.danger-button {
  width: 100%;
  padding: 0 14px;
  color: #fff;
  background: var(--danger);
}

.locked-score {
  color: var(--muted);
  font-weight: 500;
}

.standing-row {
  min-height: 74px;
  padding: 10px;
}

.rank {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--ink-inverse);
  background: var(--surface-strong);
  border-radius: 8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.emoji-rank {
  color: var(--ink);
  background: transparent;
  font-size: 1.25rem;
}

.standing-main {
  flex: 1;
  min-width: 0;
}

.standing-main strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 650;
}

.standing-main span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.standing-score {
  min-width: 70px;
  text-align: right;
}

.standing-score strong {
  display: block;
  font-size: 1.42rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.standing-score span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.bracket-ladder {
  margin-top: 18px;
}

.bracket-row {
  min-height: 58px;
  padding: 10px;
  border-left-width: 8px;
}

.bracket-row strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 600;
}

.bracket-row span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}

.bracket-range {
  margin-left: auto;
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tight-heading {
  margin-bottom: 10px;
}

.settings-card {
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-card h3 {
  margin-bottom: 10px;
}

.settings-card .primary-button {
  margin-top: 12px;
}

.variable-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.variable-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  color: var(--muted);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.78rem;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.bracket-editor-list {
  display: grid;
  gap: 10px;
}

.bracket-edit-row {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.bracket-edit-fields {
  display: grid;
  gap: 8px;
}

.bracket-edit-fields label {
  display: grid;
  gap: 4px;
}

.bracket-edit-fields span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.bracket-color-input {
  width: 100%;
  min-height: 44px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compact-button {
  min-height: 36px;
  padding: 0 12px;
}

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

.member-control-list {
  display: grid;
  gap: 10px;
}

.member-control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.member-control-main strong,
.member-control-main span {
  display: block;
}

.member-control-main strong {
  font-weight: 650;
}

.member-control-main span {
  color: var(--muted);
  font-size: 0.82rem;
}

.member-control-main span + span {
  margin-top: 2px;
}

.member-control-grid {
  display: grid;
  gap: 8px;
}

.member-control-field {
  display: grid;
  gap: 4px;
}

.member-control-field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.member-score-input {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.member-score-input:focus {
  border-color: var(--accent);
  outline: none;
}

.member-control-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.member-control-actions.full-width {
  grid-column: 1 / -1;
}

.member-control-actions .secondary-button,
.member-control-actions .danger-button {
  width: 100%;
  min-width: 0;
  padding: 0 8px;
}

.password-reset-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 56px;
  padding: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.password-reset-row strong,
.password-reset-row span {
  display: block;
}

.password-reset-row strong {
  font-weight: 650;
}

.password-reset-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  display: none;
  min-height: 44px;
  padding: 12px 14px;
  color: var(--ink-inverse);
  background: var(--surface-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-weight: 600;
}

.toast.show {
  display: block;
}

.bracket-chip,
.bracket-row {
  background: var(--bracket-color, var(--surface-soft));
}

.bracket-row {
  background: var(--surface-raised);
  border-left-color: var(--bracket-color);
}

@media (min-width: 720px) {
  .app-shell {
    padding: 28px;
  }

  .topbar {
    align-items: center;
    padding-bottom: 24px;
  }

  .identity-panel,
  .main-panel {
    padding: 18px;
  }

  .user-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .main-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .vote-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .standings-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bracket-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .member-control-row {
    grid-template-columns: minmax(170px, 0.72fr) minmax(0, 1.28fr);
    align-items: start;
  }

  .member-control-grid {
    grid-template-columns: minmax(140px, 1fr) minmax(190px, 1fr);
    align-items: end;
  }

  .bracket-edit-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
  }

  .bracket-edit-fields {
    grid-template-columns: minmax(130px, 1.1fr) minmax(170px, 1.4fr) 82px 82px 76px;
  }

  .toast {
    right: 28px;
    left: auto;
    width: min(360px, calc(100vw - 56px));
  }
}

@media (min-width: 980px) {
  .main-panel {
    display: block;
  }
}
