/* =========================================================
   Pitt Score — Design System
   Theme: "Twilight Course"
   ========================================================= */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #07100d;
  --bg-2: #0a1612;
  --panel: #101a16;
  --panel-2: #16221d;
  --panel-3: #1c2a24;
  --surface-hover: #1f2e27;

  /* Lines */
  --line: #233029;
  --line-strong: #344940;
  --line-soft: rgba(232, 244, 238, 0.06);
  --line-bright: rgba(232, 244, 238, 0.10);

  /* Text */
  --text: #ecf3ef;
  --text-dim: #c8d3cd;
  --muted: #8a9a92;
  --faint: #5d6c64;

  /* Accent — Jade */
  --accent: #3ed598;
  --accent-2: #1faf73;
  --accent-3: #157a52;
  --accent-glow: rgba(62, 213, 152, 0.34);
  --accent-soft: rgba(62, 213, 152, 0.12);
  --accent-line: rgba(62, 213, 152, 0.42);

  /* Amber — secondary */
  --gold: #e5b95a;
  --gold-2: #c89834;
  --gold-soft: rgba(229, 185, 90, 0.12);
  --gold-line: rgba(229, 185, 90, 0.40);

  /* Semantic */
  --pos: #4ade80;
  --neg: #f87171;
  --info: #7ec0ee;
  --warn: #fbbf24;

  /* Score colors */
  --score-eagle: #f0b54a;
  --score-birdie: #ef6b5a;
  --score-par: #8a9a92;
  --score-bogey: #6ba0e8;
  --score-double: #4d80c7;

  /* Effects */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, 0.34);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.46);
  --ring: 0 0 0 4px rgba(62, 213, 152, 0.18);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Type */
  --font-display: "Inter Tight", "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, monospace;

  font-family: var(--font-body);
  font-feature-settings: "ss01", "cv11";
}

* { box-sizing: border-box; }
*::selection { background: var(--accent-soft); color: var(--text); }

html, body { overflow-x: hidden; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 1200px 600px at 12% -10%, rgba(62, 213, 152, 0.10), transparent 60%),
    radial-gradient(ellipse 900px 500px at 92% 8%, rgba(229, 185, 90, 0.06), transparent 60%),
    radial-gradient(ellipse 700px 800px at 50% 110%, rgba(31, 175, 115, 0.06), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
button:disabled { cursor: not-allowed; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

a { color: var(--accent); text-decoration: none; }

/* =========================================================
   Layout
   ========================================================= */

.app-shell {
  min-height: 100svh;
  padding: 28px 24px 32px;
  position: relative;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(232, 244, 238, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 244, 238, 0.016) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 0%, transparent 70%);
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
}

/* =========================================================
   Topbar / Brand
   ========================================================= */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.28), transparent 55%),
    linear-gradient(155deg, var(--accent), var(--accent-3));
  color: #06140e;
  box-shadow:
    0 12px 28px rgba(20, 110, 70, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -8px 16px rgba(0, 0, 0, 0.18);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent 40%);
  -webkit-mask: linear-gradient(#fff, #fff) content-box, linear-gradient(#fff, #fff);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  padding: 1px;
  opacity: 0.5;
  pointer-events: none;
}

.brand-mark svg { width: 22px; height: 22px; display: block; }

.brand-text { min-width: 0; }

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.2vw, 2.4rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #ffffff 0%, #c4d4cd 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  max-width: 36rem;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* =========================================================
   Buttons
   ========================================================= */

.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01)),
    var(--panel);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease, color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--panel-2);
  box-shadow: var(--shadow-sm);
}

.button:active { transform: translateY(0); }

.button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-color: var(--accent);
}

.button.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #06140e;
  font-weight: 700;
  box-shadow:
    0 10px 26px rgba(20, 110, 70, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.button.primary:hover {
  filter: brightness(1.06);
  box-shadow:
    0 14px 30px rgba(20, 110, 70, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}

.button.ghost:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.025); }

