:root {
  --bg: #070707;
  --surface: #111111;
  --surface-2: #181818;
  --border: #262626;
  --text: #f2f2f2;
  --muted: #8a8a8a;
  --accent: #c9a227;
  --accent-2: #3ecf8e;
  --danger: #e05a5a;
  --locked: #2a2a2a;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.4;
}

.page {
  min-height: 100vh;
}

.landing-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1.5rem;
}

.landing-page .header {
  border: none;
  background: transparent;
  text-align: center;
  width: 100%;
  max-width: 480px;
}

.landing-lead {
  color: var(--muted);
  margin: 0.5rem 0 0;
}

.landing-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 480px;
  margin-top: 2rem;
}

.landing-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}

.landing-card:hover {
  border-color: var(--accent);
}

.landing-card-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.landing-card-desc {
  font-size: 0.875rem;
  color: var(--muted);
}

.landing-card-admin {
  margin-top: 0.5rem;
  border-style: dashed;
}

.header {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #101010 0%, var(--bg) 100%);
}

.header-top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.75rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.auth-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.auth-status {
  color: var(--muted);
  font-size: 0.875rem;
  margin-right: 0.25rem;
}

.last-updated {
  color: var(--muted);
  font-size: 0.78rem;
  margin-right: 0.5rem;
}

input {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  font: inherit;
}

button, .back-link {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

button:hover, .back-link:hover {
  border-color: #444;
}

button.accent {
  background: rgba(201, 162, 39, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-lg {
  width: 88px;
  height: 88px;
  font-size: 1.5rem;
  border-width: 2px;
  border-color: #333;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-wrap {
  position: relative;
  display: inline-flex;
}

.crown {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.8));
  z-index: 1;
}

.table-wrap {
  overflow: auto;
  padding: 0 0 2rem;
}

.tips-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.tips-table th,
.tips-table td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
}

.tips-table th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #0d0d0d;
  padding: 0.85rem 0.65rem;
  text-align: center;
  min-width: 170px;
}

.tips-table th.col-self {
  background: #121008;
  box-shadow: inset 0 -2px 0 var(--accent);
}

.tips-table th.match-col,
.tips-table td.match-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #0b0b0b;
  min-width: 260px;
  max-width: 280px;
  overflow: visible;
}

.tips-table tbody tr:has(.team-info:hover),
.tips-table tbody tr:has(.team-info:focus-within) {
  position: relative;
  z-index: 25;
}

.tips-table tbody tr:has(.team-info:hover) td.match-col,
.tips-table tbody tr:has(.team-info:focus-within) td.match-col {
  z-index: 26;
}

.tips-table th.match-col {
  z-index: 4;
}

.tips-table td {
  padding: 0.5rem;
  background: var(--bg);
}

.tips-table tr:nth-child(even) td {
  background: #090909;
}

.tips-table tr:nth-child(even) td.match-col {
  background: #080808;
}

.col-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding-top: 0.25rem;
}

.col-header .name {
  font-size: 0.95rem;
  font-weight: 600;
}

.col-score {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
}

