:root {
  --bg: #0f172a;
  --card: #111827;
  --muted: #94a3b8;
  --text: #e5e7eb;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --border: #1f2937;
}
* { box-sizing: border-box; }
html {
  overflow-x: hidden;
}
body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #020617, #0f172a);
  color: var(--text);
  overflow-x: hidden;
}
.topbar {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.98);
  position: sticky;
  top: 0;
  z-index: 200;
  /* Stay above rule rows: chevron ::before uses transform, which creates a stacking context. */
}
.topbar h1 { margin: 0; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.tabs {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  align-items: stretch;
  min-width: 0;
}
.tab {
  color: var(--text);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #111827;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
  min-width: 0;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
}
.tab-text--short { display: none; }
.tab.active { background: var(--accent); color: #082f49; font-weight: 700; }
@media (max-width: 900px) {
  .topbar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .tabs {
    gap: 6px;
    margin-top: 14px;
  }
  .tab {
    flex: 1 1 0;
    padding: 8px 6px;
    font-size: 0.78rem;
  }
  .tab-text--long { display: none; }
  .tab-text--short { display: inline; }
}
.container { max-width: 1200px; margin: 0 auto; padding: 24px; width: 100%; min-width: 0; }
.card {
  background: rgba(17, 24, 39, 0.96); border: 1px solid var(--border);
  border-radius: 18px; padding: 20px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.grid.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  min-width: 0;
}
.scoreboard-page > .card {
  min-width: 0;
  max-width: 100%;
}
.prose ul { line-height: 1.8; }
.rules-intro { margin: 0 0 20px; padding-left: 1.25rem; }
.cashout-heading { margin-top: 28px; margin-bottom: 12px; color: var(--accent); font-size: 1.1rem; }
.cashout-heading:first-of-type { margin-top: 8px; }
.game-rule-list { display: flex; flex-direction: column; gap: 10px; }
.game-rule {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(11, 18, 32, 0.85);
  overflow: hidden;
}
.game-rule__summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  color: var(--text);
}
.game-rule__summary::-webkit-details-marker { display: none; }
.game-rule__summary::marker { content: ''; }
.game-rule__summary::before {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 0.5em;
  margin-right: 4px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
  position: relative;
  top: 2px;
}
.game-rule[open] .game-rule__summary::before {
  transform: rotate(45deg);
  top: 0;
}
.game-rule__name {
  font-weight: 800;
  color: var(--accent);
}
.game-rule__meta {
  color: var(--muted);
  font-weight: 500;
  flex: 1 1 200px;
}
.game-rule__body {
  margin: 0;
  padding: 0 16px 16px 44px;
  color: var(--text);
  line-height: 1.65;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.rules-page > .game-rule { margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); }
.entry-log-list {
  margin-top: 8px;
  max-width: 100%;
  min-width: 0;
}
.entry-log-head {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 0.5rem;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.entry-log-head-desktop {
  display: none;
}
.entry-swipe-row {
  border-bottom: 1px solid var(--border);
}
.entry-swipe-row:last-child {
  border-bottom: none;
}
.entry-swipe-track {
  position: relative;
  overflow: hidden;
  min-height: 52px;
  background: rgba(11, 18, 32, 0.5);
}
.entry-swipe-actions {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 72px;
  z-index: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
.entry-swipe-delete {
  appearance: none;
  border: none;
  margin: 0;
  width: 100%;
  padding: 0 12px;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.entry-swipe-delete:active {
  filter: brightness(0.92);
}
.entry-swipe-slide {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 52px;
  background: rgba(17, 24, 39, 0.98);
  touch-action: pan-y;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.entry-swipe-slide:active {
  cursor: grabbing;
}
.entry-swipe-cells {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 0.5rem;
  align-items: start;
  padding: 10px 6px;
  font-size: 0.9rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.entry-cell {
  min-width: 0;
}
.entry-cell-desktop {
  display: none;
}
.entry-delete-inline {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  width: 100%;
  max-width: 4.5rem;
}
.entry-delete-inline:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.5);
}
@media (min-width: 768px) {
  .entry-log-head {
    grid-template-columns: 2.5rem minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.35fr) 4.5rem;
  }
  .entry-log-head-desktop {
    display: block;
  }
  .entry-swipe-cells {
    grid-template-columns: 2.5rem minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1.35fr) 4.5rem;
  }
  .entry-cell-desktop {
    display: block;
  }
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
label { display: flex; flex-direction: column; gap: 8px; font-weight: 600; }
input, select, button {
  font: inherit; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
}
input, select { background: #0b1220; color: var(--text); }
button { background: var(--accent); color: #082f49; font-weight: 800; cursor: pointer; }
button.danger { background: var(--danger); color: white; margin-top: 16px; }
button.btn-compact { font-size: 0.8rem; padding: 6px 10px; margin-top: 0; font-weight: 700; }
.scoreboard-reset {
  margin-top: 20px;
}
.scoreboard-reset .danger {
  margin-top: 0;
}
.flash { margin-bottom: 16px; padding: 12px 14px; border-radius: 12px; }
.flash.success { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.35); }
.flash.error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.35); }
.full-width { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-start; }
.scoreboard-bars {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 8px;
  min-width: 0;
  width: 100%;
  max-width: 100%;
}
.scoreboard-row {
  min-width: 0;
  max-width: 100%;
}
.scoreboard-row__meta {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  min-width: 0;
}
.scoreboard-row__rank {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 2rem;
}
.scoreboard-row__team {
  font-weight: 800;
  flex: 1 1 auto;
  min-width: 0;
}
.scoreboard-row__total {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent-2);
}
.scorebar {
  height: 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}
.scorebar__fill {
  height: 100%;
  border-radius: inherit;
  min-width: 0;
  transition: width 0.35s ease;
  background: linear-gradient(90deg, var(--bar-a, #38bdf8), var(--bar-b, #0ea5e9));
}
.scoreboard-row--finalist .scorebar {
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}
.scoreboard-row--1 { --bar-a: #38bdf8; --bar-b: #0284c7; }
.scoreboard-row--2 { --bar-a: #4ade80; --bar-b: #16a34a; }
.scoreboard-row--3 { --bar-a: #fbbf24; --bar-b: #d97706; }
.scoreboard-row--4 { --bar-a: #c084fc; --bar-b: #9333ea; }
@media (max-width: 900px) {
  .grid.two-col, .form-grid { grid-template-columns: minmax(0, 1fr); }
}