.button.danger {
  border-color: rgba(248, 113, 113, 0.34);
  background: rgba(248, 113, 113, 0.06);
  color: #fcb6b0;
}

.button.danger:hover { border-color: rgba(248, 113, 113, 0.6); background: rgba(248, 113, 113, 0.1); color: #ffd1cc; }

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.85rem;
  border-radius: var(--r-xs);
}

.button.tiny {
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.78rem;
  border-radius: var(--r-xs);
  font-weight: 600;
}

.button:disabled {
  opacity: 0.4;
  filter: saturate(0.6);
  box-shadow: none;
  transform: none;
}

.button svg { width: 16px; height: 16px; flex: none; }

/* =========================================================
   Tabs
   ========================================================= */

.tabs {
  display: flex;
  gap: 4px;
  padding: 5px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.008)), var(--panel);
  overflow-x: auto;
  scrollbar-width: none;
  box-shadow: var(--shadow-sm);
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
  transition: color 140ms ease, background 140ms ease;
}

.tab svg { width: 16px; height: 16px; opacity: 0.85; flex: none; }

.tab:hover { color: var(--text-dim); background: rgba(255, 255, 255, 0.03); }

.tab.active {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(62, 213, 152, 0.16), rgba(62, 213, 152, 0.06)),
    rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px var(--accent-line), 0 6px 18px rgba(20, 110, 70, 0.22);
}

.tab.active svg { color: var(--accent); opacity: 1; }

/* =========================================================
   Grid
   ========================================================= */

.grid { display: grid; gap: 16px; min-width: 0; }
.grid.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.tight { gap: 10px; }

/* =========================================================
   Cards
   ========================================================= */

.card {
  position: relative;
  min-width: 0;
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008)),
    var(--panel);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    var(--shadow-md);
  overflow: hidden;
  isolation: isolate;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02) 40%, rgba(0, 0, 0, 0.2));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
  z-index: 0;
}

.card > * { position: relative; z-index: 1; }

.card-header {
  padding: 20px 20px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}

.card-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.card-body { padding: 18px 20px 20px; }

/* =========================================================
   Pills
   ========================================================= */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.pill.accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #a8ecca;
}

.pill.green {
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.10);
  color: #a8f0c0;
}

.pill.gold {
  border-color: var(--gold-line);
  background: var(--gold-soft);
  color: #f3d791;
}

.pill.danger {
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.08);
  color: #fcb8b0;
}

.pill svg { width: 12px; height: 12px; }

/* =========================================================
   Section label
   ========================================================= */

.section-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* =========================================================
   Fields, inputs, switches
   ========================================================= */

.field { display: grid; gap: 6px; min-width: 0; }

.field label,
.field > span:first-child {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.input, .select {
  width: 100%;
  min-height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.06)),
    var(--panel-2);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.select {
  appearance: none;
  background-image:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.06)),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1.5L6 6.5L11 1.5' stroke='%238a9a92' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat, no-repeat;
  background-position: 0 0, right 12px center;
  background-size: auto, 11px 7px;
  padding-right: 32px;
}

.input::placeholder { color: var(--faint); }

.input:hover, .select:hover { border-color: var(--line-strong); }

.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.checkbox-row > span { color: var(--text-dim); font-size: 0.88rem; }

.switch {
  flex: none;
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: var(--r-pill);
  padding: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: background 160ms ease, border-color 160ms ease;
}

.switch span {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  background: var(--muted);
  transition: transform 180ms cubic-bezier(0.4, 0.0, 0.2, 1), background 160ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch:hover { border-color: var(--line-strong); }

.switch.on {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: var(--accent-2);
  box-shadow: 0 0 0 1px rgba(62, 213, 152, 0.2), 0 4px 14px rgba(31, 175, 115, 0.4);
}

.switch.on span {
  transform: translateX(18px);
  background: #06140e;
}

/* =========================================================
   Players & teams
   ========================================================= */

.player-row {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) 5.5rem auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.005)),
    rgba(0, 0, 0, 0.15);
  transition: border-color 140ms ease, background 140ms ease;
}

