main {
  max-width: 26rem;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  display: flex;
  flex-direction: column;
}

section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: center;
}

section[hidden] { display: none; }

h1 { margin: 0 0 0.5rem; }

/* the join screen owns the viewport: everything centred, mid-page */
#joinStep {
  min-height: 82vh;
  justify-content: center;
  gap: 1.4rem;
}

#joinStep .tileWord { font-size: 1.55rem; margin: 0 0 1rem; }

#joinForm {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

#codeInput {
  width: 8ch;
  box-sizing: content-box; /* 8ch of glyphs plus padding, so ROOM fits */
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em; /* recentre: tracking pads only the right edge */
  text-transform: uppercase;
}

#codeInput:focus::placeholder { color: transparent; }

#name { font-size: 1.2rem; text-align: center; }

#seatList { display: grid; gap: 0.75rem; }

#seatList button, #startBtn, #rematchBtn {
  padding: 1em;
  font-size: 1.1rem;
}

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

#players li {
  background: var(--panel);
  color: var(--panel-ink);
  font-weight: 700;
  padding: 0.8em;
  border-radius: 0.5em;
  border-left: 0.4rem solid var(--tl);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.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);
}

#playingStep { gap: 0.9rem; }

#topRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

button.small { padding: 0.35em 0.8em; font-size: 0.85rem; }

#turnLine { margin: 0; color: var(--muted); font-weight: 600; }
#turnLine.yourTurn { color: var(--accent); font-weight: 800; }

#miniBoard, #specBoard { width: 100%; font-size: 3.4vw; }

#rack {
  display: flex;
  gap: 0.45rem;
  justify-content: center;
  align-items: flex-end;
  background: linear-gradient(var(--wood-hi), var(--wood-lo));
  border-radius: 0.5rem;
  padding: 0.6rem 0.5rem 0.45rem;
  min-height: 3.6rem;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.35),
              inset 0 -2px 0 rgba(255, 255, 255, 0.15),
              0 4px 10px rgba(0, 0, 0, 0.45);
}

.rackTile {
  position: relative;
  width: 11.5vw;
  max-width: 3.4rem;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.45rem;
  font-weight: 800;
  font-family: 'Trebuchet MS', 'Segoe UI', Verdana, sans-serif;
  border-radius: 14%;
  background: linear-gradient(150deg, var(--tile-hi), var(--tile-lo));
  color: var(--tile-ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75),
              inset 0 -3px 3px rgba(146, 105, 44, 0.5),
              0 2px 4px rgba(0, 0, 0, 0.5);
}

.rackTile.selected {
  outline: 3px solid var(--accent);
  transform: translateY(-6px);
}

.rackTile .v {
  position: absolute;
  right: 8%;
  bottom: 4%;
  font-size: 0.6rem;
  font-weight: 800;
}

.actions {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
}

.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }

#blankPicker {
  position: fixed;
  inset: 0;
  background: rgba(8, 28, 48, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  z-index: 10;
}

#blankPicker[hidden] { display: none; }

#blankLetters {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
  padding: 0 1rem;
  max-width: 22rem;
}

#blankLetters button {
  aspect-ratio: 1;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 800;
  border-radius: 14%;
}

#scoresOverlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 28, 48, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  z-index: 10;
}

#scoresOverlay[hidden] { display: none; }

#scoresList {
  list-style: none;
  margin: 0;
  padding: 1rem 1.2rem;
  width: min(100%, 20rem);
  display: grid;
  gap: 0.6rem;
  background: var(--panel);
  color: var(--panel-ink);
  font-weight: 700;
  border-radius: 0.7rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

#scoresList li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px dashed rgba(178, 142, 80, 0.5);
  padding-bottom: 0.4rem;
}

#scoresList li:last-child { border-bottom: 0; padding-bottom: 0; }

#pauseVoteBar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: var(--panel);
  color: var(--panel-ink);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.6em 0.9em;
  border-radius: 0.6rem;
  border-left: 0.4rem solid var(--accent);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

#pauseVoteBar[hidden] { display: none; }

#pausedOverlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 28, 48, 0.94);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  z-index: 10;
}

#pausedOverlay[hidden] { display: none; }

#turnFlash {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 15;
  animation: turnpop 1.6s ease-out;
}

#turnFlash[hidden] { display: none; }

@keyframes turnpop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

#finalScores {
  margin: 0;
  padding: 1rem 1rem 1rem 2.6em;
  text-align: left;
  display: grid;
  gap: 0.5rem;
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 0.7rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
