body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* the hidden attribute always wins, whatever display a rule sets */
[hidden] { display: none !important; }

#splash {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.8rem;
  background: radial-gradient(ellipse at 50% 25%, var(--felt) 0%, var(--felt-dark) 80%);
}

#splash[hidden] { display: none; }

#splash.done { animation: splashOut 0.55s ease forwards; }

.splashTiles {
  display: flex;
  gap: 0.22em;
  font-size: min(7.2vw, 5.5rem);
}

.splashTiles span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  aspect-ratio: 1;
  border-radius: 0.14em;
  background: linear-gradient(150deg, var(--tile-hi), var(--tile-lo));
  color: var(--tile-ink);
  font-weight: 800;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.75),
              inset 0 -0.08em 0.08em rgba(146, 105, 44, 0.5),
              0 0.12em 0.25em rgba(0, 0, 0, 0.45);
  opacity: 0;
  animation: splashDrop 0.55s cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}

.splashTiles span:nth-child(1) { animation-delay: 0.15s; --tilt: -2.5deg; }
.splashTiles span:nth-child(2) { animation-delay: 0.25s; --tilt: 1.5deg; }
.splashTiles span:nth-child(3) { animation-delay: 0.35s; --tilt: -1deg; }
.splashTiles span:nth-child(4) { animation-delay: 0.45s; --tilt: 2deg; }
.splashTiles span:nth-child(5) { animation-delay: 0.55s; --tilt: -1.5deg; }
.splashTiles span:nth-child(6) { animation-delay: 0.65s; --tilt: 1deg; }
.splashTiles span:nth-child(7) { animation-delay: 0.75s; --tilt: -2deg; }
.splashTiles span:nth-child(8) { animation-delay: 0.85s; --tilt: 2.5deg; }

@keyframes splashDrop {
  0% { opacity: 0; transform: translateY(-55vh) rotate(14deg) scale(1.2); }
  55% { opacity: 1; }
  100% { opacity: 1; transform: translateY(0) rotate(var(--tilt, 0deg)) scale(1); }
}

.splashSub {
  margin: 0;
  color: var(--muted);
  font-size: 1.15rem;
  letter-spacing: 0.1em;
  opacity: 0;
  animation: splashSubIn 0.7s ease 1.5s forwards;
}

@keyframes splashSubIn { to { opacity: 1; } }

@keyframes splashOut {
  to { opacity: 0; transform: scale(1.04); visibility: hidden; }
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 21rem 1.2rem 2.5rem;
}

/* every board control lives in this one cluster, all the same size */
#viewCtl {
  position: fixed;
  top: 1.35rem;
  right: 0.9rem;
  z-index: 6;
  display: flex;
  gap: 0.5rem;
}

#viewCtl[hidden] { display: none; }

#viewCtl button {
  width: 2.6rem;
  height: 2.6rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

body.cinema header,
body.cinema #playing aside { display: none; }

body.cinema #playing { padding: 0; gap: 0; }

body.cinema #grid { min-height: 100vh; }

body.cinema #viewCtl { opacity: 0.3; }

body.cinema #viewCtl:hover { opacity: 1; }

header { position: relative; z-index: 6; }

header .tileWord { font-size: 1.9rem; }

/* plain room code, centred over the whole header */
.code {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

#code[hidden] { display: none; }

body.cinema #turnBar { top: 1.35rem; }

#turnBar {
  position: fixed;
  top: 4.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.28);
  padding: 0.35em 1.1em;
  border-radius: 2em;
  pointer-events: none;
  white-space: nowrap;
}

#flash {
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
  white-space: nowrap;
}

#flash.show { animation: flash 3s ease-out; }

