:root {
  --bg-deep: #1a1410;
  --ink: #f3e6d4;
  --ink-muted: #c4b09a;
  --accent: #c45c26;
  --accent-hot: #e07838;
  --gold: #d4a84b;
  --panel: rgba(28, 20, 14, 0.78);
  --line: rgba(243, 230, 212, 0.14);
  --font-display: "Rubik Spray Paint", "Impact", "Arial Black", sans-serif;
  --font-body: "Source Sans 3", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-body);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(196, 92, 38, 0.28), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(212, 168, 75, 0.18), transparent 45%),
    linear-gradient(160deg, rgba(12, 9, 7, 0.82), rgba(26, 20, 16, 0.92));
  z-index: 20;
  animation: fadeIn 0.45s ease;
}

.overlay-card {
  width: min(440px, 100%);
  max-height: min(92vh, 900px);
  overflow-y: auto;
  padding: 2rem 1.75rem;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(55, 38, 26, 0.55), rgba(22, 16, 12, 0.88)),
    var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-panel {
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.auth-tab {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.55rem 0.4rem;
  cursor: pointer;
}

.auth-tab.active {
  color: var(--gold);
  border-color: rgba(212, 168, 75, 0.45);
  background: rgba(212, 168, 75, 0.12);
}

.auth-form {
  display: grid;
  gap: 0.65rem;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.auth-form input {
  appearance: none;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
  width: 100%;
  touch-action: manipulation;
  user-select: text;
  -webkit-user-select: text;
}

.auth-error {
  color: #e88a6a;
  font-size: 0.88rem;
  min-height: 1.2em;
  margin-top: 0.45rem;
}

.auth-note {
  color: var(--ink-muted);
  font-size: 0.82rem;
  margin-top: 0.55rem;
  line-height: 1.35;
}

.auth-note a {
  color: var(--gold);
  pointer-events: auto;
}

.auth-user {
  margin-bottom: 1.1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.wallet-chip {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  font-weight: 700;
}

.wallet-credits {
  color: var(--gold);
  font-size: 0.95rem;
}

.wallet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.wallet-actions .btn {
  margin-bottom: 0;
  font-size: 0.9rem;
  padding: 0.7rem 0.6rem;
}

.lobby-min {
  color: var(--accent-hot);
  font-size: 0.9rem;
  margin: -0.4rem 0 0.85rem;
}

.lobby-list li {
  justify-content: space-between;
}

.lobby-list .lobby-player {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.btn-kick {
  flex-shrink: 0;
  border: 1px solid rgba(232, 138, 106, 0.45);
  background: rgba(196, 92, 38, 0.18);
  color: #f0c4b0;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  pointer-events: auto;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-kick:hover {
  background: rgba(196, 92, 38, 0.32);
}

.title-logo {
  display: block;
  width: min(320px, 85vw);
  height: auto;
  margin: 0.15rem auto 1rem;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.45));
}

.title-card h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3.8rem, 15vw, 6.2rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  margin: 0.35rem 0 1rem;
  color: var(--gold);
  text-transform: none;
  transform: rotate(-2deg);
  text-shadow:
    0.04em 0.05em 0 rgba(0, 0, 0, 0.55),
    -0.02em 0 0 rgba(196, 92, 38, 0.35);
}

.legal-links {
  margin-top: 0.85rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink-muted);
  line-height: 1.45;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  justify-content: center;
  align-items: center;
}

.legal-links a {
  color: var(--gold);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  pointer-events: auto;
}

.legal-links a:hover {
  color: var(--accent-hot);
}

.eyebrow {
  color: var(--accent-hot);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  font-weight: 700;
}

.lede {
  color: var(--ink-muted);
  line-height: 1.45;
  margin-bottom: 1.4rem;
}

.setup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.setup .setup-wide {
  grid-column: 1 / -1;
}