.player-row:hover { border-color: var(--line-strong); }

.player-row .player-tag {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--r-pill);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
}

.team-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    rgba(0, 0, 0, 0.18);
}

.team-box.alt { background: rgba(255, 255, 255, 0.015); }

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

.chip-button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.005)),
    var(--panel);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: left;
  transition: all 140ms ease;
}

.chip-button:hover {
  border-color: var(--line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    var(--panel-2);
  color: var(--text);
}

.chip-button.selected {
  border-color: var(--accent-line);
  background:
    linear-gradient(180deg, rgba(62, 213, 152, 0.18), rgba(62, 213, 152, 0.06)),
    var(--panel);
  color: #c4f0d8;
  box-shadow: inset 0 0 0 1px rgba(62, 213, 152, 0.18);
}

/* =========================================================
   Tables / scorecard
   ========================================================= */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.2);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.table-wrap::-webkit-scrollbar { height: 8px; width: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line-soft);
  text-align: center;
  white-space: nowrap;
  font-size: 0.9rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--panel-2);
  border-bottom-color: var(--line);
}

tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }

td:first-child,
th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel);
  padding-left: 14px;
  font-weight: 600;
  color: var(--text-dim);
}

th:first-child { z-index: 3; background: var(--panel-2); }

tbody tr:last-child td { border-bottom: 0; }

tbody tr.totals-row td {
  background: rgba(62, 213, 152, 0.04);
  font-weight: 700;
  border-top: 1px solid var(--accent-line);
  color: var(--text);
}

tbody tr.totals-row td:first-child {
  background: linear-gradient(90deg, var(--accent-soft), rgba(62, 213, 152, 0.04));
  color: var(--accent);
}

.score-input {
  width: 52px;
  min-height: 36px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  text-align: center;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: all 140ms ease;
}

.score-input:hover { border-color: var(--line-strong); }
.score-input:focus { border-color: var(--accent); box-shadow: var(--ring); }

/* Score-to-par color coding */
.score-input.eagle { border-color: var(--score-eagle); background: rgba(240, 181, 74, 0.10); color: #fbd089; box-shadow: inset 0 0 0 1px rgba(240, 181, 74, 0.28); }
.score-input.birdie { border-color: var(--score-birdie); background: rgba(239, 107, 90, 0.10); color: #fbb5aa; box-shadow: inset 0 0 0 1px rgba(239, 107, 90, 0.28); }
.score-input.bogey { border-color: var(--score-bogey); background: rgba(107, 160, 232, 0.08); color: #b8d5f5; }
.score-input.double { border-color: var(--score-double); background: rgba(77, 128, 199, 0.06); color: #9fbce8; }

.compact-table table { min-width: 440px; }
.compact-table th { font-size: 0.72rem; }

.compact-select {
  min-height: 34px;
  border-radius: var(--r-xs);
  background-size: auto, 9px 6px;
  background-position: 0 0, right 8px center;
  padding-right: 26px;
  padding-left: 8px;
  font-size: 0.85rem;
}

/* =========================================================
   Score legend
   ========================================================= */

.score-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
}

.score-legend span { display: inline-flex; align-items: center; gap: 6px; }

.score-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

/* =========================================================
   Eggs
   ========================================================= */

.egg-cell {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  min-width: 160px;
}

.egg-button {
  min-width: 32px;
  min-height: 30px;
  padding: 0 8px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: all 120ms ease;
}

.egg-button:hover { border-color: var(--line-strong); color: var(--text-dim); }

.egg-button.selected {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: #c4f0d8;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* =========================================================
   Spin Wheel
   ========================================================= */

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 28px;
  align-items: center;
}

.wheel-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 34px 8px 12px;
  isolation: isolate;
}

.wheel-stage::before {
  content: "";
  position: absolute;
  inset: 50px 10% 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(62, 213, 152, 0.32), rgba(62, 213, 152, 0.06) 60%, transparent 75%);
  filter: blur(36px);
  z-index: -1;
}

.wheel {
  aspect-ratio: 1;
  width: min(100%, 376px);
  margin: 0 auto;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  border: 10px solid rgba(232, 244, 238, 0.08);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(62, 213, 152, 0.16),
    inset 0 0 0 2px rgba(255, 255, 255, 0.08);
  transform: rotate(var(--wheel-rotation, 0deg));
  will-change: transform;
}

.wheel.spinning {
  animation: wheel-spin 3.2s cubic-bezier(0.16, 0.84, 0.18, 1) both;
}

.wheel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.34), transparent 22%),
    radial-gradient(circle at 50% 50%, transparent 54%, rgba(0, 0, 0, 0.32) 100%);
  pointer-events: none;
  z-index: 1;
}