@keyframes flash {
  0% { opacity: 0; transform: translate(-50%, 12px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

main[hidden] { display: none; }

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4rem;
  padding: 2rem;
  flex-wrap: wrap;
}

.join { text-align: center; }

/* ---------- landing (the #welcome main becomes a real page) ---------- */

#welcome { display: block; width: 100%; padding: 0; }

.hero {
  position: relative;
  min-height: 96vh;
  margin-top: -6.4rem; /* the scene runs up behind the transparent header */
  padding-top: 6.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#heroScene { position: absolute; inset: 0; }

#heroScene canvas { display: block; width: 100%; height: 100%; }

.heroScrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%,
    rgba(10, 28, 48, 0.38) 0%, rgba(10, 28, 48, 0.8) 70%, var(--felt-dark) 100%);
}

.heroContent {
  position: relative;
  display: grid;
  gap: 1.25rem;
  justify-items: center;
  text-align: center;
  padding: 6rem 1.5rem 4rem;
  max-width: 48rem;
}

.kicker {
  margin: 0;
  letter-spacing: 0.35em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
}

.heroContent h2 {
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 4.3rem);
  line-height: 1.05;
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.6);
}

.heroContent .sub {
  margin: 0;
  color: #cfdeed;
  font-size: 1.18rem;
  line-height: 1.65;
  max-width: 34rem;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
}

.heroActions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.5rem;
}

#createBtn {
  font-size: 1.3rem;
  padding: 0.95em 2.3em;
  border-radius: 0.7em;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7),
              inset 0 -2px 2px rgba(146, 105, 44, 0.45),
              0 10px 34px rgba(255, 215, 94, 0.28);
}

#createBtn:hover {
  transform: translateY(-2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7),
              inset 0 -2px 2px rgba(146, 105, 44, 0.45),
              0 16px 44px rgba(255, 215, 94, 0.4);
}

.btnGhost {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.3rem;
  padding: 0.9em 2.1em;
  border-radius: 0.7em;
  border: 2px solid rgba(243, 236, 217, 0.4);
  color: var(--ink);
  text-decoration: none;
  background: rgba(0, 0, 0, 0.28);
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.btnGhost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-2px);
}

#playingNow {
  min-height: 1.6em;
  margin: 0;
  color: #7fe0a0;
  font-weight: 700;
}

#playingNow:not(:empty) {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 2em;
  padding: 0.45em 1.2em;
}

.landing {
  width: min(92vw, 62rem);
  margin: 0 auto;
  padding-top: 5rem;
  text-align: center;
}

.landing h3 { font-size: clamp(1.6rem, 3.4vw, 2.1rem); margin: 0 0 0.4rem; }

.landing .lead { color: var(--muted); margin: 0 auto 2.2rem; max-width: 38rem; }

.cards {
  display: grid;
  gap: 1.1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(243, 236, 217, 0.13);
  border-radius: 1rem;
  padding: 1.6rem 1.4rem;
  text-align: left;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 215, 94, 0.45);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

.card .icon { font-size: 1.9rem; line-height: 1; }

.card h4 { margin: 0.7rem 0 0.35rem; font-size: 1.08rem; }

.card p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.6; }

.stepCards { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); }

.step .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  aspect-ratio: 1;
  border-radius: 0.4rem;
  background: linear-gradient(150deg, var(--tile-hi), var(--tile-lo));
  color: var(--tile-ink);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75),
              inset 0 -2px 2px rgba(146, 105, 44, 0.5),
              0 3px 8px rgba(0, 0, 0, 0.4);
}

.faq {
  display: grid;
  gap: 0.7rem;
  max-width: 36rem;
  margin: 0 auto;
}

.faq details {
  text-align: left;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(243, 236, 217, 0.14);
  border-radius: 0.8rem;
  padding: 0.95rem 1.2rem;
  transition: border-color 0.25s ease;
}

.faq details[open] { border-color: rgba(255, 215, 94, 0.4); }

.faq summary { cursor: pointer; font-weight: 700; }

.faq details p { margin: 0.7rem 0 0; color: var(--muted); line-height: 1.6; }

.disclaimer {
  display: block;
  color: var(--muted);
  opacity: 0.65;
  font-size: 0.8rem;
  margin: 0 auto;
  padding: 4rem 0 2.5rem;
  max-width: 40rem;
}

/* scroll-in reveals */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  #createBtn, .btnGhost, .card { transition: none; }
}

#createBtn { font-size: 1.4rem; padding: 0.9em 2em; }

.linklike {
  background: none;
  box-shadow: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  font-weight: 400;
  padding: 0.4em;
  margin-top: 1.6rem;
}


