:root {
  --bg-color: #f8f9fa;
  --card-bg: #ffffff;
  --text-main: #212529;
  --text-muted: #666666;
  --text-faint: #999999;
  --border: #eeeeee;
  --border-input: #cccccc;

  --accent-green: #2e7d32;
  --accent-green-dark: #1b5e20;
  --accent-green-light-bg: #e8f5e9;

  --danger: #d32f2f;
  --info-blue: #1976d2;
  --link-blue: #007bff;
  --neutral-btn: #666666;
  --admin-accent: #dc3545;
  --gray-status: #9e9e9e;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background: var(--bg-color);
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 20px;
}

.app-card {
  width: 100%;
  max-width: 560px;
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  position: relative;
}

@media (max-width: 640px) {
  .page { padding: 0; }
  .app-card { border-radius: 0; min-height: 100vh; box-shadow: none; }
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.logo-mark {
  height: 24px;
  width: 24px;
  object-fit: contain;
  vertical-align: middle;
}

.logo-mark.large {
  height: 76px;
  width: 76px;
}

.menu-wrap { position: relative; }

.menu-button {
  background: transparent;
  border: 0;
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.menu {
  position: absolute;
  right: 0;
  top: 34px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  padding: 6px;
  min-width: 180px;
  z-index: 10;
}

.menu[hidden] { display: none; }

.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-main);
}

.menu button:hover { background: var(--bg-color); }
.menu .menu-divider { border-top: 1px solid var(--border); margin: 4px 0; }
.menu .menu-label { padding: 6px 12px; font-size: 11px; text-transform: uppercase; color: var(--text-faint); }

