:root {
  --bg-deep: #071b19;
  --bg-mid: #0f342f;
  --paper: rgba(247, 242, 231, 0.94);
  --paper-strong: rgba(255, 251, 243, 0.98);
  --text: #15221f;
  --muted: #566865;
  --line: rgba(21, 34, 31, 0.12);
  --gold: #d7a54b;
  --gold-deep: #a76c23;
  --emerald: #1f7f63;
  --felt: #1b7f61;
  --felt-dark: #105340;
  --felt-light: #36a67f;
  --shadow: 0 20px 54px rgba(4, 10, 10, 0.3);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(215, 165, 75, 0.18), transparent 24%),
    radial-gradient(circle at 88% 14%, rgba(54, 166, 127, 0.18), transparent 22%),
    linear-gradient(145deg, #081613, #123530 56%, #0a2623 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.03), transparent 30%),
    linear-gradient(rgba(255, 255, 255, 0.014) 0, rgba(255, 255, 255, 0.014) 1px, transparent 1px, transparent 88px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.014) 0, rgba(255, 255, 255, 0.014) 1px, transparent 1px, transparent 88px);
  opacity: 0.4;
  pointer-events: none;
}

.billard-app {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.billard-topbar,
.billard-controls-panel,
.table-shell,
.player-card,
.rules-card {
  backdrop-filter: blur(12px);
}

.billard-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 24, 22, 0.42);
  box-shadow: var(--shadow);
}

.billard-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.billard-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #f7f2e5;
}

.billard-brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #1f170d;
  font-weight: 900;
}

.billard-brand-copy {
  display: grid;
  gap: 2px;
}

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

.billard-brand-copy span,
.billard-return,
.billard-support {
  color: rgba(247, 242, 229, 0.78);
}

.billard-return,
.billard-support {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
}

.billard-return {
  background: rgba(255, 255, 255, 0.08);
}

.billard-support {
  background: linear-gradient(135deg, #ffdc42, #f0b90a);
  color: #20170d;
}

.billard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(320px, 0.96fr);
  gap: 24px;
  align-items: start;
  padding: 34px 0 22px;
}

.eyebrow {
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  font-weight: 800;
  color: rgba(247, 242, 229, 0.66);
}

.billard-copy h1,
.table-caption h2,
.rules-card h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.billard-copy h1 {
  margin: 0 0 16px;
  max-width: 11ch;
  color: #fdf7eb;
  font-size: clamp(2.4rem, 5vw, 4.7rem);
  line-height: 0.96;
}

.billard-copy p:last-child {
  max-width: 60ch;
  margin: 0;
  color: rgba(247, 242, 229, 0.82);
  font-size: 1.04rem;
  line-height: 1.7;
}

.billard-controls-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.12), transparent 38%),
    rgba(247, 242, 231, 0.12);
  box-shadow: var(--shadow);
}

.status-copy {
  display: grid;
  gap: 10px;
}

.status-copy h2 {
  margin: 0;
  color: #fff8ec;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.1;
}

.notice-text,
.setup-note,
.table-hint {
  margin: 0;
  color: rgba(247, 242, 229, 0.76);
  line-height: 1.6;
}

.setup-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  border-radius: 24px;
  background: rgba(9, 20, 18, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.setup-group,
.power-panel {
  display: grid;
  gap: 10px;
}

.setup-label {
  color: #f7f2e5;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff8ec;
  cursor: pointer;
  font-weight: 700;
}

.choice-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-pill:has(input:checked) {
  background: linear-gradient(135deg, rgba(215, 165, 75, 0.98), rgba(167, 108, 35, 0.96));
  border-color: rgba(255, 226, 165, 0.32);
  color: #20170d;
  box-shadow: 0 14px 30px rgba(117, 68, 14, 0.24);
}

.power-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.power-head strong {
  color: #fff8ec;
}

.power-range {
  width: 100%;
  accent-color: var(--gold);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.action-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff8ec;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.action-button.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #20170d;
  box-shadow: 0 14px 30px rgba(117, 68, 14, 0.24);
}

.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
}

.action-button:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
  box-shadow: none;
}

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

