:root {
  --bg: #f6f1e8;
  --bg-accent: #eadcc8;
  --surface: rgba(255, 252, 246, 0.92);
  --surface-strong: #fffaf2;
  --text: #22201c;
  --muted: #6f675a;
  --line: rgba(34, 32, 28, 0.12);
  --brand: #0d5b4f;
  --brand-strong: #093b34;
  --highlight: #d77f2f;
  --shadow: 0 22px 50px rgba(86, 63, 20, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(215, 127, 47, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(13, 91, 79, 0.18), transparent 30%),
    linear-gradient(180deg, var(--bg) 0%, #f3ebdf 100%);
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.shell.narrow {
  width: min(860px, calc(100vw - 32px));
}

.hero,
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(16px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 28px;
  margin-bottom: 24px;
}

.card {
  padding: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  font-size: 0.8rem;
}

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

h1 {
  max-width: 12ch;
  font-size: clamp(2rem, 4vw, 4.4rem);
  line-height: 0.95;
}

.lede {
  max-width: 62ch;
  color: var(--muted);
}

.admin-link,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  color: #fff7f0;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  cursor: pointer;
}

button:hover {
  filter: brightness(1.06);
}

.admin-link {
  min-height: auto;
  padding: 4px 10px;
  background: none;
  color: var(--muted);
  font-size: 0.78rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  align-self: center;
}

.admin-link:hover {
  filter: none;
  color: var(--text);
  background: rgba(34, 32, 28, 0.05);
}

details.timeline-stage > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
}

details.timeline-stage > summary::-webkit-details-marker {
  display: none;
}

details.timeline-stage > summary::before {
  content: "▶";
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

details.timeline-stage[open] > summary::before {
  transform: rotate(90deg);
}

details.timeline-stage > summary h3 {
  margin: 0;
}

.section-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.muted {
  color: var(--muted);
}

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

.stack.compact {
  gap: 10px;
}

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

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

.grid.three {
  grid-template-columns: 2fr 1fr 1fr;
  gap: 24px;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 600;
}

input,
select {
  min-height: 46px;
  width: 100%;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-weight: 700;
}

.timeline {
  display: grid;
  gap: 18px;
}

.timeline-stage {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 248, 236, 0.84);
  border: 1px solid var(--line);
}

.match {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}

.match:last-child {
  border-bottom: none;
}

.match .score {
  font-weight: 700;
  color: var(--brand);
}

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

.team-line,
.user-line,
.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.team-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.team-chip {
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 248, 236, 0.84);
}

.team-flag {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  background: #fff;
  border: 1px solid rgba(34, 32, 28, 0.08);
  flex: 0 0 auto;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  background: var(--bg-accent);
  border: 2px solid var(--line);
  flex: 0 0 auto;
}

.user-avatar-preview {
  width: 80px;
  height: 80px;
  border-radius: 999px;
  object-fit: cover;
  border: 3px solid var(--brand);
  display: block;
}

.bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(13, 91, 79, 0.12);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--highlight), var(--brand));
}

.hidden {
  display: none;
}

.login-error {
  color: #b91c1c;
  font-weight: 600;
  margin: 0;
}

/* ─── custom team select ─────────────────────────────────────────────────── */

.cs-wrapper {
  position: relative;
}

.cs-trigger {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cs-trigger::after {
  content: "▾";
  font-size: 0.9rem;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform 0.15s;
}

.cs-trigger.open::after {
  transform: rotate(180deg);
}

.cs-trigger:hover {
  filter: brightness(0.97);
}

.cs-placeholder {
  color: var(--muted);
}

.cs-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 200;
}

.cs-option {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.cs-option-placeholder {
  color: var(--muted);
  font-size: 0.9em;
}

.cs-option:hover {
  background: rgba(13, 91, 79, 0.07);
}

.cs-option.selected {
  background: rgba(13, 91, 79, 0.12);
  font-weight: 600;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.user-row:last-child {
  border-bottom: none;
}

.user-row-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-row-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-danger {
  background: linear-gradient(135deg, #b91c1c, #7f1d1d);
}

.edit-form {
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(13, 91, 79, 0.04);
  border: 1px solid var(--line);
  display: grid;
  gap: 10px;
}

pre {
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  background: #211d18;
  color: #f7f1e7;
}

.actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

@media (max-width: 900px) {
  body {
    min-height: 100dvh;
  }

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

  .shell,
  .shell.narrow {
    width: min(100vw - 20px, 100%);
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
  }

  .hero,
  .section-header {
    flex-direction: column;
    align-items: start;
  }

  h1 {
    max-width: none;
  }

  .card,
  .hero {
    border-radius: 20px;
    padding: 18px;
  }

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