:root {
  --ink: #102235;
  --muted: #5d6a77;
  --paper: #f7faf9;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(16, 34, 53, 0.12);
  --red: #db2747;
  --blue: #0068b5;
  --green: #159957;
  --gold: #f4b223;
  --cyan: #00a6d6;
  --grass: #0b7f4f;
  --shadow: 0 18px 48px rgba(16, 34, 53, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.34) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.24) 1px, transparent 1px),
    linear-gradient(135deg, rgba(0, 104, 181, 0.18), transparent 38%),
    linear-gradient(225deg, rgba(219, 39, 71, 0.16), transparent 36%),
    radial-gradient(circle at 50% 0%, rgba(244, 178, 35, 0.24), transparent 28%),
    var(--paper);
  background-size: 64px 64px, 64px 64px, auto, auto, auto, auto;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover:not(:disabled),
.link-button:hover {
  transform: translateY(-1px);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 900;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.app-header {
  position: relative;
  overflow: hidden;
  min-height: 260px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  padding: 40px clamp(18px, 5vw, 72px) 84px;
  color: white;
  background:
    linear-gradient(115deg, rgba(0, 87, 184, 0.86), rgba(12, 132, 86, 0.74) 48%, rgba(231, 29, 73, 0.78)),
    linear-gradient(rgba(9, 23, 42, 0.1), rgba(9, 23, 42, 0.48)),
    url("https://images.unsplash.com/photo-1517927033932-b3d18e61fb3a?auto=format&fit=crop&w=1800&q=80") center 44% / cover;
}

.app-header::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  border-radius: 28px;
  pointer-events: none;
}

.app-header::after {
  content: "";
  position: absolute;
  right: clamp(20px, 9vw, 140px);
  bottom: -54px;
  width: 210px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 22%, rgba(255, 255, 255, 0.96) 23% 28%, transparent 29%),
    conic-gradient(from 18deg, rgba(255,255,255,0.9) 0 10%, rgba(16,34,53,0.9) 10% 18%, rgba(255,255,255,0.9) 18% 30%, rgba(16,34,53,0.9) 30% 38%, rgba(255,255,255,0.9) 38% 52%, rgba(16,34,53,0.9) 52% 60%, rgba(255,255,255,0.9) 60% 74%, rgba(16,34,53,0.9) 74% 82%, rgba(255,255,255,0.9) 82% 100%);
  opacity: 0.24;
}

.app-header > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  padding: 7px 12px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(244, 178, 35, 0.94);
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 12px;
  font-size: clamp(2.4rem, 6vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.subtitle {
  max-width: 680px;
  margin-bottom: 0;
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: rgba(255, 255, 255, 0.9);
}

.header-actions,
.participant-tools,
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

main {
  width: min(1440px, calc(100% - 28px));
  margin: -52px auto 48px;
}

.score-strip,
.workspace {
  display: grid;
  gap: 16px;
}

.score-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.score-strip article,
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.score-strip article {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: 8px;
}

.score-strip article::after {
  content: "";
  position: absolute;
  right: -22px;
  top: -28px;
  width: 82px;
  height: 82px;
  border-radius: 50%;
  border: 14px solid rgba(0, 104, 181, 0.09);
}

.score-strip span {
  display: block;
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  font-weight: 900;
}

.score-strip p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 700;
}

.workspace {
  grid-template-columns: 320px minmax(0, 1fr);
  align-items: start;
}

.panel {
  border-radius: 8px;
}

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

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title.compact {
  margin-top: 24px;
}

.section-title h2 {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: 0;
}

.section-title span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.award {
  border-left: 5px solid var(--gold);
  padding: 12px;
  border-radius: 6px;
  background:
    linear-gradient(90deg, rgba(244, 178, 35, 0.18), rgba(255, 255, 255, 0.86)),
    white;
}

.award strong {
  display: block;
}

.award input {
  width: 100%;
  margin-top: 8px;
}

.award small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 800;
}

.rules-table-wrap {
  max-height: 286px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.rules-table {
  min-width: 0;
}

.rules-table th,
.rules-table td {
  padding: 9px 10px;
  vertical-align: top;
}

.rules-table th:first-child,
.rules-table td:first-child {
  width: 68px;
  text-align: center;
  font-weight: 900;
}

.rules-table td:first-child {
  color: var(--ink);
  background: linear-gradient(90deg, rgba(244, 178, 35, 0.22), rgba(21, 153, 87, 0.08));
}

.rules-table td:last-child {
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.25;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--ink);
  background: white;
}

.compact-select {
  width: auto;
  min-width: 220px;
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.file-drop {
  display: block;
  margin-top: 12px;
  padding: 16px;
  border: 1px dashed rgba(0, 104, 181, 0.45);
  border-radius: 8px;
  background: rgba(0, 104, 181, 0.08);
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.file-drop span,
.file-drop small {
  display: block;
}

.file-drop span {
  font-weight: 900;
}

.file-drop small {
  margin-top: 4px;
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.tab,
.primary,
.ghost,
.danger {
  min-height: 42px;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 900;
}

.primary {
  color: var(--ink);
  background: var(--gold);
  box-shadow: 0 10px 24px rgba(244, 178, 35, 0.32);
}

.tab {
  color: var(--muted);
  background: rgba(16, 34, 53, 0.07);
}

.tab.active {
  color: white;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
}

.ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}

.danger {
  color: white;
  background: var(--red);
}

.danger.subtle,
.table-action {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.full {
  width: 100%;
  margin-top: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.comparison-wrap {
  margin-bottom: 14px;
}

.comparison-wrap table {
  min-width: 820px;
}

.chart-panel {
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: white;
}

thead {
  background: linear-gradient(90deg, rgba(0, 104, 181, 0.1), rgba(244, 178, 35, 0.14));
}

.prize-wrap {
  margin-top: 12px;
}

.prize-table {
  min-width: 0;
}

.prize-table th,
.prize-table td {
  padding: 10px 8px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: rgba(0, 166, 214, 0.05);
}

.rank {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green), var(--blue));
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.filters {
  margin-bottom: 14px;
}

.filters button {
  min-width: 42px;
  min-height: 38px;
  border-radius: 999px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  font-weight: 900;
}

.filters button.active {
  color: white;
  background: linear-gradient(135deg, var(--red), var(--blue));
}

.matches-grid,
.projection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.match-card,
.projection-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.match-card::before,
.projection-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--gold), var(--red));
}

