:root {
  --felt: #0b3d2e;
  --felt-dark: #072a1f;
  --neon: #5df2c3;
  --ink: #eef7f2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: radial-gradient(ellipse at top, var(--felt), var(--felt-dark));
  color: var(--ink);
  min-height: 100vh;
}

/* Cosmetic felts restyle the whole viewport, not just the table. */
body:has(.felt-midnight) {
  --felt: #10122b;
  --felt-dark: #090a1a;
  --neon: #8a9bff;
  --ink: #e8ebff;
}
body:has(.felt-royal) {
  --felt: #3d0b2e;
  --felt-dark: #2a071f;
  --neon: #f2c35d;
  --ink: #fbf0f7;
}
body:has(.felt-neon) {
  --felt: #0a0a0a;
  --felt-dark: #000000;
  --neon: #39ff14;
  --ink: #eaffe0;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  margin: 0.5rem 0 0.25rem;
  font-size: 1.6rem;
}
.tagline {
  opacity: 0.85;
  margin-top: 0;
}

.table {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.row-label {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  opacity: 0.75;
}

.row {
  display: flex;
  gap: 0.4rem;
}

.card {
  flex: 1;
  aspect-ratio: 5 / 7;
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: 8px;
  border: 2px solid transparent;
  background: #f8faf9;
  color: #1a1a1a;
  cursor: default;
  transition: transform 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.suit-h,
.suit-d {
  color: #c2273b;
}

/* Suit letter badge: suits must never be color-only (spec §11.5). */
.card .suit-letter {
  display: block;
  font-size: 0.55rem;
  font-weight: 400;
  opacity: 0.7;
  letter-spacing: 0.05em;
}

/* Keyboard focus visibility (spec §11.5). */
.card:focus-visible,
.pair-tab:focus-visible,
.commit:focus-visible,
.redraw:focus-visible,
.shop-card:focus-visible,
.relic-icon:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid var(--neon);
  outline-offset: 2px;
}

.card.dimmed {
  opacity: 0.45;
}
.card.committed {
  border-color: var(--neon);
  transform: translateY(-6px);
  box-shadow: 0 4px 14px rgba(93, 242, 195, 0.35);
}

.pair-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin-top: 0.25rem;
}

.pair-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.4rem;
  border-radius: 8px;
  border: 1px solid rgba(238, 247, 242, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 0.95rem;
  cursor: pointer;
}

.pair-tab.selected {
  border-color: var(--neon);
  background: rgba(93, 242, 195, 0.12);
}
.pair-tab.best .pair-cat {
  color: var(--neon);
}
.pair-cat {
  font-size: 0.7rem;
  opacity: 0.8;
}

.score-line {
  font-size: 0.95rem;
  opacity: 0.9;
}

.hud {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.hud-score {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--neon);
}

.card.marked {
  border-color: #f2b25d;
  box-shadow: 0 4px 14px rgba(242, 178, 93, 0.35);
  transform: translateY(6px);
}

.actions {
  display: flex;
  gap: 0.5rem;
}

.actions .commit {
  flex: 2;
}