h1 { text-align: center; color: var(--accent-green); font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3, h4 { color: #333; margin-top: 0; }

.meta-label { font-size: 11px; text-transform: uppercase; color: var(--text-muted); }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.section-divider {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-input);
  border-radius: 6px;
  font-size: 16px;
  margin: 6px 0;
  font-family: inherit;
}

input[type="checkbox"], input[type="radio"] {
  width: auto;
  padding: 0;
  margin: 0 6px 0 0;
  border: 0;
  vertical-align: middle;
}

input.no-spinner::-webkit-inner-spin-button,
input.no-spinner::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input.no-spinner {
  -moz-appearance: textfield;
}

label { font-size: 13px; color: var(--text-muted); }

label.checkbox-label {
  display: flex;
  align-items: center;
  margin: 10px 0;
}

.button {
  width: 100%;
  padding: 12px;
  border-radius: 6px;
  background: var(--accent-green);
  color: #fff;
  border: 0;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.button:hover { opacity: 0.9; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button.secondary { background: var(--info-blue); }
.button.danger { background: var(--danger); }
.button.ghost { background: transparent; color: var(--neutral-btn); border: 1px solid var(--border-input); }
.button.inline { width: auto; padding: 8px 14px; font-size: 13px; }

.link-button {
  background: none;
  border: 0;
  color: var(--link-blue);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
}

.pill.OPEN { background: var(--accent-green); }
.pill.LOCKED { background: var(--danger); }
.pill.SETTLED { background: var(--gray-status); }
.pill.active { background: var(--accent-green); }
.pill.finished { background: var(--gray-status); }
.pill.WON { background: var(--accent-green); }
.pill.LOST { background: var(--gray-status); }
.pill.PENDING { background: var(--info-blue); }

.pill-toggle { border: 0; cursor: pointer; background: #eee; color: var(--text-muted); }
.pill-toggle.active { background: var(--accent-green); color: #fff; }
.pill-toggle.read-only { cursor: default; }

.tabs { display: flex; width: 100%; border-radius: 10px; overflow: hidden; }

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 4px 6px;
  cursor: pointer;
  color: #fff;
}
.tab:last-child { border-right: 0; }

.tab-label { font-size: 13px; font-weight: 700; }
.tab-status { font-size: 10px; opacity: 0.85; }

/* Color reflects the event's real status (matches the status pills) so which round is open is
   visible at a glance without clicking into each tab; the status word underneath spells out what
   the color means for every tab, not just the selected one. */

/* The selection indicator lives in its own row below the tab bar, not as a border on the tab
   itself - a border there sits flush against .tabs's rounded-corner overflow:hidden clip and
   is nearly invisible against a saturated status-color fill. */
.tabs-indicator { display: flex; width: 100%; margin: 6px 0 16px; }
.tabs-indicator-cell { flex: 1; display: flex; justify-content: center; }
.tabs-indicator-bar { width: 60%; height: 4px; border-radius: 2px; background: transparent; }
.tabs-indicator-cell.active .tabs-indicator-bar { background: var(--text-main); }
.tab.OPEN { background: var(--accent-green); }
.tab.LOCKED { background: var(--danger); }
.tab.SETTLED { background: var(--gray-status); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }

/* My Bets groups its rows under a round heading. Sharing the plain `th` style made the heading
   read as just another column label, so it needs to clearly out-rank them: full-size text in the
   main colour, a rule above it to break the run of rows, and the round's status as a pill. */
.bet-group th {
  font-size: 15px;
  font-weight: 700;
  text-transform: none;
  color: var(--text-main);
  background: var(--bg-color);
  padding: 16px 8px 10px;
  border-top: 2px solid var(--border);
  border-bottom: 1px solid var(--border-input);
}
.bet-group:first-child th { border-top: 0; padding-top: 10px; }
.bet-group .pill { margin-left: 8px; vertical-align: 2px; }

.tip-wrap {
  position: relative;
  cursor: pointer;
  border-bottom: 1px dotted currentColor;
  outline: none;
}

.tip-bubble {
  position: absolute;
  top: 125%;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  max-width: 60vw;
  background: var(--text-main);
  color: #fff;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  white-space: normal;
  text-align: center;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  pointer-events: none;
  z-index: 30;
}

.tip-bubble::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--text-main);
}

.tip-wrap:hover .tip-bubble,
.tip-wrap:focus .tip-bubble,
.tip-wrap.show-tip .tip-bubble {
  opacity: 1;
  visibility: visible;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

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

.error { color: var(--danger); font-size: 13px; text-align: center; margin: 8px 0; }
.success { color: var(--accent-green); font-size: 13px; text-align: center; margin: 8px 0; }
.info { color: var(--text-muted); font-size: 13px; text-align: center; margin: 8px 0; }

.confirm-box {
  background: var(--accent-green-light-bg);
  border-radius: 10px;
  padding: 14px;
  margin: 10px 0;
}

.confirm-box h4 { color: var(--accent-green-dark); margin: 0 0 6px; }

details { margin-top: 10px; }
summary { font-weight: 700; cursor: pointer; padding: 8px 0; border-top: 1px solid var(--border); }
summary::-webkit-details-marker { display: none; }
summary::after { content: '▼'; float: right; font-size: 11px; }
details[open] summary::after { content: '▲'; }

/* A roster row IS its own <details> - the whole row (name, badge, chevron) lives inside <summary>,
   so clicking anywhere across it opens/closes the row, not just a small trigger. The open state is
   shown with a background tint framing the row, not indentation - the body sits flush left instead
   of being pushed in, so it doesn't waste horizontal space on mobile. */
.roster-row { margin-top: 0; border-bottom: 1px solid var(--border); }
.roster-row:last-child { border-bottom: none; }
.roster-row summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 0;
  padding: 10px 8px;
  cursor: pointer;
}
.roster-row summary::after { content: '▾'; float: none; font-size: 20px; line-height: 1; color: var(--text-muted); margin-left: 8px; }
.roster-row[open] summary::after { content: '▴'; }
/* Tint only the body, not <summary> - if two consecutive rows are both open, a tinted summary
   would blend into the row above/below it with no visible seam between two different people. */
.roster-row-body {
  padding: 10px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  background: var(--bg-color);
  border-radius: 8px;
}

.form-toggle { text-align: center; margin-top: 10px; font-size: 13px; }

.markdown h2, .markdown h3 { margin-top: 20px; }
.markdown h2:first-child, .markdown h3:first-child { margin-top: 0; }
.markdown p, .markdown ul, .markdown ol { font-size: 14px; line-height: 1.5; margin: 0 0 10px; }
.markdown ul, .markdown ol { padding-left: 20px; }
.markdown li { margin-bottom: 4px; }
.markdown li > ul, .markdown li > ol { margin-top: 4px; }
.markdown code { background: var(--accent-green-light-bg); color: var(--accent-green-dark); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.markdown a { color: var(--link-blue); }
