:root {
  --green: #2d5016;
  --green-light: #4a7c28;
  --cream: #f5f5dc;
  --ink: #1a1a1a;
  --card-bg: #ffffff;
  --border: #ddd;
  --muted: #666;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 0 2rem;
  color: var(--ink);
  background: var(--cream);
}

header {
  background: var(--green);
  padding: 1rem 1.25rem;
  border-bottom: 3px solid var(--green-light);
}
header h1 { font-size: 1.25rem; margin: 0; }
header h1 a { color: #fff; text-decoration: none; }

main { padding: 1rem 1.25rem; }

h2 { color: var(--green); font-size: 1.1rem; margin: 1.25rem 0 0.75rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.session-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}
.session-tab {
  flex: 0 0 auto;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.session-tab.active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.card h2 { margin-top: 0; }

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0.75rem 0 0.3rem;
}

input, select, button {
  font-size: 1rem;
  font-family: inherit;
}

input[type="text"], input[type="email"], input[type="number"], select {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.segmented-option {
  flex: 1;
  text-align: center;
  padding: 0.6rem 0.4rem;
  cursor: pointer;
  background: #fff;
  border-right: 1px solid var(--border);
  font-size: 0.9rem;
  position: relative;
}
.segmented-option:last-child { border-right: none; }
.segmented-option input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-option:has(input:checked) {
  background: var(--green);
  color: #fff;
  font-weight: 600;
}

.new-bet select#matchId { margin-top: 0.4rem; }

.primary-button, .secondary-button {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
}
.primary-button {
  background: var(--green);
  color: #fff;
  width: 100%;
  margin-top: 1rem;
  padding: 0.75rem;
}
.primary-button:disabled { background: #aaa; cursor: not-allowed; }
.secondary-button {
  background: var(--green-light);
  color: #fff;
}
.link-button {
  background: none;
  border: none;
  color: var(--green-light);
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}

.empty-note {
  color: var(--muted);
  font-size: 0.9rem;
  font-style: italic;
}

.bet-list { display: flex; flex-direction: column; gap: 0.75rem; }
.bet-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 4px solid var(--border);
}
.bet-card.status-open { border-left-color: var(--green-light); }
.bet-card.status-accepted { border-left-color: #b5791f; }
.bet-card.status-settled { border-left-color: var(--green); }
.bet-card.status-cancelled { border-left-color: #999; opacity: 0.6; }

.bet-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.bet-amount { font-size: 1.15rem; font-weight: 700; color: var(--green); }
.bet-status {
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.bet-description { margin: 0.2rem 0; font-size: 0.95rem; }
.bet-meta { margin: 0.2rem 0; font-size: 0.85rem; color: var(--muted); }
.bet-result { margin: 0.3rem 0; font-size: 0.85rem; font-weight: 600; color: var(--green); }

.bet-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.bet-actions form { margin: 0; display: flex; gap: 0.4rem; align-items: center; }
.bet-actions select { width: auto; }

@media (prefers-color-scheme: dark) {
  :root {
    --cream: #111;
    --card-bg: #1c1c1c;
    --border: #333;
    --ink: #eee;
    --muted: #aaa;
  }
  input[type="text"], input[type="email"], input[type="number"], select, .segmented-option {
    background: #1c1c1c;
    color: #eee;
  }
}