.redraw {
  flex: 1;
  padding: 0.8rem;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid rgba(238, 247, 242, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
}

.redraw:disabled {
  opacity: 0.4;
  cursor: default;
}

.last-score {
  font-size: 0.9rem;
  color: var(--neon);
}

.blind-result {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
}

.end-screen {
  align-items: center;
  text-align: center;
  padding-top: 3rem;
}

.commit {
  padding: 0.8rem;
  font-size: 1.05rem;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  background: var(--neon);
  color: #072a1f;
  cursor: pointer;
}

.play-log {
  font-size: 0.85rem;
  opacity: 0.85;
  padding-left: 1.2rem;
}

.all-combos {
  font-size: 0.8rem;
  opacity: 0.8;
}
.all-combos button {
  background: none;
  border: none;
  color: var(--neon);
  cursor: pointer;
  padding: 0.15rem 0;
  text-align: left;
}

@media (prefers-reduced-motion: reduce) {
  .card {
    transition: none;
  }
  .theater-total {
    animation: none;
  }
}

/* --- Boss banner --- */
.boss-banner {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: rgba(194, 39, 59, 0.15);
  border: 1px solid rgba(194, 39, 59, 0.45);
  font-size: 0.85rem;
}

.boss-banner.active {
  background: rgba(194, 39, 59, 0.3);
}

/* --- Relic row --- */
.relic-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.relic-icon {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(93, 242, 195, 0.5);
  background: rgba(93, 242, 195, 0.1);
  color: var(--ink);
  font-size: 0.75rem;
  cursor: pointer;
}

.relic-text {
  flex-basis: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 0.85rem;
}

.relic-text em {
  display: block;
  opacity: 0.75;
  margin-top: 0.25rem;
}

/* --- Score theater --- */
.theater {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(93, 242, 195, 0.4);
  background: rgba(0, 0, 0, 0.45);
  color: var(--ink);
  cursor: pointer;
  width: 100%;
}

.theater-steps {
  font-size: 0.8rem;
  opacity: 0.85;
  text-align: center;
}

.theater-eq {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 2rem;
  font-weight: 800;
}

.theater-chips {
  color: #7db8ff;
}

.theater-mult {
  color: #f27d5d;
}

.theater-total {
  color: var(--neon);
  animation: slam 0.3s ease;
}

.theater-hint {
  font-size: 0.7rem;
  opacity: 0.6;
}

@keyframes slam {
  0% {
    transform: scale(1.6);
  }
  100% {
    transform: scale(1);
  }
}

/* --- Shop --- */
.shop {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.shop-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem;
  min-height: 6.5rem;
  border-radius: 10px;
  border: 1px solid rgba(238, 247, 242, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}

.shop-card:disabled {
  opacity: 0.45;
  cursor: default;
}

.shop-card.sold {
  align-items: center;
  justify-content: center;
  opacity: 0.35;
}

.shop-text {
  font-size: 0.72rem;
  opacity: 0.8;
}

.price {
  margin-top: auto;
  color: var(--neon);
  font-weight: 700;
}

.pack {
  padding: 0.6rem;
  border-radius: 10px;
  border: 1px dashed rgba(93, 242, 195, 0.5);
}

.pack-head {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.pack-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.levels {
  font-size: 0.8rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.level-chip {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(125, 184, 255, 0.15);
  border: 1px solid rgba(125, 184, 255, 0.4);
}

.error {
  color: #ff8a8a;
  font-size: 0.85rem;
}

/* --- Title / tutorial --- */
.title-screen {
  gap: 0.75rem;
  padding-top: 1.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.field select {
  padding: 0.5rem;
  border-radius: 8px;
  background: #0a2e23;
  color: var(--ink);
  border: 1px solid rgba(238, 247, 242, 0.3);
}

.table-desc {
  font-size: 0.85rem;
  opacity: 0.8;
  margin: 0;
}

.tutorial-link {
  color: var(--neon);
  font-size: 0.9rem;
}

.tutorial .card.static {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tutorial-back {
  display: block;
  text-align: center;
  text-decoration: none;
}

.hidden-card {
  background: #123b4f;
  color: rgba(238, 247, 242, 0.5);
}

.replay-link {
  display: inline-block;
  text-decoration: none;
  text-align: center;
}

/* --- Collection --- */
.collection-section h3 {
  margin-bottom: 0.3rem;
}
.collection-section .dim {
  opacity: 0.6;
  font-weight: 400;
  font-size: 0.8rem;
}
.collection-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.collection-list li {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
}
.collection-list li.unseen {
  opacity: 0.4;
}

/* --- Voucher / sell row --- */
.voucher-card {
  border-style: dashed;
  border-color: rgba(242, 178, 93, 0.6);
  min-height: auto;
}
.sell-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  font-size: 0.85rem;
}

/* --- Cosmetics (earned by play; purely visual) --- */

.back-circuit .hidden-card {
  background: repeating-linear-gradient(45deg, #123b4f, #123b4f 6px, #1a5b78
    6px, #1a5b78 12px);
}

.back-gold .hidden-card {
  background: linear-gradient(135deg, #6b5310, #b8963a);
  color: rgba(0, 0, 0, 0.5);
}

/* --- Challenge seeds --- */
.challenge-row {
  display: flex;
  gap: 0.4rem;
}
.challenge-input {
  flex: 1;
  padding: 0.5rem;
  border-radius: 8px;
  background: #0a2e23;
  color: var(--ink);
  border: 1px solid rgba(238, 247, 242, 0.3);
}
