:root {
  --bg: #0b0c10;
  --surface: #15161c;
  --surface-2: #1b1d25;
  --surface-3: #232630;
  --line: #30333f;
  --line-soft: #252833;
  --text: #f6f7fb;
  --muted: #a1a7b8;
  --pink: #e4007c;
  --pink-2: #ff4aad;
  --pink-soft: #2b1022;
  --green: #9ad66b;
  --green-bg: #142318;
  --danger: #ff7777;
  --danger-bg: #2a1518;
  --radius: 16px;
  --radius-control: 999px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.035), 0 8px 22px rgba(0, 0, 0, 0.22);
  font-family: ui-sans-serif, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.auth-shell {
  position: fixed;
  inset: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background: var(--bg);
  z-index: 20;
}

.auth-card {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-copy {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.auth-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar,
.section-head,
.top-actions,
.round-actions,
.timer-strip,
.timer-actions,
.inline-form,
.match-top,
.score-form,
.standing-row,
.player-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
}

.brand-lockup {
  display: grid;
  gap: 8px;
}

.brand-logo {
  display: block;
  width: 150px;
  height: auto;
  object-fit: contain;
}

.auth-logo {
  width: 166px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--pink-2);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 36px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 19px;
  letter-spacing: -0.01em;
}

.top-actions,
.round-actions,
.inline-form,
.score-form {
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions {
  justify-content: flex-end;
}

.save-state {
  min-width: 86px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 700;
}

.save-state.saving {
  color: var(--green);
  border-color: rgba(154, 214, 107, 0.32);
  background: var(--green-bg);
}

.control-strip,
.timer-strip,
.panel,
.automation-note {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.automation-note {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  color: var(--muted);
  background: var(--surface-2);
  border-left: 3px solid var(--pink);
}

.automation-note strong {
  color: var(--text);
}

.automation-note span {
  color: var(--muted);
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(110px, 0.5fr)) auto;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.timer-strip {
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.timer-display {
  display: block;
  margin-top: 2px;
  font-size: 38px;
  line-height: 1;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
}

.timer-actions {
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

label span,
.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0f1015;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(228, 0, 124, 0.18);
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button.primary {
  background: var(--pink);
  color: #ffffff;
  box-shadow: none;
}

.button.secondary {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
}

.button.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(209, 67, 67, 0.3);
}

.button:disabled {
  cursor: not-allowed;
  background: var(--surface-3);
  color: #747b91;
}

.button.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(420px, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.section-head {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.player-list,
.matches,
.standings {
  display: grid;
  gap: 10px;
}

.player-row,
.standing-row,
.match-card {
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  background: var(--surface-2);
}

.player-row {
  min-height: 56px;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  flex-wrap: wrap;
}

.player-name-input {
  flex: 1 1 150px;
  min-width: 0;
}

.match-card {
  padding: 16px;
}

.match-top {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.match-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.team {
  min-width: 0;
}

.team span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  font-weight: 900;
}

.team small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.versus {
  color: var(--pink-2);
  font-size: 13px;
  font-weight: 900;
}

.score-form {
  margin-top: 12px;
  justify-content: flex-end;
}

.score-form input,
.score-form select,
.round-actions input {
  width: 84px;
}

.score-form select {
  width: 112px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  padding: 0 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
}

.status.finished {
  color: var(--green);
  border-color: rgba(154, 214, 107, 0.32);
  background: var(--green-bg);
}

.standing-row {
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  padding: 12px;
}

.rank {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-weight: 900;
}

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

.standing-main span,
.standing-stat {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.standing-stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  opacity: 0;
  pointer-events: none;
  max-width: min(520px, calc(100vw - 32px));
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f7fb;
  color: #101114;
  font-weight: 800;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.confirm-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.56);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.64);
}

.confirm-box {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.confirm-copy {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 1080px) {
  .control-strip,
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .work-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 100%);
    padding-top: 16px;
  }

  .topbar,
  .control-strip,
  .layout {
    grid-template-columns: 1fr;
  }

  .timer-strip {
    align-items: flex-start;
    flex-direction: column;
  }

  .timer-actions {
    justify-content: flex-start;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 28px;
  }

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

  .versus {
    display: none;
  }

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

@media print {
  body {
    color: #111;
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .top-actions,
  .control-strip,
  .timer-strip,
  .inline-form,
  .round-actions,
  .score-form,
  .toast,
  .confirm-dialog,
  .player-row .button {
    display: none !important;
  }

  .topbar,
  .layout {
    display: block;
  }

  .panel,
  .match-card,
  .standing-row,
  .player-row {
    break-inside: avoid;
    color: #111;
    border-color: #bbb;
    background: #fff;
    box-shadow: none;
  }

  .panel {
    margin: 0 0 16px;
  }

  .layout {
    gap: 0;
  }

  .team span,
  .standing-main strong,
  h1,
  h2 {
    color: #111;
  }

  .eyebrow,
  .versus,
  .rank {
    color: #111;
    background: transparent;
  }
}