.wheel::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 50%;
  border: 1px solid rgba(232, 244, 238, 0.22);
  box-shadow:
    inset 0 0 32px rgba(0, 0, 0, 0.24),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
  z-index: 1;
}

.wheel-label {
  position: absolute;
  inset: 0;
  transform: rotate(var(--label-angle));
  pointer-events: none;
  z-index: 2;
}

.wheel-label span {
  position: absolute;
  top: 22px;
  left: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100px;
  min-height: 26px;
  padding: 0 10px;
  transform: translateX(-50%) rotate(var(--label-counter));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--r-pill);
  background: rgba(6, 18, 14, 0.78);
  backdrop-filter: blur(4px);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
}

.wheel-hub {
  position: absolute;
  left: 50%;
  top: calc(50% + 12px);
  z-index: 4;
  display: grid;
  place-items: center;
  width: 108px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(62, 213, 152, 0.32);
  background:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.14), transparent 55%),
    linear-gradient(180deg, var(--panel-3), var(--panel));
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -8px 14px rgba(0, 0, 0, 0.3);
}

.wheel-hub strong {
  margin-top: 8px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.wheel-hub span {
  margin-top: -16px;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.wheel-pointer {
  position: absolute;
  top: 4px;
  left: 50%;
  width: 46px;
  height: 54px;
  transform: translateX(-50%);
  z-index: 5;
}

.wheel-pointer::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  width: 28px;
  height: 32px;
  transform: translateX(-50%);
  transform-origin: 50% 0;
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  background: linear-gradient(180deg, #6df0b3, var(--accent-2));
  box-shadow: 0 6px 18px rgba(31, 175, 115, 0.5);
}

.wheel-pointer::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 50%;
  width: 40px;
  height: 10px;
  transform: translateX(-50%);
  border-radius: var(--r-pill);
  background: linear-gradient(180deg, #ffffff, #c8d3cd);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.is-spinning .wheel-pointer::before {
  animation: pointer-tick 0.14s steps(2, end) 22;
}

/* =========================================================
   Result list
   ========================================================= */

.result-list { display: grid; gap: 8px; }

.is-spinning .result-list {
  animation: result-reveal 0.5s ease both;
  animation-delay: 2.7s;
}

.result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.005)),
    rgba(0, 0, 0, 0.18);
  transition: border-color 140ms ease, background 140ms ease;
}

.result-row:hover { border-color: var(--line-strong); }

.result-row.featured {
  border-color: var(--accent-line);
  background:
    linear-gradient(180deg, rgba(62, 213, 152, 0.16), rgba(62, 213, 152, 0.04)),
    rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 0 0 1px rgba(62, 213, 152, 0.18), 0 6px 18px rgba(20, 110, 70, 0.18);
}

.result-row strong.rank {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-line);
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-row .row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.result-row .row-main span { line-height: 1.35; min-width: 0; }

/* =========================================================
   Ledger
   ========================================================= */

.ledger-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.005)),
    rgba(0, 0, 0, 0.18);
  transition: border-color 140ms ease;
}

.ledger-row:hover { border-color: var(--line-strong); }