.match-cell {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.match-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.stage-badge {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mult-badge {
  background: rgba(201, 162, 39, 0.15);
  border: 1px solid rgba(201, 162, 39, 0.45);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.teams {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.team-line {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
}

.team-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: help;
  z-index: 1;
}

.team-info:hover,
.team-info:focus-within {
  z-index: 30;
}

.team-info:focus {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.rank-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(201, 162, 39, 0.12);
  border: 1px solid rgba(201, 162, 39, 0.35);
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
  line-height: 1.3;
}

.team-tooltip {
  display: none;
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 40;
  width: min(280px, 70vw);
  padding: 0.65rem 0.75rem;
  background: #151515;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  font-size: 0.78rem;
  line-height: 1.45;
  color: #ddd;
  text-align: left;
  pointer-events: none;
}

.team-tooltip strong {
  display: block;
  color: var(--accent);
  margin-bottom: 0.35rem;
  font-size: 0.72rem;
}

.team-tooltip p {
  margin: 0;
}

.team-info:hover .team-tooltip,
.team-info:focus .team-tooltip,
.team-info:focus-within .team-tooltip {
  display: block;
}

.flag {
  width: 22px;
  height: 16px;
  object-fit: cover;
  border-radius: 2px;
  background: #222;
}

.flag-sm {
  width: 18px;
  height: 13px;
}

.flag-btn {
  width: 20px;
  height: 14px;
  flex-shrink: 0;
}

.flag-placeholder.flag-btn {
  width: 20px;
  height: 14px;
}

.flag-placeholder {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  background: #333;
  display: inline-block;
}

.match-result {
  font-size: 0.82rem;
  color: var(--accent-2);
  font-weight: 600;
}

.pred-cell {
  min-width: 180px;
}

.pred-cell.locked {
  opacity: 0.55;
}

.pred-cell.editable {
  background: rgba(201, 162, 39, 0.04);
}

.pred-cell.auto .auto-badge {
  display: inline-block;
}

.auto-badge {
  display: none;
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.pick-hint {
  display: block;
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
  text-align: center;
}

.score-row-muted {
  opacity: 0.45;
}

.winner-btns {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.35rem;
}

.winner-team-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  padding: 0.35rem 0.45rem;
  font-size: 0.72rem;
  text-align: left;
  line-height: 1.2;
}

.winner-team-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner-team-btn.draw-btn {
  justify-content: center;
}

.winner-team-btn.active {
  background: rgba(62, 207, 142, 0.15);
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.winner-btns button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.score-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.score-value {
  min-width: 1rem;
  text-align: center;
  font-weight: 700;
  line-height: 1.2;
}

.score-sep {
  color: var(--muted);
  padding-bottom: 0.1rem;
}

.score-btn {
  width: 18px;
  height: 16px;
  padding: 0;
  font-size: 0.62rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.score-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pred-display {
  text-align: center;
  font-size: 0.85rem;
}

.pred-display .scoreline {
  font-weight: 700;
  margin-top: 0.15rem;
}

.pred-display .winner-label {
  color: var(--muted);
  font-size: 0.72rem;
}

.winner-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  justify-content: center;
}

.rules {
  margin: 0 1.5rem 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.rules p {
  margin: 0.35rem 0 0;
  color: #ccc;
  line-height: 1.5;
}

.rules h2 + h2 {
  margin-top: 1.25rem;
}

.rules ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
  color: #ccc;
}

.rules li + li {
  margin-top: 0.35rem;
}

.admin-page .header h1 {
  font-size: 1.25rem;
}

.admin-main {
  padding: 1rem 1.5rem 2rem;
}

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

.admin-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 1rem 0;
}

.admin-list {
  display: grid;
  gap: 0.5rem;
}

.admin-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-row.has-result {
  border-color: rgba(62, 207, 142, 0.35);
}

.admin-match-label {
  font-size: 0.9rem;
}

.admin-score-input {
  width: 56px;
  text-align: center;
}

#adminStatus {
  color: var(--muted);
  font-size: 0.875rem;
}

@media (max-width: 720px) {
  .header, .rules, .admin-main {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .auth-bar input {
    width: 100px;
  }

  .tips-table th.match-col,
  .tips-table td.match-col {
    min-width: 72px;
    max-width: 84px;
    width: 84px;
    padding: 0.35rem 0.3rem;
  }

  .tips-table th.match-col {
    font-size: 0.65rem;
    padding: 0.55rem 0.3rem;
  }

  .match-cell {
    gap: 0.25rem;
  }

  .match-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    font-size: 0.62rem;
    line-height: 1.25;
  }

  .stage-badge {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.55rem;
    padding: 0.05rem 0.3rem;
  }

  .mult-badge {
    font-size: 0.55rem;
    padding: 0.05rem 0.3rem;
  }

  .match-col .team-line {
    font-size: 0.68rem;
    gap: 0.2rem;
  }

  .match-col .team-info {
    min-width: 0;
    flex: 1;
    gap: 0.15rem;
  }

  .match-col .team-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 52px;
  }

  .match-col .rank-badge {
    display: none;
  }

  .match-col .flag {
    width: 16px;
    height: 12px;
    flex-shrink: 0;
  }

  .match-col .flag-placeholder {
    width: 16px;
    height: 12px;
  }

  .match-result {
    font-size: 0.62rem;
    line-height: 1.25;
  }
}
