:root {
  color-scheme: dark;
  --bg-top: #16314b;
  --bg-bottom: #07131f;
  --panel: rgba(6, 22, 36, 0.8);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  --text-main: #f5f7fb;
  --text-muted: #9db3ca;
  --accent: #ffb84d;
  --accent-strong: #ff8f1f;
  --teal: #79e7d3;
  --green: #8dd18f;
  --red: #ff9588;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --font-display: "Avenir Next Condensed", "Trebuchet MS", "Segoe UI",
    sans-serif;
  --font-body: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(255, 184, 77, 0.22), transparent 24rem),
    radial-gradient(circle at 82% 18%, rgba(121, 231, 211, 0.2), transparent 22rem),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text-main);
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.03), transparent 42%),
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.06), transparent 18%);
  pointer-events: none;
}

.app-shell {
  position: relative;
  width: min(1100px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 20px 0 136px;
}

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

.app-tab-bar {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(760px, calc(100vw - 18px));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 18, 29, 0.92);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(24px);
  z-index: 18;
}

.app-tab-button {
  min-height: 56px;
  display: grid;
  place-items: center;
  padding: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.app-tab-button.active {
  color: #09121b;
  font-weight: 800;
  background: linear-gradient(135deg, var(--teal), #b9fff1);
  border-color: rgba(121, 231, 211, 0.5);
}

.app-tab-label {
  font-size: 0.95rem;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    var(--panel);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(22px);
}

.panel::after {
  content: "";
  position: absolute;
  inset: auto -30% -65% auto;
  width: 14rem;
  height: 14rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 184, 77, 0.18), transparent 70%);
  pointer-events: none;
}

.hero {
  display: grid;
  gap: 18px;
  margin-bottom: 16px;
}

.hero-copy h1,
.section-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

.hero-copy h1 {
  font-size: clamp(2.3rem, 5vw, 4rem);
  line-height: 0.92;
  max-width: 12ch;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--teal);
}

.lede,
.helper-text,
.empty-state p,
.settlement-subtitle,
.history-meta,
.player-meta,
.metric-card span {
  color: var(--text-muted);
}

.lede {
  margin: 14px 0 0;
  max-width: 42rem;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 14px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.metric-card span {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.metric-card strong {
  font-size: clamp(1.1rem, 3vw, 1.45rem);
}

.sync-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid rgba(121, 231, 211, 0.16);
  background:
    radial-gradient(circle at top right, rgba(121, 231, 211, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.04);
}

.sync-panel[data-state="signed-in"] {
  border-color: rgba(141, 209, 143, 0.24);
}

.sync-panel[data-state="needs-choice"] {
  border-color: rgba(255, 184, 77, 0.34);
  background:
    radial-gradient(circle at top right, rgba(255, 184, 77, 0.18), transparent 44%),
    rgba(255, 255, 255, 0.04);
}

.sync-copy {
  display: grid;
  gap: 6px;
}

.sync-copy strong {
  font-size: 1.02rem;
}

.sync-copy .helper-text {
  margin: 0;
}

.sync-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.tab-intro {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.tab-intro-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4.5vw, 2.7rem);
  line-height: 0.96;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.two-up {
  display: grid;
  gap: 12px;
}

.rules-grid,
.matchup-list {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  appearance: none;
  width: 100%;
  padding: 14px 15px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(4, 16, 26, 0.76);
  color: var(--text-main);
  transition: border-color 140ms ease, transform 140ms ease,
    box-shadow 140ms ease;
}

input::placeholder {
  color: #87a0b8;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(121, 231, 211, 0.72);
  box-shadow: 0 0 0 4px rgba(121, 231, 211, 0.14);
}

button {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary {
  color: #09121b;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.secondary {
  color: #07131f;
  font-weight: 700;
  background: linear-gradient(135deg, var(--teal), #9af5ff);
}

.ghost,
.text-button {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.text-button {
  padding: 10px 12px;
}

.hidden {
  display: none !important;
}

.player-list,
.leaderboard,
.history-list,
.settlements {
  display: grid;
  gap: 12px;
}

.rules-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 12px;
}

.rule-card {
  display: grid;
  gap: 8px;
  min-height: 144px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.68);
}

.rule-card p {
  margin: 0;
  line-height: 1.45;
  color: var(--text-muted);
}

.inline-link {
  color: #ffe2af;
}

.player-list {
  margin-top: 16px;
}

.player-card,
.leader-card,
.history-item,
.settlement-card {
  border-radius: 20px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.68);
}

.player-card,
.leader-card,
.history-item {
  display: grid;
  gap: 10px;
}

.player-topline,
.leader-topline,
.history-topline,
.settlement-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #08111b;
  background: linear-gradient(
    135deg,
    hsl(var(--player-hue) 82% 70%),
    hsl(calc(var(--player-hue) + 22) 85% 62%)
  );
}

.player-meta strong,
.leader-meta strong,
.history-main strong,
.settlement-main strong {
  display: block;
  font-size: 1rem;
}

.player-meta span,
.leader-meta span {
  font-size: 0.88rem;
}

.player-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
}

