/* LEARN(css): The design is built on "design tokens" — named values declared
   once on :root as custom properties and reused everywhere. Change --felt or
   --rust here and the whole app follows. The rust accent is sampled from the
   card-back pattern, so the palette is cohesive by construction. */

:root {
  /* the room */
  --paper: #f1efe7;      /* sage-tinted paper, the quiet backdrop */
  --ink: #262420;        /* warm near-black for text */
  --muted: #767061;      /* secondary text */
  --line: #dcd8ca;       /* hairline borders on paper */

  /* the table */
  --felt: #2b6e54;       /* felt green, center */
  --felt-deep: #1e5340;  /* felt green, edges */
  --felt-rim: #16382c;   /* the wooden-dark rim around the felt */
  --on-felt: #e8efe9;    /* text placed on the felt */
  --on-felt-dim: rgba(232, 239, 233, 0.66);

  /* the cards */
  --card-face: #fbf8f1;  /* paper-white card front */
  --card-ink: #4e3c13;   /* card value color (kept from the original tool) */

  /* actions */
  --rust: #bf4f28;       /* primary action — matches the card back */
  --rust-deep: #9e3d1c;

  --radius-card: 12px;
  --shadow-card: 0 6px 16px rgba(12, 34, 24, 0.35);
  --shadow-soft: 0 2px 10px rgba(38, 36, 32, 0.08);
}

* {
  box-sizing: border-box;
}

/* LEARN(css): The HTML `hidden` attribute only works through a low-priority
   browser default (display: none). Any of our own display rules would silently
   override it. This rule makes `hidden` always win — the JavaScript relies on
   it to switch between the join view and the game view. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: "Karla", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* LEARN(css): :focus-visible fires for keyboard focus but not mouse clicks —
   so tab-navigation gets a clear ring without flashing one on every click. */
:focus {
  outline: none;
}
:focus-visible {
  /* LEARN(css): outline follows the element's own border-radius in modern
     browsers, so pills get pill-shaped rings automatically. */
  outline: 3px solid var(--rust);
  outline-offset: 2px;
}

/* --- type roles --- */

.display {
  font-family: "Young Serif", serif;
  font-weight: 400;
}

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

/* --- top bar --- */

.topbar {
  max-width: 1060px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--ink);
}

/* The mark: two tiny fanned cards, one showing the pattern, one a face.
   Pure CSS — no image file needed beyond the pattern data-URL below. */
.mark {
  /* LEARN(css): A <span> is display:inline by default, and inline elements
     ignore width/height — without this line the mark collapses to nothing
     and its absolutely-positioned card children float over the neighbors. */
  display: inline-block;
  position: relative;
  width: 34px;
  height: 34px;
  flex: none;
}

.mark i {
  position: absolute;
  width: 22px;
  height: 30px;
  border-radius: 4px;
  border: 1.5px solid rgba(38, 36, 32, 0.25);
}

.mark i:first-child {
  left: 0;
  top: 2px;
  transform: rotate(-10deg);
  background-image: var(--cardback);
  background-size: 26px;
}

.mark i:last-child {
  left: 11px;
  top: 0;
  transform: rotate(7deg);
  background: var(--card-face);
}

.mark i:last-child::after {
  content: "?";
  font-family: "Young Serif", serif;
  font-size: 0.85rem;
  color: var(--rust);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.wordmark-text {
  font-family: "Young Serif", serif;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
}

.wordmark-text b {
  color: var(--rust);
  font-weight: 400; /* Young Serif has one weight; the color does the work */
}

.room-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.room-name {
  color: var(--muted);
  font-size: 0.95rem;
}

.room-name b {
  color: var(--ink);
}

.quiet-link {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.quiet-link:hover {
  color: var(--ink);
}

/* --- buttons --- */

.btn {
  display: inline-block;
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.6rem 1.4rem;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

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

.btn-primary {
  background-color: var(--rust);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--rust-deep);
}

/* a quieter button for secondary actions that live on the felt */
.btn-felt {
  background: rgba(255, 255, 255, 0.14);
  color: var(--on-felt);
}

.btn-felt:hover {
  background: rgba(255, 255, 255, 0.24);
}

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--ink);
  font-weight: 700;
  border-radius: 999px;
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
}

.btn-ghost:hover {
  border-color: var(--muted);
}

main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

/* --- the felt table: the shared, authoritative game state made visible --- */