.ledger-row .player-tag {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0)),
    var(--panel-3);
  color: var(--text);
  border: 1px solid var(--line-strong);
  letter-spacing: -0.01em;
}

.ledger-row .player-name {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

.ledger-row .player-amount {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ledger-row.leader {
  border-color: var(--gold-line);
  background:
    linear-gradient(180deg, rgba(229, 185, 90, 0.10), rgba(229, 185, 90, 0.02)),
    rgba(0, 0, 0, 0.18);
}

.ledger-row.leader .player-tag {
  background: linear-gradient(180deg, var(--gold), var(--gold-2));
  color: #2a1d04;
  border-color: var(--gold-2);
  box-shadow: 0 6px 18px rgba(200, 152, 52, 0.34);
}

.ledger-row.leader .leader-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--gold-soft);
  color: #f3d791;
  border: 1px solid var(--gold-line);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settlement-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.18);
  transition: border-color 140ms ease;
}

.settlement-row:hover { border-color: var(--line-strong); }

.settlement-row .flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.settlement-row .flow .arrow {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
}

.settlement-row .flow .arrow svg { width: 13px; height: 13px; }

.settlement-row .amount {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent);
}

.detail-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--r-xs);
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid var(--line-soft);
  font-size: 0.88rem;
}

.detail-row:hover { background: rgba(255, 255, 255, 0.02); border-color: var(--line); }

.detail-row .label { color: var(--text-dim); }
.detail-row .label .tag {
  display: inline-block;
  margin-right: 8px;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.detail-row .stake {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
}

.money-pos { color: var(--pos); }
.money-neg { color: var(--neg); }
.money-even { color: var(--muted); }

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

.empty {
  padding: 26px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  text-align: center;
  background: rgba(0, 0, 0, 0.12);
  font-size: 0.92rem;
}

.empty .empty-icon {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--accent);
}

.empty .empty-icon svg { width: 20px; height: 20px; }

.split-actions { display: flex; gap: 8px; flex-wrap: wrap; }

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

.press-row {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.8fr 0.8fr auto;
  gap: 10px;
  align-items: end;
}

/* =========================================================
   Game card variant (subtle visual tag)
   ========================================================= */

.team-box.game-card {
  position: relative;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    rgba(0, 0, 0, 0.18);
  border-color: var(--line);
}

.game-card .game-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.game-card .game-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.98rem;
  letter-spacing: -0.01em;
}

.game-card .game-desc {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
  display: block;
  margin-top: 2px;
}

/* =========================================================
   Animations
   ========================================================= */

@keyframes wheel-spin {
  0% { filter: brightness(1) saturate(1); transform: rotate(var(--wheel-from)); }
  76% { filter: brightness(1.12) saturate(1.08); }
  90% { transform: rotate(calc(var(--wheel-to) - 8deg)); }
  100% { filter: brightness(1) saturate(1); transform: rotate(var(--wheel-to)); }
}

@keyframes pointer-tick {
  0% { transform: translateX(-50%) rotate(-7deg); }
  100% { transform: translateX(-50%) rotate(7deg); }
}

@keyframes result-reveal {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .wheel.spinning,
  .is-spinning .wheel-pointer::before,
  .is-spinning .result-list { animation: none; }
  * { transition-duration: 0s !important; }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 980px) {
  .topbar, .grid.two, .grid.three, .wheel-layout {
    grid-template-columns: 1fr;
  }
  .actions { justify-content: flex-start; }
  .press-row { grid-template-columns: 1fr 1fr; }
  .app-shell { padding: 22px 18px; }
}