.seat-order-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.seat-order-button {
  padding: 10px 12px;
}

.net-tag,
.entry-badge,
.history-timestamp {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.net-positive {
  background: rgba(141, 209, 143, 0.14);
  color: #bcf2be;
}

.net-negative {
  background: rgba(255, 149, 136, 0.14);
  color: #ffc4bc;
}

.net-flat {
  background: rgba(255, 255, 255, 0.08);
  color: #dce8f4;
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
}

.toggle-pill {
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-main);
  text-align: left;
}

.toggle-pill.active {
  border-color: rgba(255, 184, 77, 0.35);
  background: linear-gradient(
    135deg,
    rgba(255, 184, 77, 0.18),
    rgba(255, 143, 31, 0.12)
  );
}

.toggle-pill[aria-disabled="true"] {
  opacity: 0.3;
  cursor: not-allowed;
}

.round-panel {
  display: grid;
  gap: 14px;
}

.cashout-panel {
  display: grid;
  gap: 14px;
}

.cashout-topline {
  align-items: stretch;
}

.cashout-helper,
.cashout-plan-item,
.cashout-summary-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.68);
}

.cashout-helper p,
.cashout-summary-card p,
.cashout-plan-item p {
  margin: 0;
  line-height: 1.45;
  color: var(--text-muted);
}

.cashout-preview,
.cashout-plan-list {
  display: grid;
  gap: 10px;
}

.cashout-summary-card strong,
.cashout-plan-item strong {
  font-size: 1rem;
}

.cashout-summary-headline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cashout-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.warning-card {
  border-color: rgba(255, 184, 77, 0.22);
  background:
    radial-gradient(circle at top right, rgba(255, 184, 77, 0.14), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.68);
}

.wager-toolbar {
  display: grid;
  gap: 12px;
  align-items: end;
}