.table {
  position: relative;
  margin-top: 0.9rem;
  border-radius: 34px;
  padding: 2.5rem 2rem 2.2rem;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.6rem;

  /* LEARN(css): Three layered backgrounds — a radial gradient lights the felt
     from the center like a lamp over a real table; the rim is a thick border;
     the inset shadows give the surface depth. */
  background: radial-gradient(ellipse at 50% 30%, var(--felt) 0%, var(--felt-deep) 78%);
  border: 10px solid var(--felt-rim);
  box-shadow:
    inset 0 2px 18px rgba(0, 0, 0, 0.35),
    0 14px 30px -18px rgba(22, 56, 44, 0.55);
}

/* the "rail" line marked on real tables */
.table::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  pointer-events: none;
}

/* --- player cards on the table --- */

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.4rem 1.6rem;
}

.card-list li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  /* LEARN(css): perspective makes children's 3D rotations (the card flip)
     actually look 3D instead of just squashing flat. */
  perspective: 700px;
}

.card-box {
  width: 108px;
  height: 152px; /* real playing-card ratio, 2.5 x 3.5 */
  border-radius: var(--radius-card);
  display: grid;
  place-items: center;
}

/* face-down: the patterned back, shared with the original tool */
:root {
  --cardback: url("data:image/gif;base64,R0lGODlhJAAkAJEAAOjFsezdztOKbL5QKCH5BAAAAAAALAAAAAAkACQAAAL/HC4RAqm/mmLHyHmAbczB11Ea8ombJKSgKo6Z17pXFznmS1JptiX0z3vVhpEKDoUIkoa0olGIUeZUk1RI6Yn2mh/FDAt6frOrRRTqXPpsVLYugzxaVy+YcBdnoWPZOT0E4eckQtZFZBjWoHixQFWl6Nhol6R2p1Okt5TGaEWZA6fjiMdhZgPHeWrTWGVq+jTZg1HYyAEWKLYzmyiGKoUimilz+YYryyTlg5RcDJSAbNx0Q7lMcbIGEyzTK8zVdfVaImzs/QV+prYqWWW2ObkoOApM/Em/rUlIm7fijs8a2EEKEaZ3AsMUgneEU6RcpJbZ27aGHkAO2Ors8xQH1IR0Bn5YnOtVAAA7");
}

.card-box.face-down {
  background-image: var(--cardback);
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-card);
}

/* face-up: paper card, big Young Serif value */
.card-box.face-up {
  background: var(--card-face);
  color: var(--card-ink);
  font-family: "Young Serif", serif;
  font-size: 2.6rem;
  box-shadow: var(--shadow-card);
}

/* no card yet: an outlined "seat" marked on the felt, not a card */
.card-box.seat {
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.38);
  color: var(--on-felt-dim);
  font-size: 0.85rem;
  box-shadow: none;
}

.card-label {
  color: var(--on-felt);
  font-size: 0.95rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.card-list li.you .card-label {
  font-weight: 800;
}

/* --- the reveal: the one orchestrated animation in the app --- */

/* LEARN(css): The JS adds .just-revealed to the list only on the moment the
   round flips from hidden to revealed, and sets --i per card. Each card plays
   a one-shot 3D flip, staggered by its index — a wave of cards turning over. */
.just-revealed .card-box.face-up {
  animation: flip-in 0.45s calc(var(--i) * 90ms) both ease-out;
}

@keyframes flip-in {
  from { transform: rotateY(88deg); }
  to   { transform: rotateY(0); }
}

/* a small settle when your card lands face-down on the felt */
.just-played .card-box.face-down {
  animation: settle 0.3s ease-out;
}

@keyframes settle {
  from { transform: translateY(-14px) scale(1.05); }
  to   { transform: translateY(0) scale(1); }
}

/* LEARN(css): Some people get motion-sick from animation. The OS exposes
   their preference, and this media query turns the show off for them. */
@media (prefers-reduced-motion: reduce) {
  .just-revealed .card-box.face-up,
  .just-played .card-box.face-down {
    animation: none;
  }
  .btn,
  .hand-card {
    transition: none;
  }
}

/* --- center of the table: status, controls, results --- */

.table-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  text-align: center;
}

.table-empty {
  color: var(--on-felt-dim);
  margin: 0;
  font-size: 1.05rem;
}

.vote-count {
  color: var(--on-felt-dim);
  font-size: 0.9rem;
  margin: 0;
}

.controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.results {
  color: var(--on-felt);
  margin: 0;
}

.results .headline {
  font-family: "Young Serif", serif;
  font-size: 1.9rem;
  display: block;
}

.results .detail {
  color: var(--on-felt-dim);
  font-size: 0.9rem;
}

.results.consensus .headline {
  animation: consensus-pop 0.45s ease-out;
}

@keyframes consensus-pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .results.consensus .headline {
    animation: none;
  }
}

/* --- below the table: joining, or your hand --- */

.below-table {
  margin-top: 2rem;
  text-align: center;
}