#qr {
  background: #fff;
  padding: 14px;
  border-radius: 12px;
  border: 6px solid var(--tile-lo);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  width: min(38vh, 340px);
  margin: 0 auto;
}

#qr svg { display: block; width: 100%; height: auto; }

#joinHint {
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: underline;
}

/* a phone hosting the board: QR + join link only, seats live on /play */
@media (max-width: 700px) {
  #seatsCol { display: none; }
  #roomCode { font-size: 2.3rem; }
}
.hint { color: var(--muted); }

/* full-width row over both the QR and the seats, like the close row below */
#roomCode {
  width: 100%;
  text-align: center;
  font-size: 3.4rem;
  font-weight: 800;
  letter-spacing: 0.35em;
  margin: 0.5rem 0 -1.5rem -0.35em; /* left offset balances the tracking */
  color: var(--ink);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

#seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.9rem;
}

#seats li {
  width: min(70vw, 22rem);
  padding: 1.05rem 1.4rem;
  border-radius: 0.9rem;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

#seats li::before {
  content: '';
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  flex: none;
}

#seats li.empty {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(243, 236, 217, 0.14);
  color: var(--muted);
  font-weight: 400;
  font-size: 1.05rem;
}

#seats li.empty::before { background: currentColor; opacity: 0.35; }

#seats li.taken,
#seats li.away {
  background: var(--panel);
  color: var(--panel-ink);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

#seats li.taken::before { background: #3f9d63; }

#seats li.away { opacity: 0.55; }

#seats li.away::before { background: var(--tw); }

/* full-width child of the lobby flex row — wraps to its own centred line */
/* lobby columns hang from a shared top line under the code row */
#lobby { align-items: flex-start; align-content: center; }

#lobby #roomCode { align-self: center; }

.lobbyActions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin: 0.5rem 0 2.5rem;
}

/* creator's settings picker — a modal floating over the landing */
#setupModal {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(6, 18, 32, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#setupModal[hidden] { display: none; }

.modalCard {
  background: linear-gradient(170deg, #14324f, #0d2440);
  border: 1px solid rgba(243, 236, 217, 0.18);
  color: var(--ink);
  padding: 2.2rem 2.5rem;
  border-radius: 1.1rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  display: grid;
  gap: 1.3rem;
  justify-items: center;
  width: min(92vw, 26rem);
}

.modalCard h2 { margin: 0; }

.modalCard .seg { width: 100%; }

.seg {
  display: flex;
  border: 2px solid var(--tile-edge);
  border-radius: 0.6em;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.22);
}

.seg button {
  flex: 1;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  padding: 0.7em 0.4em;
}

.seg button.on {
  background: linear-gradient(160deg, var(--tile-hi), var(--tile-lo));
  color: var(--tile-ink);
}

#setupCreateBtn { font-size: 1.2rem; padding: 0.8em 2em; margin-top: 0.6rem; }

#playing { gap: 3rem; flex-wrap: nowrap; }

/* the stage holds both views; buttons swap which child shows */
#grid {
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 0;
  min-height: 76vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#grid canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#grid canvas[hidden],
#grid2d[hidden] { display: none; }

/* flat grid */
#grid2d {
  width: min(84vh, 58vw);
  font-size: min(3.2vh, 2.2vw);
}

#playing aside {
  background: var(--panel);
  color: var(--panel-ink);
  padding: 1.6rem 2rem;
  border-radius: 0.8rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: 19rem;
}

#playing aside h2 {
  margin: 0 0 0.8rem;
  border-bottom: 3px double var(--tile-edge);
  padding-bottom: 0.4rem;
}

#playerPanel {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  font-size: 1.25rem;
}

#playerPanel li {
  padding: 0.5rem 0.2rem;
  border-bottom: 1px dashed rgba(178, 142, 80, 0.5);
}

#playerPanel li.away { opacity: 0.5; }

#playerPanel li.turn { color: #8a423a; font-weight: 800; }

#playerPanel li.turn::after { content: ' ◀'; }

#bag, #lastMove { color: var(--panel-muted); margin: 0.4rem 0; }

#clock { font-size: 1.4rem; font-weight: 800; margin: 0.4rem 0; }

.winner {
  color: #8a423a;
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0.6rem 0 0;
}