.match-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.teams span {
  color: var(--red);
  font-weight: 900;
}

.teams strong:last-child {
  text-align: right;
}

.score-inputs {
  display: grid;
  grid-template-columns: 62px 20px 62px;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
}

.score-inputs input {
  min-height: 38px;
  text-align: center;
  font-weight: 900;
}

.participant-tools {
  margin-bottom: 14px;
}

.participant-tools select {
  max-width: 260px;
}

.participant-tools #participantPin {
  max-width: 180px;
}

.knockout-admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1.2fr);
  gap: 16px;
  margin-bottom: 20px;
}

.admin-card,
.knockout-round-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.admin-card h3,
.knockout-round-card h3 {
  margin: 0 0 12px;
  color: var(--ink);
}

.deadline-grid,
.knockout-form {
  display: grid;
  gap: 10px;
}

.deadline-grid label,
.knockout-form label,
.knockout-match-admin label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.knockout-form button {
  align-self: end;
}

.knockout-master-import {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.knockout-master-import p {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.knockout-master-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.knockout-master-controls input {
  min-height: 40px;
}

.knockout-master-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

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

.summary-grid.compact span {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.summary-grid.compact strong {
  color: var(--ink);
}

.summary-errors {
  margin: 10px 0 0;
  color: #9f1239;
  font-weight: 700;
}

.summary-ok {
  margin: 10px 0 0;
  color: #047857;
  font-weight: 800;
}

.knockout-generator {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.knockout-generator p {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.knockout-generator > button {
  justify-self: start;
}

.knockout-generator-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.summary-warning {
  margin: 10px 0 0;
  color: #b45309;
  font-weight: 850;
}

.thirds-reference {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.thirds-reference strong {
  display: block;
  margin-bottom: 8px;
}

.thirds-reference ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 14px;
  margin: 0;
  padding-left: 18px;
}

.thirds-reference li {
  color: var(--ink);
  font-weight: 850;
}

.thirds-reference span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.knockout-admin-list {
  display: grid;
  gap: 14px;
}

.knockout-match-admin {
  display: grid;
  grid-template-columns: 86px repeat(4, minmax(86px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.knockout-match-admin:first-of-type {
  border-top: 0;
}

.knockout-match-admin .match-id {
  align-self: center;
  font-weight: 900;
  color: var(--blue);
}

.knockout-match-admin input,
.knockout-match-admin select {
  min-height: 36px;
  padding: 8px 10px;
}

.empty-state.small {
  padding: 12px;
}

.projection-card.correct {
  border-color: rgba(21, 153, 87, 0.45);
  background: rgba(21, 153, 87, 0.08);
}

.participant-awards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.award-mini {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.award-mini strong,
.award-mini span {
  display: block;
}

.award-mini span {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.award-mini.hit {
  border-color: rgba(21, 153, 87, 0.45);
  background: rgba(21, 153, 87, 0.08);
}

.participant-final-projection {
  margin-bottom: 14px;
}

.final-projection-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid #64748b;
  border-radius: 8px;
  background: #f8fafc;
}

.final-projection-card.hit {
  border-left-color: #16a34a;
  background: #ecfdf5;
}

.final-projection-card.miss {
  border-left-color: #dc2626;
  background: #fef2f2;
}

.final-projection-heading,
.final-projection-teams {
  display: flex;
  align-items: center;
  gap: 10px;
}

.final-projection-heading {
  justify-content: space-between;
  flex-wrap: wrap;
}

.final-projection-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 1rem;
}

.final-projection-status {
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
}

.final-projection-teams {
  margin-top: 10px;
  flex-wrap: wrap;
  color: var(--muted);
}

.final-projection-teams strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.final-projection-empty {
  font-weight: 800;
}

.empty-state {
  padding: 28px;
  border: 1px dashed rgba(0, 104, 181, 0.34);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.68);
  font-weight: 800;
  text-align: center;
}

.projection-card.missed {
  border-color: rgba(219, 39, 71, 0.3);
}

.points-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 4px 8px;
  border-radius: 999px;
  color: white;
  background: var(--blue);
  font-size: 0.82rem;
  font-weight: 900;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.status-pill.exact {
  background: var(--green);
}

.status-pill.outcome {
  background: var(--blue);
}

.status-pill.incorrect {
  background: var(--red);
}

.status-pill.pending {
  color: var(--ink);
  background: rgba(16, 34, 53, 0.12);
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 10;
}

.toast {
  max-width: 340px;
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: var(--ink);
  box-shadow: var(--shadow);
}

@media (max-width: 920px) {
  .app-header {
    display: block;
    padding-bottom: 76px;
  }

  .header-actions {
    margin-top: 22px;
  }

  .score-strip,
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  main {
    width: min(100% - 18px, 1440px);
  }

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

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

  .participant-tools select {
    max-width: none;
  }

  .participant-tools #participantPin {
    max-width: none;
  }

  .knockout-admin-grid,
  .knockout-form,
  .knockout-match-admin {
    grid-template-columns: 1fr;
  }
}