.metrics-grid div {
  padding: 16px 14px;
  border-radius: 22px;
  background: rgba(9, 20, 18, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.metrics-grid dt {
  margin: 0 0 8px;
  color: rgba(247, 242, 229, 0.66);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metrics-grid dd {
  margin: 0;
  color: #fff8ec;
  font-size: 1.24rem;
  font-weight: 800;
}

.billard-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 24px;
  align-items: start;
}

.table-shell {
  position: relative;
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: 30px;
  background: rgba(247, 242, 231, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: var(--shadow);
}

.table-caption {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.table-caption h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2.4vw, 2.3rem);
  line-height: 1.06;
}

.table-hint {
  max-width: 34ch;
  color: var(--muted);
}

.table-stage {
  position: relative;
  border-radius: 34px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.22), transparent 28%),
    linear-gradient(145deg, #6d4221, #402311);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -8px 18px rgba(15, 8, 4, 0.38);
}

.table-canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 24px;
  background: linear-gradient(145deg, var(--felt-light), var(--felt) 46%, var(--felt-dark));
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.06),
    inset 0 0 40px rgba(4, 14, 12, 0.22);
  touch-action: none;
  cursor: crosshair;
}

.result-overlay {
  position: absolute;
  inset: 42px;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 30px;
  border-radius: 28px;
  background: rgba(9, 21, 18, 0.8);
  color: #fff8ec;
  text-align: center;
  box-shadow: 0 28px 54px rgba(3, 8, 8, 0.34);
}

.result-overlay.hidden {
  display: none;
}

.overlay-kicker {
  margin: 0;
  color: rgba(247, 242, 229, 0.66);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.result-overlay h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.overlay-message {
  max-width: 34ch;
  margin: 0 auto;
  line-height: 1.6;
}

.overlay-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.overlay-meta div {
  padding: 16px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.overlay-meta dt {
  margin: 0 0 6px;
  color: rgba(247, 242, 229, 0.64);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.overlay-meta dd {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.billard-sidebar {
  display: grid;
  gap: 18px;
}

.player-card,
.rules-card {
  padding: 22px;
  border-radius: 28px;
  background: rgba(247, 242, 231, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.player-card {
  display: grid;
  gap: 16px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.player-card.active {
  border-color: rgba(31, 127, 99, 0.34);
  box-shadow:
    var(--shadow),
    0 0 0 3px rgba(31, 127, 99, 0.1);
}

.billard-app.training-mode .player-card.opponent {
  opacity: 0.72;
}

.player-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-token {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-weight: 900;
  border: 2px solid rgba(15, 18, 18, 0.12);
}

.player-token.white-ball {
  background:
    radial-gradient(circle at 34% 30%, #ffffff, #f5eee0 62%, #c8beae);
  color: #10231b;
}

.player-token.black-ball {
  background:
    radial-gradient(circle at 34% 30%, #61656d, #1d2329 58%, #090d12);
  color: #fff8ec;
}

.player-name {
  margin: 0 0 4px;
  font-size: 1.14rem;
  font-weight: 800;
}

.player-role {
  margin: 0;
  color: var(--muted);
}

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

.player-stats div {
  padding: 14px 12px;
  border-radius: 18px;
  background: rgba(14, 28, 23, 0.05);
}

.player-stats dt {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.player-stats dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.rules-card h3 {
  margin: 0 0 14px;
  font-size: 1.48rem;
}

.rules-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

@media (max-width: 1060px) {
  .billard-hero,
  .billard-layout {
    grid-template-columns: 1fr;
  }

  .billard-copy h1 {
    max-width: none;
  }
}

@media (max-width: 720px) {
  .billard-app {
    width: min(100%, calc(100% - 18px));
    padding-top: 16px;
  }

  .billard-topbar,
  .table-shell,
  .player-card,
  .rules-card,
  .billard-controls-panel {
    border-radius: 22px;
  }

  .billard-topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
  }

  .billard-brand-copy span,
  .billard-return,
  .billard-support {
    font-size: 0.9rem;
  }

  .billard-topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .billard-hero {
    gap: 18px;
    padding: 24px 0 18px;
  }

  .metrics-grid,
  .player-stats,
  .overlay-meta {
    grid-template-columns: 1fr;
  }

  .table-shell {
    padding: 16px;
  }

  .table-caption {
    flex-direction: column;
    align-items: start;
  }

  .table-stage {
    padding: 12px;
    border-radius: 24px;
  }

  .result-overlay {
    inset: 18px;
    padding: 22px 18px;
  }

  .choice-pill,
  .action-button,
  .billard-return,
  .billard-support {
    width: 100%;
  }

  .action-row {
    display: grid;
  }
}