.join-title {
  font-family: "Young Serif", serif;
  font-size: 1.5rem;
  margin: 0 0 0.25rem;
}

.join-sub {
  color: var(--muted);
  margin: 0 0 1.1rem;
}

/* the quiet "or with a different name" line between the two ways in */
.or-divider {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0.9rem 0 0.7rem;
}

.inline-form {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  flex-wrap: wrap;
}

input[type="text"] {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  width: min(340px, 75vw);
}

input[type="text"]:focus {
  border-color: var(--rust);
}

/* --- your hand: a row of small pickable cards --- */

.hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.hand-card {
  width: 62px;
  height: 88px;
  border-radius: 9px;
  border: 2px solid var(--line);
  background: var(--card-face);
  color: var(--card-ink);
  font-family: "Young Serif", serif;
  font-size: 1.35rem;
  box-shadow: var(--shadow-soft);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.hand-card:hover {
  transform: translateY(-6px) rotate(-2deg);
  box-shadow: 0 10px 18px rgba(38, 36, 32, 0.16);
}

/* your current pick stays lifted and turns rust — unmissable */
.hand-card.selected-card {
  background: var(--rust);
  border-color: var(--rust-deep);
  color: #fff;
  transform: translateY(-9px);
  box-shadow: 0 12px 20px rgba(158, 61, 28, 0.35);
}

.identity {
  margin-top: 1.4rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.identity button {
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.identity button:hover {
  color: var(--ink);
}

/* --- connection warning --- */

.alert {
  max-width: 460px;
  margin: 1.5rem auto 0;
  padding: 0.8rem 1.2rem;
  text-align: center;
  border-radius: 12px;
  color: #7a5a1e;
  background-color: #f8ecd2;
  border: 1.5px solid #e7d5a8;
}

/* --- landing page --- */

.hero {
  text-align: center;
  padding-top: 11vh;
}

.hero .mark {
  /* scale() doesn't change the layout box, so grow upward from the bottom
     edge to keep the enlarged mark from overlapping the title below it */
  transform: scale(2.2);
  transform-origin: bottom center;
  margin-bottom: 1.4rem;
}

.hero-title {
  font-family: "Young Serif", serif;
  font-size: clamp(2.6rem, 7vw, 4.2rem);
  margin: 0;
  line-height: 1.1;
}

.hero-title b {
  color: var(--rust);
  font-weight: 400;
}

.hero-tagline {
  margin: 0.6rem 0 2.4rem;
}

.hero-hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 1rem;
}

/* --- recent tables: little felt chips, one per remembered room --- */

.recents {
  margin-top: 2.4rem;
}

.recent-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

/* Each chip is a sliver of table felt: the room name jumps in, the × forgets.
   Two buttons share one pill — see landing.js for why they're siblings. */
.recent-chip {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--felt) 0%, var(--felt-deep) 100%);
  box-shadow: 0 2px 8px rgba(22, 56, 44, 0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.recent-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 12px rgba(22, 56, 44, 0.35);
}

.recent-chip button {
  background: none;
  border: none;
  color: var(--on-felt);
  font-size: 0.95rem;
}

.recent-go {
  font-weight: 700;
  padding: 0.5rem 0.3rem 0.5rem 1.1rem;
}

.recent-forget {
  color: var(--on-felt-dim);
  padding: 0.5rem 0.85rem 0.5rem 0.4rem;
  line-height: 1;
}

.recent-forget:hover {
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .recent-chip {
    transition: none;
  }
}

/* the table's edge peeking in at the bottom of the landing page */
.horizon {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 110px;
  background: radial-gradient(ellipse at 50% 100%, var(--felt) 0%, var(--felt-deep) 80%);
  border-top: 8px solid var(--felt-rim);
  z-index: -1;
}

.horizon i {
  position: absolute;
  width: 64px;
  height: 90px;
  border-radius: 9px;
  background-image: var(--cardback);
  border: 2.5px solid rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-card);
}

.horizon i:nth-child(1) { left: 18%; bottom: -30px; transform: rotate(-9deg); }
.horizon i:nth-child(2) { left: 50%; bottom: -20px; transform: rotate(4deg); }
.horizon i:nth-child(3) { right: 16%; bottom: -34px; transform: rotate(12deg); }

/* --- small screens --- */

@media (max-width: 640px) {
  .table {
    padding: 1.6rem 1rem;
    border-radius: 24px;
    border-width: 7px;
    min-height: 300px;
  }
  .table::before {
    inset: 9px;
    border-radius: 15px;
  }
  .card-box {
    width: 82px;
    height: 116px;
  }
  .card-box.face-up {
    font-size: 2rem;
  }
  .hand-card {
    width: 54px;
    height: 78px;
  }
}