@media (max-width: 760px) {
  .player-row { grid-template-columns: 2rem minmax(0, 1fr) 4.6rem; }
  .player-row .remove-player { grid-column: 2 / 4; }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 16px 14px calc(96px + env(safe-area-inset-bottom));
  }

  .app-shell::before { background-size: 44px 44px; }

  .topbar { grid-template-columns: 1fr; gap: 14px; margin-bottom: 16px; }

  .brand { gap: 12px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 10px; }
  .brand-mark svg { width: 18px; height: 18px; }
  .brand h1 { font-size: 1.55rem; }
  .brand p { font-size: 0.86rem; }

  .actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .actions .button { width: 100%; min-height: 38px; padding: 0 8px; font-size: 0.84rem; }
  .actions .button svg { display: none; }

  .tabs {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    margin: 0;
    padding: 6px;
    border-radius: var(--r-lg);
    border: 1px solid var(--line-strong);
    background: rgba(7, 16, 13, 0.86);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .tab {
    flex-direction: column;
    gap: 3px;
    min-height: 54px;
    padding: 6px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--r-sm);
  }

  .tab svg { width: 18px; height: 18px; opacity: 1; }
  .tab span { line-height: 1; }

  .card { border-radius: var(--r-md); }
  .card-header { padding: 16px 16px 0; align-items: stretch; }
  .card-header > .button,
  .card-header > .split-actions { width: auto; }
  .card-title { font-size: 1rem; }
  .card-subtitle { font-size: 0.84rem; }
  .card-body { padding: 14px 16px 16px; }

  .button, .input, .select { min-height: 44px; }

  .player-row { grid-template-columns: 1.8rem minmax(0, 1fr) 4.4rem; gap: 8px; padding: 10px; }
  .player-row .remove-player { min-height: 34px; }

  .player-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .chip-button { min-height: 42px; padding: 0 10px; text-align: center; }

  .team-box { padding: 12px; }

  .split-actions { display: grid; grid-template-columns: 1fr; }
  .split-actions .button, .split-actions .select, .split-actions .input { width: 100%; max-width: none !important; }

  .bet-grid { grid-template-columns: 1fr; }
  .press-row { grid-template-columns: 1fr; }

  .result-row { align-items: flex-start; flex-direction: column; gap: 6px; }
  .result-row .row-main { width: 100%; }
  .result-row > strong.rank,
  .result-row > span:last-child { align-self: flex-end; }

  .ledger-row { grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 12px; }
  .ledger-row .player-tag { width: 32px; height: 32px; font-size: 0.85rem; }
  .ledger-row .player-amount { font-size: 1rem; }

  .settlement-row { grid-template-columns: 1fr; gap: 6px; }
  .settlement-row .amount { align-self: flex-end; }

  .detail-row { grid-template-columns: 1fr; gap: 4px; font-size: 0.85rem; }
  .detail-row .stake { align-self: flex-end; }

  .wheel { width: min(100%, 300px); border-width: 8px; }
  .wheel-stage { min-height: 340px; padding-top: 28px; }
  .wheel-label span { top: 16px; max-width: 78px; min-height: 24px; padding: 0 8px; font-size: 0.68rem; }
  .wheel-hub { top: calc(50% + 10px); width: 88px; }
  .wheel-hub strong { font-size: 1rem; }
  .wheel-hub span { margin-top: -14px; font-size: 0.58rem; }
  .wheel-layout { gap: 14px; }

  .table-wrap { margin-inline: -2px; }
  table { min-width: 640px; }
  th, td { padding: 8px 6px; font-size: 0.86rem; }
  td:first-child { padding-left: 10px; }
  .score-input { width: 46px; min-height: 36px; }
  .compact-table table { min-width: 380px; }
  .egg-cell { min-width: 140px; }
}

@media (max-width: 420px) {
  .app-shell { padding-inline: 12px; }
  .brand h1 { font-size: 1.4rem; }
  .brand p { font-size: 0.8rem; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .button.danger { grid-column: 1 / -1; }
  .card-header { flex-direction: column; }
  .player-row { grid-template-columns: 1.7rem minmax(0, 1fr); }
  .player-row input[data-player-hcp] { grid-column: 2; width: 100%; }
  .player-row .remove-player { grid-column: 2; }
  .tab { font-size: 0.66rem; }
  .player-chips { grid-template-columns: 1fr; }
}