.setup label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.setup select,
.setup input {
  appearance: none;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0.7rem 0.8rem;
  font: inherit;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
  width: 100%;
  touch-action: manipulation;
  user-select: text;
  -webkit-user-select: text;
}

.setup input::placeholder {
  color: rgba(196, 176, 154, 0.55);
}

.btn {
  width: 100%;
  border: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  padding: 0.9rem 1.1rem;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.primary {
  background: linear-gradient(180deg, var(--accent-hot), var(--accent));
  color: #1a100a;
  margin-bottom: 0.55rem;
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.btn.secondary {
  background: rgba(212, 168, 75, 0.16);
  color: var(--gold);
  border: 1px solid rgba(212, 168, 75, 0.35);
  margin-bottom: 0.55rem;
}

.btn.secondary:hover {
  background: rgba(212, 168, 75, 0.24);
}

.btn.ghost {
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--line);
  margin-bottom: 0.55rem;
}

.overlay-card h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.8rem);
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  text-transform: none;
}

.lobby-card h2 {
  font-size: 2.2rem;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.lobby-lede {
  margin-bottom: 1rem;
}

.share-row {
  display: grid;
  gap: 0.35rem;
  color: var(--ink-muted);
  font-size: 0.85rem;
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.share-row input {
  width: 100%;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  text-transform: none;
  letter-spacing: 0;
}

.lobby-list {
  list-style: none;
  display: grid;
  gap: 0.45rem;
  margin: 0.9rem 0 0.75rem;
  padding: 0;
}

.lobby-list li {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.7rem;
  border-left: 3px solid var(--player-color, var(--gold));
  background: rgba(0, 0, 0, 0.22);
  color: var(--ink);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

.lobby-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--player-color, var(--gold));
  flex-shrink: 0;
}

.lobby-status {
  color: var(--gold);
  font-size: 0.92rem;
  margin-bottom: 0.9rem;
  min-height: 1.3em;
  text-transform: none;
  letter-spacing: 0;
}

.rules {
  display: grid;
  gap: 0.75rem;
  margin: 0 0 1.1rem 1.1rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.controls-note {
  color: var(--gold);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: linear-gradient(180deg, rgba(12, 9, 7, 0.72), transparent);
}

.brand-chip,
.round-label,
.pot-label {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-chip {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.brand-logo {
  width: 48px;
  height: 32px;
  object-fit: contain;
  border-radius: 4px;
  background: #000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.pot-label {
  color: var(--accent-hot);
  font-weight: 700;
}

.scoreboard {
  position: absolute;
  top: 4.2rem;
  left: 1rem;
  display: grid;
  gap: 0.45rem;
  min-width: 210px;
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.45rem 0.7rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--player-color, var(--gold));
  font-size: 0.9rem;
}

.player-row.active {
  background: rgba(196, 92, 38, 0.28);
  box-shadow: 0 0 0 1px rgba(224, 120, 56, 0.35);
}

.player-row .player-name {
  font-weight: 600;
}

.player-row .wealth {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.player-row .coin-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
  flex-shrink: 0;
}

.player-row .lei {
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.player-row .coin-count {
  font-size: 0.75rem;
  color: var(--ink-muted);
  white-space: nowrap;
}

.turn-banner {
  position: absolute;
  top: 22%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.55rem 1.2rem;
  background: rgba(12, 9, 7, 0.72);
  border: 1px solid var(--line);
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 1.35rem;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.turn-banner.show {
  opacity: 1;
}

.aim-panel {
  position: absolute;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 2rem));
  padding: 0.9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  pointer-events: none;
}

.aim-hint {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0.7rem;
  text-align: center;
}

.meters {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.85rem;
  align-items: end;
}

.meter span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 0.3rem;
}

.meter-interactive {
  pointer-events: auto;
  cursor: ew-resize;
  touch-action: none;
}

.bar {
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--accent-hot));
  transition: width 0.05s linear;
}

#height-fill {
  background: linear-gradient(90deg, #6fcf7a, var(--gold));
}