.wager-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.wager-chip {
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--text-main);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.wager-chip.active {
  color: #09121b;
  background: linear-gradient(135deg, var(--accent), #ffd27d);
  border-color: rgba(255, 184, 77, 0.54);
}

.wager-chip.reset-chip {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border-style: dashed;
}

.compact-field span {
  font-size: 0.86rem;
}

.quick-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.roller-picker {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.roller-chip {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  color: var(--text-main);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.roller-chip .avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.roller-chip-name {
  font-weight: 700;
}

.roller-chip.active {
  color: #09121b;
  background:
    linear-gradient(
      135deg,
      hsl(var(--player-hue) 82% 78% / 1),
      hsl(calc(var(--player-hue) + 24) 86% 72% / 1)
    );
  border-color: hsl(var(--player-hue) 72% 68% / 0.95);
}

.matchup-list {
  margin-top: 4px;
}

.matchup-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(circle at top right, rgba(121, 231, 211, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.7);
}

.matchup-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.matchup-wager {
  width: min(360px, 48%);
  display: grid;
  gap: 10px;
}

.matchup-header .field {
  width: min(150px, 42%);
}

.matchup-wager .field {
  width: 100%;
}

.matchup-header input {
  padding-block: 12px;
}

.outcome-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
}

.outcome-chip {
  min-height: 52px;
  padding: 12px 14px;
  text-align: center;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.outcome-chip[data-tone="roller"] {
  border-color: rgba(141, 209, 143, 0.18);
}

.outcome-chip[data-tone="player"] {
  border-color: rgba(255, 149, 136, 0.18);
}

.outcome-chip.active[data-tone="roller"] {
  background: linear-gradient(
    135deg,
    rgba(141, 209, 143, 0.22),
    rgba(121, 231, 211, 0.14)
  );
  border-color: rgba(141, 209, 143, 0.42);
}

.outcome-chip.active[data-tone="player"] {
  background: linear-gradient(
    135deg,
    rgba(255, 149, 136, 0.2),
    rgba(255, 115, 115, 0.12)
  );
  border-color: rgba(255, 149, 136, 0.42);
}

.outcome-chip.active[data-tone="push"] {
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.12),
    rgba(255, 255, 255, 0.06)
  );
  border-color: rgba(255, 255, 255, 0.2);
}

.matchup-summary {
  margin: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  line-height: 1.45;
  color: var(--text-muted);
}

.matchup-summary.summary-roller {
  color: #c8ffd0;
  background: rgba(141, 209, 143, 0.1);
}

.matchup-summary.summary-player {
  color: #ffd0c9;
  background: rgba(255, 149, 136, 0.1);
}

.leaderboard {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.leader-card {
  min-height: 145px;
}

.leader-card[data-rank="1"] {
  background:
    radial-gradient(circle at top right, rgba(255, 184, 77, 0.28), transparent 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.03)),
    rgba(5, 19, 31, 0.68);
}

.leader-value {
  font-size: 1.8rem;
  font-weight: 800;
}

.leader-breakdown {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
  color: var(--text-muted);
}

.settlements {
  gap: 10px;
}

.settlement-card {
  display: grid;
  gap: 8px;
}

.settlement-main strong {
  font-size: 1.02rem;
}

.settlement-subtitle {
  margin: 0;
  line-height: 1.45;
}

.history-list {
  gap: 10px;
}

.history-item {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.history-main {
  display: grid;
  gap: 8px;
}

.history-main p,
.empty-state p {
  margin: 0;
  line-height: 1.45;
}

.history-detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.outcome-pill {
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.06);
}

.outcome-pill.roller-win {
  background: rgba(141, 209, 143, 0.14);
  color: #bcf2be;
}

.outcome-pill.player-win {
  background: rgba(255, 149, 136, 0.14);
  color: #ffc4bc;
}

.outcome-pill.push {
  background: rgba(255, 255, 255, 0.08);
  color: #dce8f4;
}

.outcome-pill.cashout-in {
  background: rgba(141, 209, 143, 0.14);
  color: #bcf2be;
}

.outcome-pill.cashout-out {
  background: rgba(255, 149, 136, 0.14);
  color: #ffc4bc;
}

.history-right {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.history-timestamp {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

.entry-badge.round {
  background: rgba(255, 184, 77, 0.14);
  color: #ffd49a;
}

.entry-badge.transfer {
  background: rgba(121, 231, 211, 0.14);
  color: #c8fff6;
}

.entry-badge.cashout {
  background: rgba(255, 255, 255, 0.1);
  color: #eef4fb;
}

.history-delete {
  padding: 10px 12px;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
}

.flash {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(8, 18, 29, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.28);
  z-index: 20;
}

@media (min-width: 860px) {
  .layout {
    grid-template-columns: 1.1fr 0.95fr;
    align-items: start;
  }

  .round-panel,
  .cashout-panel,
  .history-panel,
  .hero {
    grid-column: 1 / -1;
  }

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

  .wager-toolbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 1100px);
    padding-top: 12px;
  }

  .app-tab-bar {
    width: calc(100vw - 12px);
    gap: 6px;
    padding: 8px;
    border-radius: 22px;
  }

  .app-tab-button {
    min-height: 52px;
    padding-inline: 8px;
  }

  .app-tab-label {
    font-size: 0.86rem;
  }

  .panel {
    padding: 16px;
    border-radius: 22px;
  }

  .hero-copy h1 {
    max-width: 10ch;
  }

  .hero-metrics {
    grid-template-columns: 1fr;
  }

  .sync-actions button {
    flex: 1 1 100%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-right {
    justify-items: start;
  }

  .matchup-header {
    flex-direction: column;
  }

  .matchup-wager {
    width: 100%;
  }

  .matchup-header .field {
    width: 100%;
  }
}
