:root {
  --bg: #0c0e14;
  --surface: #171b26;
  --lift: #222837;
  --ink: #eef1f6;
  --muted: #8b93a7;
  --accent: #6d8bff;
  --ok: #3ee0a0;
  --bad: #ff5d73;
  --warn: rgba(255, 93, 115, 0.16);
  --on-accent: #ffffff;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --tap: 44px;
  --col-bid: 52px;
  --col-tricks: 64px;
  --col-score: 72px;
  --safe-t: max(16px, env(safe-area-inset-top));
  --safe-b: max(16px, env(safe-area-inset-bottom));
  --safe-x: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "DM Sans", "Segoe UI", sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

b,
strong,
h1,
h2 {
  font-weight: 400;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, #1a2250, transparent 58%),
    var(--bg);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  touch-action: manipulation;
}

input {
  background: transparent;
  border: 0;
  outline: none;
}

#app {
  max-width: 28rem;
  margin: 0 auto;
  min-height: 100dvh;
  padding: var(--safe-t) var(--safe-x) calc(96px + var(--safe-b));
}

.wordmark {
  margin: 0 0 18px;
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.setup-title {
  margin: 0 0 18px;
  font-size: 2rem;
}

.panel {
  background: var(--surface);
  border-radius: 20px;
  padding: 8px 12px 12px;
  box-shadow: var(--shadow);
}

.player-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}

.name-input {
  flex: 1;
  height: var(--tap);
  padding: 0 14px;
  border-radius: 12px;
  background: var(--lift);
  font-size: 16px;
}

.name-input:focus {
  background: #2a3144;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.2rem;
  background: var(--lift);
}

.home {
  min-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 24px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 48px;
}

.home-actions {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.home .primary-btn {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.btn-sub {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.75);
}

.home-ghost {
  margin-top: 0;
}

.ghost-btn,
.primary-btn,
.link-btn {
  min-height: var(--tap);
}

.ghost-btn {
  width: 100%;
  margin-top: 8px;
  border-radius: 12px;
  color: var(--ink);
  background: var(--lift);
}

.primary-btn {
  width: 100%;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
}

.primary-btn:disabled {
  opacity: 0.4;
}

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

.meta {
  text-align: center;
  margin: 14px 0;
  color: var(--muted);
}

.footer-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.board-head {
  display: grid;
  grid-template-columns: 1fr var(--col-bid) var(--col-tricks) var(--col-score);
  align-items: end;
  padding: 4px 12px 10px;
}

.board-head h1 {
  margin: 0;
  font-size: 1.35rem;
  text-align: left;
}

.player-count {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
}

.col-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.banner {
  margin: 0 0 10px;
  padding: 8px 12px;
  border-radius: 12px;
  text-align: center;
  font-size: 0.9rem;
  background: var(--surface);
}

.banner.warn {
  background: var(--warn);
  color: var(--bad);
}

.score-card {
  position: relative;
  background: var(--surface);
  border-radius: 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.score-card.dealer {
  background: #1d2233;
}

.dealer-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.68rem;
  display: grid;
  place-items: center;
  z-index: 1;
  pointer-events: none;
}

.score-card.dealer .pname {
  padding-left: 22px;
}

.score-row {
  display: grid;
  grid-template-columns: 1fr var(--col-bid) var(--col-tricks) var(--col-score);
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 10px 12px;
  text-align: inherit;
}

.pname {
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 8px;
}

.num,
.score-val {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.num {
  border-radius: 10px;
  min-height: 36px;
  display: grid;
  place-items: center;
  background: var(--lift);
}

.num.active {
  background: var(--accent);
  color: var(--on-accent);
}

.num.dash {
  color: var(--muted);
  background: transparent;
}

.score-val {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.score-val.ok {
  color: var(--ok);
}

.score-val.bad {
  color: var(--bad);
}

.chevron {
  color: var(--muted);
  font-size: 0.75rem;
}

.score-card.open .chevron {
  transform: rotate(180deg);
}

.history,
.picker {
  background: #12151f;
  padding: 0 12px 12px;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr var(--col-bid) var(--col-tricks) var(--col-score);
  align-items: center;
  min-height: 40px;
  color: var(--muted);
  font-size: 0.92rem;
}

.history-row .num,
.history-row .score-val {
  min-height: auto;
  background: none;
}

.history-row .total-label,
.history-row .total-val {
  color: var(--ink);
}

.bubble-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.picker .bubble-grid {
  padding: 12px 0 2px;
}

.bubble {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  background: var(--lift);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.bubble.selected {
  background: var(--accent);
  color: var(--on-accent);
}

.bubble.forbidden {
  opacity: 0.28;
  text-decoration: line-through;
  cursor: not-allowed;
}

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 28rem;
  margin: 0 auto;
  padding: 12px var(--safe-x) calc(12px + var(--safe-b));
  background: linear-gradient(180deg, transparent, var(--bg) 32%);
}

.back-btn {
  width: 52px;
  height: 52px;
  flex: none;
  border-radius: 50%;
  background: var(--lift);
  font-size: 1.4rem;
}

.dock .primary-btn {
  flex: 1;
  min-height: 52px;
}

.results {
  text-align: center;
  padding-top: 12px;
}

.win-label {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
  color: var(--accent);
}

.results h1 {
  margin: 8px 0 6px;
  font-size: clamp(2rem, 8vw, 2.8rem);
}

.win-score {
  margin: 0 0 20px;
  color: var(--ok);
  font-size: 1.05rem;
}

.place {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.place.win {
  background: #1d2440;
}

.place b {
  color: var(--ok);
}

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