.angle-readout {
  font-family: var(--font-display);
  font-size: 1.6rem;
  min-width: 3.2rem;
  text-align: right;
  color: var(--ink);
}

.result-toast {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  padding: 0.85rem 1.4rem;
  background: rgba(12, 9, 7, 0.85);
  border: 1px solid var(--gold);
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 1.5rem;
  text-align: center;
  animation: popIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .scoreboard {
    top: auto;
    bottom: 7.5rem;
    left: 0.75rem;
  }

  .aim-panel {
    bottom: 0.75rem;
  }

  .meters {
    grid-template-columns: 1fr 1fr;
  }

  .meter-angle {
    grid-column: 1 / -1;
  }

  .meter-angle .angle-readout {
    text-align: left;
  }
}

/* —— Terms / legal page —— */
html.legal-html,
html.legal-html body.legal-page {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  touch-action: pan-y;
  user-select: text;
  -webkit-user-select: text;
  overscroll-behavior: auto;
}

body.legal-page {
  background:
    radial-gradient(ellipse at 30% 10%, rgba(196, 92, 38, 0.22), transparent 45%),
    radial-gradient(ellipse at 80% 90%, rgba(212, 168, 75, 0.14), transparent 40%),
    var(--bg-deep);
}

.legal-wrap {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.legal-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.legal-logo-link {
  display: inline-block;
}

.legal-logo {
  width: min(280px, 70vw);
  height: auto;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.4));
}

.legal-header h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.8rem);
  color: var(--gold);
  margin-bottom: 0.35rem;
}

.legal-meta {
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.legal-body {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 1.4rem 1.35rem;
  backdrop-filter: blur(12px);
}

.legal-body section + section {
  margin-top: 1.35rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.legal-body h2 {
  font-size: 1.05rem;
  color: var(--accent-hot);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

.legal-body p,
.legal-body li {
  color: var(--ink-muted);
  line-height: 1.5;
  font-size: 0.98rem;
}

.legal-body p + p {
  margin-top: 0.55rem;
}

.legal-body ul {
  margin: 0.55rem 0 0 1.15rem;
  display: grid;
  gap: 0.4rem;
}

.legal-body strong {
  color: var(--ink);
}

.legal-footer {
  margin-top: 1.5rem;
  text-align: center;
}

.legal-footer .btn {
  width: auto;
  min-width: 200px;
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

.legal-copy {
  margin-top: 1rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

/* —— TOP earners —— */
.top-wrap {
  width: min(640px, 100%);
}

.top-board {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.35rem 0;
  backdrop-filter: blur(12px);
}

.top-empty {
  padding: 1.5rem 1.25rem;
  color: var(--ink-muted);
  text-align: center;
}

.top-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.top-row {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--line);
}

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

.top-row--positive .top-earned strong {
  color: var(--gold);
}

.top-row--negative .top-earned strong {
  color: var(--accent-hot);
}

.top-row--neutral .top-earned strong {
  color: var(--ink-muted);
}

.top-rank {
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--gold);
  text-align: center;
}

.top-row:nth-child(1) .top-rank {
  color: var(--gold);
}

.top-row:nth-child(2) .top-rank,
.top-row:nth-child(3) .top-rank {
  color: var(--accent-hot);
}

.top-name {
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-earned {
  text-align: right;
  display: grid;
  gap: 0.1rem;
}

.top-earned strong {
  font-size: 1.05rem;
}

.top-earned-lei {
  font-size: 0.78rem;
  color: var(--ink-muted);
}

.top-note {
  margin-top: 1.15rem;
  color: var(--ink-muted);
  font-size: 0.92rem;
  line-height: 1.45;
  text-align: center;
}

.top-note strong {
  color: var(--ink);
}

.top-footer-links {
  margin-top: 0.85rem;
  justify-content: center;
}

a.btn.ghost {
  display: block;
  text-align: center;
  text-decoration: none;
}
