:root {
  --card-back: #2563eb;
  --card-back-stripe: #1d4ed8;
  --card-back-glow: rgba(15, 40, 120, 1);
  --board-bg: radial-gradient(ellipse at 50% 40%, #1e6b35, #0a2e14 70%, #061a0b);
  --board-overlay: none;
  --hud-bg: rgba(0, 0, 0, 0.2);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Segoe UI", Arial, sans-serif;
  background: #0a0a0a;
  /* No pull-to-refresh or rubber-band bounce on swipes (mobile) */
  overscroll-behavior: none;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Track the *visible* viewport on phones: stays correct while the browser
   URL bar shows/hides, so the layout doesn't jump mid-gesture */
@supports (height: 100dvh) {
  #game-container {
    height: 100dvh;
  }
}

/* ── Game Board ── */
#game-board {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--board-bg);
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
  position: relative;
  isolation: isolate;
}

#game-board::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--board-overlay);
  pointer-events: none;
  z-index: 0;
}

/* Aces theme: background image via ::after, rotated in landscape */
#game-board[data-theme="aces"]::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  background: url("/assets/background/inferno.webp") center/cover no-repeat;
  pointer-events: none;
  z-index: -1;
}

@media (orientation: landscape) {
  #game-board[data-theme="aces"]::after {
    width: 100vh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

/* ── Tableau ── */
.tableau {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 0 0;
  min-height: 0;
  position: relative;
  z-index: 1;
}

.tableau-row {
  display: flex;
  justify-content: center;
  margin-top: -68px;
}

.tableau-row:first-child {
  margin-top: 0;
}

.tableau-row.tableau-row-gap {
  margin-top: 10px;
}

/* ── Layered tableau (stacked layers via CSS grid) ── */
.tableau.tableau-layered {
  display: grid;
}

.tableau-layer {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.tableau-layer .card {
  pointer-events: auto;
}

.tableau-layer.tableau-layer-offset {
  transform: translateY(-53px);
}

/* ── Card ── */
.card {
  width: 60px;
  height: 86px;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
  margin: 0 4px;
  perspective: 400px;
  flex-shrink: 0;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
  pointer-events: none;
}

.card.face-down {
  pointer-events: none;
}

.card.face-down .card-inner {
  transform: rotateY(180deg);
}

.card-face,
.card-back {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.card-face {
  background: #ffffff;
  border: 1px solid #d1d5db;
  box-shadow: 0 0 4px 1px rgba(0,0,0,0.4), 2px 2px 4px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-back {
  background: var(--card-back);
  border: 1px solid #ffffff;
  box-shadow: 0 0 4px 1px var(--card-back-glow), 1px 1px 3px rgba(0,0,0,0.2);
  transform: rotateY(180deg);
  overflow: hidden;
}

.card-back::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    var(--card-back-stripe) 3px,
    var(--card-back-stripe) 4px
  ), repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    var(--card-back-stripe) 3px,
    var(--card-back-stripe) 4px
  );
}

/* Card corners */
.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  font-size: 15px;
  font-weight: bold;
  font-family: 'Times New Roman', Times, serif;
  pointer-events: none;
}

.corner .suit {
  font-size: 17px;
  font-weight: normal;
}

.corner.top-left {
  top: 3px;
  left: 4px;
}

.corner.top-right {
  top: 3px;
  right: 4px;
}

.corner.bottom-left {
  bottom: 3px;
  left: 4px;
  transform: rotate(180deg);
}

.corner.bottom-right {
  bottom: 3px;
  right: 4px;
  transform: rotate(180deg);
}

.center-value {
  font-size: 44px;
  font-weight: bold;
  font-family: 'Times New Roman', Times, serif;
  pointer-events: none;
}

.card.red .corner,
.card.red .center-value {
  color: #e74c3c;
}

.card.black .corner,
.card.black .center-value {
  color: #2c3e50;
}

/* Playable highlight (learn mode) */
.card.playable {
  z-index: 10;
  filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.7));
}

.card.playable > .card-inner {
  animation: playable-pulse 1.2s ease-in-out infinite;
}

.card.playable .card-face {
  background: #fff0b3;
}

@keyframes playable-pulse {
  0%, 100% { transform: translateY(-3px) scale(1.03); }
  50% { transform: translateY(-5px) scale(1.05); }
}

/* Priority highlight — playable cards that block others */
.card.playable-priority {
  z-index: 11;
  filter: drop-shadow(0 0 8px rgba(251, 100, 36, 0.8));
}

.card.playable-priority > .card-inner {
  animation: priority-pulse 1s ease-in-out infinite;
}

.card.playable-priority .card-face {
  background: #ffe0b2;
}

@keyframes priority-pulse {
  0%, 100% { transform: translateY(-4px) scale(1.04); }
  50% { transform: translateY(-6px) scale(1.06); }
}

/* Pressed state for interactive cards — scale inner to preserve hit area */
.card.can-play:active > .card-inner,
.card.can-play.pressed > .card-inner {
  transform: scale(0.93);
}

.pile-stock:active,
.pile-stock.pressed {
  transform: scale(0.93);
}

/* Card dealing animation */
.card.dealing {
  opacity: 0;
  transform: translateY(-120px);
}

.card.deal-in {
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
  opacity: 1;
  transform: translateY(0);
}

/* Card removal animation (played to pile) — instant hide, clone flies */
.card.removing {
  opacity: 0;
  pointer-events: none;
}

/* Col-gap spacer for split layouts */
.card.card-spacer {
  visibility: hidden;
  pointer-events: none;
}

.card-spacer-narrow {
  width: 35px;
  flex-shrink: 0;
}

/* Flying clone overlay */
.card-flying {
  position: absolute;
  z-index: 50;
  pointer-events: none;
  transition: transform 0.28s ease-in-out;
  will-change: transform;
}

/* After removal animation: invisible spacer preserving layout */
.card.removed {
  visibility: hidden;
  pointer-events: none;
}

/* No moves left — remaining cards are locked */
.card.locked {
  opacity: 0.35;
  filter: grayscale(0.8);
  pointer-events: none;
  transition: opacity 0.4s ease-out, filter 0.4s ease-out;
}

/* ── Piles Row ── */
.piles-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 96px;
  padding: 12px 24px 8px;
  background: var(--hud-bg);
  border-radius: 16px;
  margin: 0 auto 8px;
}

.piles-area {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.pile-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pile {
  width: 60px;
  height: 86px;
  border-radius: 8px;
  border: 2px dashed rgba(255,255,255,0.3);
  position: relative;
  cursor: pointer;
}

.pile .card {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
  cursor: default;
}

.pile-stock {
  cursor: pointer;
}

.pile-stock.stock-empty {
  cursor: default;
  pointer-events: none;
}

.stock-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 28px;
  opacity: 0.35;
}

.pile-stock .card {
  cursor: pointer;
}
.pile-stock .card .card-back {
  box-shadow: 0 0 4px 1px rgba(15, 40, 120, 0.7), 1px 1px 2px rgba(0,0,0,0.15);
}

.pile-label {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  text-align: center;
  letter-spacing: 0.5px;
}

/* Stock pile stacking effect */
.pile-stock .card:nth-child(1) {
  top: -4px;
  left: -4px;
}
.pile-stock .card:nth-child(2) {
  top: -2px;
  left: -2px;
}

.stock-count {
  position: absolute;
  top: 0;
  left: 0;
  right: -4px;
  bottom: -4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  z-index: 5;
  pointer-events: none;
}

.stock-count::after {
  content: attr(data-count);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2em;
  height: 2em;
  padding: 0 0.3em;
  border-radius: 999px;
  border: 2px solid rgba(251, 191, 36, 0.5);
  background: rgba(0, 0, 0, 0.6);
  color: #fbbf24;
  font-size: inherit;
  font-weight: inherit;
  line-height: 1;
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4), inset 0 0 4px rgba(251, 191, 36, 0.15);
}

/* Pile2 inactive state */
.pile.pile2-inactive .card {
  opacity: 0.4;
}

/* Pile2 fly animation */
.pile2-fly {
  position: absolute;
  z-index: 50;
  transition: transform 0.25s ease-out, opacity 0.25s ease-out;
}

/* ── Donut Timer ── */
.donut-timer {
  position: relative;
  width: 60px;
  height: 60px;
}

.donut-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: rgba(0,0,0,0.3);
  stroke-width: 3;
}

.donut-fill {
  fill: none;
  stroke: #4ade80;
  stroke-width: 3;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear, stroke 0.5s;
}

.donut-fill.warning {
  stroke: #fbbf24;
}

.donut-fill.critical {
  stroke: #ef4444;
}

.donut-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  pointer-events: none;
}

/* ── HUD info areas ── */
.hud-info-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.55);
  line-height: 1;
}

.hud-left {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 64px;
  justify-self: end;
}

.hud-right {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 64px;
  justify-self: start;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.hud-stat .hud-score-value,
.hud-stat .hud-level-value {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-level-value {
  font-size: 20px;
  font-weight: 700;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 5ch;
  text-align: center;
}

.hud-score-value {
  font-size: 20px;
  font-weight: 700;
  color: #4ade80;
  font-variant-numeric: tabular-nums;
  min-width: 10ch;
  text-align: center;
}

/* ── Streak Donut ── */
.donut-streak {
  position: relative;
  width: 56px;
  height: 56px;
}

.streak-fill {
  fill: none;
  stroke: rgba(255,255,255,0.3);
  stroke-width: 3;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s ease-out, stroke 0.3s;
}

.streak-fill.active {
  stroke: #fb923c;
}

.streak-fill.hot {
  stroke: #fbbf24;
}

.streak-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

/* ── Pause/Menu Button ── */
.board-actions {
  position: absolute;
  top: calc(24px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.board-action {
  display: flex;
  align-items: center;
  gap: 6px;
}

.board-action-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.board-actions button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.board-actions button:hover {
  color: #fff;
  background: rgba(255,255,255,0.2);
}

.btn-skip {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  z-index: 10;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-skip:hover {
  color: #fff;
  background: rgba(255,255,255,0.2);
}

.level-jumps {
  position: absolute;
  top: calc(24px + env(safe-area-inset-top));
  left: 4px;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 76px;
}

.btn-jump {
  padding: 5px 0;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
}

.btn-jump:hover {
  color: #fff;
  background: rgba(255,255,255,0.2);
}

/* ── Score Popups ── */
.score-popups {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.score-popup {
  position: absolute;
  font-weight: bold;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(0,0,0,0.7), 0 0 12px rgba(0,0,0,0.5);
  animation: popupFloat 1s ease-out forwards;
  white-space: nowrap;
}

@keyframes popupFloat {
  0% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-40px);
  }
}

.score-popup.penalty {
  animation: popupFloat 1.2s ease-out forwards;
}

.card.misplay-shake,
.card-inner.misplay-shake {
  animation: cardShake 0.3s ease-out;
}

@keyframes cardShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(2.5px); }
  60% { transform: translateX(-1.5px); }
  80% { transform: translateX(1px); }
}

/* ── Level Banner ── */
.level-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  z-index: 30;
  pointer-events: none;
  animation: bannerIn 0.4s ease-out;
}

@keyframes bannerIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* ── Countdown Number ── */
.countdown-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,0.6), 0 0 40px rgba(239,68,68,0.4);
  z-index: 25;
  pointer-events: none;
  opacity: 0;
  animation: countdownPulse 0.9s ease-out forwards;
}

@keyframes countdownPulse {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.5);
  }
  15% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  70% {
    opacity: 0.5;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
  }
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease;
  padding: 12px 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Menu Header ── */
.menu-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top));
  z-index: 10;
}

.menu-header-logo {
  font-size: 15px;
  font-weight: 700;
  color: #a5b4fc;
  letter-spacing: 0.5px;
}

.menu-header-right {
  display: flex;
  align-items: center;
}

.menu-header-signin {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ccc;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.menu-header-signin:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.menu-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a5b4fc;
  font-size: 16px;
  font-weight: 700;
  transition: border-color 0.2s;
}

.menu-header-avatar:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.menu-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Avatar Dropdown ── */
.avatar-dropdown {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px 0;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.avatar-dropdown-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.avatar-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.avatar-dropdown-item:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Main Menu Full Page ── */
.main-menu-page {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #0f172a, #1e293b);
  display: flex;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  /* Scroll instead of clipping when content is taller than a phone screen,
     without chaining the scroll into the browser's pull-to-refresh */
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.main-menu-content .menu-buttons:not(.row) {
  max-width: 280px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.main-menu-content {
  max-width: 500px;
  width: 100%;
  text-align: center;
  color: #fff;
  display: flex;
  flex-direction: column;
  /* Vertically centered when it fits; scrolls without clipping when it doesn't */
  margin-top: auto;
  margin-bottom: auto;
}

.main-menu-content h1 {
  font-size: 32px;
  margin-bottom: 4px;
  color: #a5b4fc;
}

.main-menu-content h2 {
  font-size: 24px;
  margin-bottom: 16px;
  color: #a5b4fc;
}

/* Settings */
.settings-list {
  margin: 16px 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  margin-bottom: 8px;
}

.settings-label {
  font-size: 16px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  background: #475569;
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 50%;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transform: translateY(-50%);
  transition: left 0.2s;
}

.toggle-switch input:checked + .toggle-track {
  background: #4f46e5;
}

.toggle-switch input:checked + .toggle-track .toggle-thumb {
  left: 23px;
}

/* Card back picker */
.card-back-picker {
  display: flex;
  align-items: center;
  gap: 24px;
}

.card-preview {
  width: 57px;
  height: 82px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #fff;
  flex-shrink: 0;
}

.card-preview-inner {
  width: 100%;
  height: 100%;
  background: var(--card-back);
  position: relative;
}

.card-preview-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    var(--card-back-stripe) 3px,
    var(--card-back-stripe) 4px
  ), repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    var(--card-back-stripe) 3px,
    var(--card-back-stripe) 4px
  );
}

/* Color swatches */
.color-swatches {
  display: grid;
  grid-template-columns: repeat(4, 36px);
  gap: 10px;
}

.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
  padding: 0;
  outline: none;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: #fff;
}

/* Theme buttons */
.theme-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-btn {
  padding: 8px 12px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #334155;
  color: rgba(255,255,255,0.7);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.theme-btn:hover {
  background: #475569;
  color: #fff;
}

.theme-btn.active {
  border-color: #a5b4fc;
  color: #fff;
}

.menu {
  background: #1e293b;
  border-radius: 16px;
  padding: 20px 24px;
  max-width: 420px;
  width: 90%;
  max-height: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.menu h1 {
  font-size: 32px;
  margin-bottom: 4px;
  color: #a5b4fc;
}

.menu h2 {
  font-size: 24px;
  margin-bottom: 16px;
  color: #a5b4fc;
}

.subtitle {
  color: rgba(255,255,255,0.6);
  margin-bottom: 12px;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  flex-shrink: 0;
}

.menu-buttons.row {
  flex-direction: row;
  gap: 20px;
}

.btn {
  display: block;
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #4f46e5;
  color: #fff;
}

.btn-primary:hover {
  background: #4338ca;
}

.btn-secondary {
  background: #334155;
  color: #cbd5e1;
}

.btn-secondary:hover {
  background: #475569;
  color: #fff;
}

/* Rules */
.rules {
  margin-top: 24px;
  text-align: left;
  background: rgba(0,0,0,0.2);
  border-radius: 10px;
  padding: 16px;
  overflow-y: auto;
  flex-shrink: 1;
  min-height: 0;
}

.rules h3 {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 8px;
}

.rules ul {
  padding-left: 18px;
}

.rules li {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 4px;
  line-height: 1.4;
}

/* Level select grid */
.level-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.btn-level {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #334155;
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
}

.btn-level:hover {
  background: #475569;
  transform: translateY(-1px);
}

.level-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #22c55e;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.level-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
}

.level-time {
  font-size: 12px;
  color: #94a3b8;
}

/* Level result */
.result-details {
  text-align: left;
  margin: 16px 0;
  overflow-y: auto;
  flex-shrink: 1;
  min-height: 0;
  padding-right: 8px;
}

.level-result .result-details {
  text-align: left;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
}

.level-result .result-row.grand-total {
  grid-column: 1 / -1;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
  color: rgba(255,255,255,0.7);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.result-row.bonus {
  color: #fbbf24;
}

.result-row.total {
  font-weight: 700;
  color: #fff;
  font-size: 16px;
  border-top: 1px solid rgba(255,255,255,0.15);
  padding-top: 10px;
  margin-top: 4px;
}

.result-row.grand-total {
  font-weight: 700;
  color: #a5b4fc;
  font-size: 18px;
  border-top: 2px solid rgba(165, 180, 252, 0.3);
  padding-top: 10px;
  margin-top: 4px;
}

.result-row.empty {
  color: rgba(255,255,255,0.25);
}

.menu.high-scores h2,
.main-menu-content.high-scores h2 {
  margin-bottom: 8px;
}

.menu.high-scores .result-details,
.main-menu-content.high-scores .result-details {
  margin: 4px 0;
}

.menu.high-scores .result-row,
.main-menu-content.high-scores .result-row {
  padding: 3px 0;
}

.menu.high-scores .menu-buttons,
.main-menu-content.high-scores .menu-buttons {
  margin-top: 12px;
}

/* ── High Scores Tabs ── */
.hs-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}

.hs-tab {
  flex: 1;
  padding: 6px 0;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.hs-tab:not(:last-child) {
  border-right: 1px solid rgba(255,255,255,0.15);
}

.hs-tab.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.hs-tab:hover:not(.active) {
  background: rgba(255,255,255,0.1);
}

/* ── Leaderboards ── */
.main-menu-content.leaderboards {
  max-width: 440px;
}

.main-menu-content.leaderboards h2 {
  margin-bottom: 10px;
}

.lb-filters {
  margin-bottom: 12px;
}

.lb-period-tabs {
  flex-wrap: wrap;
}

.lb-period-tabs .hs-tab {
  padding: 5px 0;
  font-size: 12px;
}

.lb-list {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
}

.lb-loading, .lb-empty {
  text-align: center;
  color: rgba(255,255,255,0.4);
  padding: 32px 0;
  font-size: 14px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  font-size: 13px;
}

.lb-row:nth-child(odd) {
  background: rgba(255,255,255,0.07);
}

.lb-row.lb-me {
  background: rgba(79, 70, 229, 0.2);
  border: 1px solid rgba(79, 70, 229, 0.4);
}

.lb-rank {
  width: 24px;
  text-align: center;
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  flex-shrink: 0;
}

.lb-rank-1 .lb-rank { color: #fbbf24; }
.lb-rank-2 .lb-rank { color: #d1d5db; }
.lb-rank-3 .lb-rank { color: #d97706; }

.lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
  font-size: 14px;
}

.lb-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.lb-avatar-emoji {
  font-size: 16px;
  line-height: 1;
}

.lb-avatar-initial {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
}

.lb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,0.9);
}

.lb-stat {
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  flex-shrink: 0;
}

.lb-score {
  font-weight: 700;
  color: #a5b4fc;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 60px;
  text-align: right;
}

/* ── Key Card / Lock Mechanic ── */
.card-locked {
  pointer-events: auto;
}

.card-locked .card-inner {
  transform: rotateY(180deg);
}

.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  z-index: 10;
  pointer-events: none;
}

.card-key-face {
  background: linear-gradient(135deg, #fef3c7, #fde68a) !important;
  border-color: #f59e0b !important;
}

.key-icon {
  font-size: 32px;
  pointer-events: none;
}

.card-key.can-play {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.6), 0 0 12px rgba(251, 191, 36, 0.3);
  z-index: 1;
}

.key-flying {
  position: absolute;
  font-size: 28px;
  z-index: 1000;
  transition: transform 0.4s ease-in-out;
  pointer-events: none;
}

.card-unlocking {
  animation: unlock-pulse 0.5s ease-out;
}

@keyframes unlock-pulse {
  0% { box-shadow: 0 0 20px rgba(74, 222, 128, 0.8); }
  100% { box-shadow: none; }
}

/* ── Responsive Breakpoints ── */

/* Mobile portrait: < 480px — card 46×60 */
@media (max-width: 479px) {
  .card {
    width: 46px;
    height: 60px;
    border-radius: 6px;
    margin: 0 3px;
  }

  .card-face,
  .card-back {
    border-radius: 6px;
  }

  .corner {
    font-size: 12px;
  }

  .corner .suit {
    font-size: 13px;
  }

  .corner.top-left {
    top: 2px;
    left: 3px;
  }

  .corner.top-right {
    top: 2px;
    right: 3px;
  }

  .corner.bottom-left {
    bottom: 2px;
    left: 3px;
  }

  .corner.bottom-right {
    bottom: 2px;
    right: 3px;
  }

  .center-value {
    font-size: 32px;
  }

  .tableau-row {
    margin-top: -50px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-42px);
  }

  .pile {
    width: 46px;
    height: 60px;
    border-radius: 6px;
  }

  .piles-row {
    gap: 36px;
    padding: 8px 16px 4px;
  }

  .piles-area {
    gap: 12px;
  }

  .hud-left,
  .hud-right {
    gap: 24px;
  }

  .hud-info-label {
    font-size: 10px;
  }

  .pile-label {
    font-size: 10px;
  }

  .stock-count {
    font-size: 16px;
  }

  .pile-stock .card:nth-child(1) {
    top: -3px;
    left: -3px;
  }
  .pile-stock .card:nth-child(2) {
    top: -1.5px;
    left: -1.5px;
  }

  .donut-timer {
    width: 40px;
    height: 40px;
  }

  .donut-text {
    font-size: 12px;
  }

  .hud-level-value {
    font-size: 17px;
  }

  .hud-score-value {
    font-size: 15px;
  }

  .donut-streak {
    width: 42px;
    height: 42px;
  }

  .streak-text {
    font-size: 16px;
  }

  .main-menu-page {
    padding: 12px;
  }

  .main-menu-content h1 {
    font-size: 22px;
    margin-bottom: 2px;
  }

  .main-menu-content h2 {
    font-size: 17px;
    margin-bottom: 6px;
  }

  .settings-list {
    margin: 4px 0;
  }

  .settings-row {
    padding: 8px 12px;
    margin-bottom: 6px;
  }

  .settings-label {
    font-size: 13px;
  }

  .color-swatch {
    width: 26px;
    height: 26px;
  }

  .color-swatches {
    grid-template-columns: repeat(4, 26px);
    gap: 6px;
  }

  .card-back-picker {
    gap: 12px;
  }

  .card-preview {
    width: 40px;
    height: 58px;
    border-radius: 5px;
  }

  .theme-btn {
    font-size: 12px;
    padding: 6px 10px;
  }

  .menu {
    padding: 16px;
  }

  .menu h1 {
    font-size: 22px;
    margin-bottom: 2px;
  }

  .menu h2 {
    font-size: 17px;
    margin-bottom: 10px;
  }

  .subtitle {
    margin-bottom: 12px;
    font-size: 13px;
  }

  .menu-buttons {
    gap: 8px;
    margin-top: 12px;
  }

  .btn {
    padding: 9px 14px;
    font-size: 14px;
  }

  .rules {
    margin-top: 12px;
    padding: 10px 12px;
  }

  .rules h3 {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .rules li {
    font-size: 12px;
    margin-bottom: 2px;
  }

  .settings-label {
    font-size: 14px;
  }

  .result-details {
    margin: 8px 0;
  }

  .result-row {
    padding: 4px 0;
    font-size: 12px;
  }

  .level-banner {
    font-size: 24px;
  }

  .level-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .btn-level {
    padding: 8px 10px;
  }

  .level-num {
    width: 24px;
    height: 24px;
    font-size: 11px;
  }

  .level-name {
    font-size: 12px;
  }

  .level-time {
    font-size: 10px;
  }

  .result-row {
    font-size: 12px;
  }

  .result-row.total {
    font-size: 14px;
  }

  .result-row.grand-total {
    font-size: 15px;
  }
}

/* Mobile landscape: 480–767px — card 54×70 */
@media (min-width: 480px) and (max-width: 767px) {
  .card {
    width: 54px;
    height: 70px;
    border-radius: 7px;
    margin: 0 3px;
  }

  .card-face,
  .card-back {
    border-radius: 7px;
  }

  .corner {
    font-size: 13px;
  }

  .corner .suit {
    font-size: 15px;
  }

  .corner.top-left {
    top: 3px;
    left: 3px;
  }

  .corner.top-right {
    top: 3px;
    right: 3px;
  }

  .corner.bottom-left {
    bottom: 3px;
    left: 3px;
  }

  .corner.bottom-right {
    bottom: 3px;
    right: 3px;
  }

  .center-value {
    font-size: 37px;
  }

  .tableau-row {
    margin-top: -60px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-48px);
  }

  .pile {
    width: 54px;
    height: 70px;
    border-radius: 7px;
  }

  .piles-row {
    gap: 52px;
    padding: 10px 20px 6px;
  }

  .piles-area {
    gap: 16px;
  }

  .hud-left,
  .hud-right {
    gap: 36px;
  }

  .hud-info-label {
    font-size: 11px;
  }

  .pile-label {
    font-size: 11px;
  }

  .stock-count {
    font-size: 16px;
  }

  .pile-stock .card:nth-child(1) {
    top: -3px;
    left: -3px;
  }
  .pile-stock .card:nth-child(2) {
    top: -1.5px;
    left: -1.5px;
  }

  .donut-timer {
    width: 46px;
    height: 46px;
  }

  .donut-text {
    font-size: 13px;
  }

  .hud-level-value {
    font-size: 18px;
  }

  .hud-score-value {
    font-size: 17px;
  }

  .donut-streak {
    width: 46px;
    height: 46px;
  }

  .streak-text {
    font-size: 17px;
  }

  .menu {
    padding: 24px;
  }

  .menu h1 {
    font-size: 28px;
  }

  .menu h2 {
    font-size: 20px;
  }

  .level-banner {
    font-size: 28px;
  }

  .result-row {
    font-size: 13px;
  }

  .result-row.total {
    font-size: 15px;
  }

  .result-row.grand-total {
    font-size: 16px;
  }

  .settings-list {
    margin: 6px 0;
  }

  .settings-row {
    padding: 8px 12px;
    margin-bottom: 6px;
  }

  .settings-label {
    font-size: 14px;
  }

  .color-swatch {
    width: 28px;
    height: 28px;
  }

  .color-swatches {
    grid-template-columns: repeat(4, 28px);
    gap: 7px;
  }

  .card-back-picker {
    gap: 14px;
  }

  .card-preview {
    width: 42px;
    height: 60px;
    border-radius: 5px;
  }

  .theme-btn {
    font-size: 12px;
    padding: 6px 10px;
  }
}

/* Tablet: 768–1023px — card 64×92 */
@media (min-width: 768px) and (max-width: 1023px) {
  .card {
    width: 64px;
    height: 92px;
    border-radius: 8px;
    margin: 0 4px;
  }

  .corner {
    font-size: 16px;
  }

  .corner .suit {
    font-size: 18px;
  }

  .corner.top-left {
    top: 3px;
    left: 4px;
  }

  .corner.top-right {
    top: 3px;
    right: 4px;
  }

  .corner.bottom-left {
    bottom: 3px;
    left: 4px;
  }

  .corner.bottom-right {
    bottom: 3px;
    right: 4px;
  }

  .center-value {
    font-size: 46px;
  }

  .tableau-row {
    margin-top: -74px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-56px);
  }

  .pile {
    width: 64px;
    height: 92px;
    border-radius: 8px;
  }

  .piles-row {
    gap: 72px;
    padding: 14px 24px 8px;
  }

  .piles-area {
    gap: 22px;
  }

  .hud-left,
  .hud-right {
    gap: 48px;
  }

  .pile-label {
    font-size: 13px;
  }

  .stock-count {
    font-size: 19px;
  }

  .donut-timer {
    width: 52px;
    height: 52px;
  }

  .donut-text {
    font-size: 15px;
  }

  .hud-level-value {
    font-size: 19px;
  }

  .hud-score-value {
    font-size: 20px;
  }

  .donut-streak {
    width: 50px;
    height: 50px;
  }

  .streak-text {
    font-size: 18px;
  }
}

/* Laptop: 1024–1439px — card 80×115 */
@media (min-width: 1024px) and (max-width: 1439px) {
  .card {
    width: 80px;
    height: 115px;
    border-radius: 10px;
    margin: 0 5px;
  }

  .card-face,
  .card-back {
    border-radius: 10px;
  }

  .corner {
    font-size: 19px;
  }

  .corner .suit {
    font-size: 22px;
  }

  .corner.top-left {
    top: 4px;
    left: 5px;
  }

  .corner.top-right {
    top: 4px;
    right: 5px;
  }

  .corner.bottom-left {
    bottom: 4px;
    left: 5px;
  }

  .corner.bottom-right {
    bottom: 4px;
    right: 5px;
  }

  .center-value {
    font-size: 56px;
  }

  .tableau-row {
    margin-top: -92px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-68px);
  }

  .pile {
    width: 80px;
    height: 115px;
    border-radius: 10px;
  }

  .piles-row {
    gap: 84px;
    padding: 16px 28px 10px;
  }

  .piles-area {
    gap: 28px;
  }

  .hud-left,
  .hud-right {
    gap: 56px;
  }

  .pile-label {
    font-size: 14px;
  }

  .stock-count {
    font-size: 22px;
  }

  .pile-stock .card:nth-child(1) {
    top: -5px;
    left: -5px;
  }
  .pile-stock .card:nth-child(2) {
    top: -2.5px;
    left: -2.5px;
  }

  .donut-timer {
    width: 60px;
    height: 60px;
  }

  .donut-text {
    font-size: 16px;
  }

  .hud-level-value {
    font-size: 22px;
  }

  .hud-score-value {
    font-size: 24px;
  }

  .donut-streak {
    width: 56px;
    height: 56px;
  }

  .streak-text {
    font-size: 20px;
  }

  .main-menu-content {
    max-width: 560px;
  }

  .main-menu-content h1 {
    font-size: 36px;
  }

  .main-menu-content h2 {
    font-size: 28px;
  }

  .menu {
    padding: 36px;
    max-width: 480px;
  }

  .menu h1 {
    font-size: 36px;
  }

  .menu h2 {
    font-size: 28px;
  }

  .btn {
    padding: 14px 24px;
    font-size: 17px;
  }

  .level-banner {
    font-size: 36px;
  }

  .level-num {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .level-name {
    font-size: 14px;
  }

  .level-time {
    font-size: 13px;
  }

  .result-row {
    font-size: 15px;
  }

  .result-row.total {
    font-size: 17px;
  }

  .result-row.grand-total {
    font-size: 20px;
  }
}

/* Desktop: ≥ 1440px — card 96×138 */
@media (min-width: 1440px) {
  .card {
    width: 96px;
    height: 138px;
    border-radius: 12px;
    margin: 0 6px;
  }

  .card-face,
  .card-back {
    border-radius: 12px;
  }

  .corner {
    font-size: 22px;
  }

  .corner .suit {
    font-size: 26px;
  }

  .corner.top-left {
    top: 5px;
    left: 6px;
  }

  .corner.top-right {
    top: 5px;
    right: 6px;
  }

  .corner.bottom-left {
    bottom: 5px;
    left: 6px;
  }

  .corner.bottom-right {
    bottom: 5px;
    right: 6px;
  }

  .center-value {
    font-size: 68px;
  }

  .tableau-row {
    margin-top: -110px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-79px);
  }

  .pile {
    width: 96px;
    height: 138px;
    border-radius: 12px;
  }

  .piles-row {
    gap: 108px;
    padding: 20px 32px 12px;
  }

  .piles-area {
    gap: 32px;
  }

  .hud-left,
  .hud-right {
    gap: 72px;
  }

  .pile-label {
    font-size: 16px;
  }

  .stock-count {
    font-size: 26px;
  }

  .pile-stock .card:nth-child(1) {
    top: -6px;
    left: -6px;
  }
  .pile-stock .card:nth-child(2) {
    top: -3px;
    left: -3px;
  }

  .donut-timer {
    width: 68px;
    height: 68px;
  }

  .donut-text {
    font-size: 18px;
  }

  .hud-level-value {
    font-size: 17px;
  }

  .hud-score-value {
    font-size: 28px;
  }

  .donut-streak {
    width: 64px;
    height: 64px;
  }

  .streak-text {
    font-size: 22px;
  }

  .main-menu-content {
    max-width: 600px;
  }

  .main-menu-content h1 {
    font-size: 40px;
  }

  .main-menu-content h2 {
    font-size: 30px;
  }

  .menu {
    padding: 40px;
    max-width: 520px;
  }

  .menu h1 {
    font-size: 40px;
  }

  .menu h2 {
    font-size: 30px;
  }

  .btn {
    padding: 16px 28px;
    font-size: 18px;
    border-radius: 12px;
  }

  .level-banner {
    font-size: 40px;
  }

  .level-num {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }

  .level-name {
    font-size: 15px;
  }

  .level-time {
    font-size: 14px;
  }

  .result-row {
    font-size: 16px;
  }

  .result-row.total {
    font-size: 18px;
  }

  .result-row.grand-total {
    font-size: 22px;
  }
}

/* ── Height overrides for landscape phones ── */

/* Very short viewport (phone landscape, ≤ 420px tall) */
@media (max-height: 420px) and (orientation: landscape) {
  .card {
    width: 46px;
    height: 60px;
    border-radius: 6px;
    margin: 0 3px;
  }

  .card-face,
  .card-back {
    border-radius: 6px;
  }

  .corner {
    font-size: 12px;
  }

  .corner .suit {
    font-size: 13px;
  }

  .corner.top-left {
    top: 2px;
    left: 3px;
  }

  .corner.top-right {
    top: 2px;
    right: 3px;
  }

  .corner.bottom-left {
    bottom: 2px;
    left: 3px;
  }

  .corner.bottom-right {
    bottom: 2px;
    right: 3px;
  }

  .center-value {
    font-size: 32px;
  }

  .tableau {
    padding: 4px 0 0;
  }

  .tableau-row {
    margin-top: -50px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-42px);
  }

  .pile {
    width: 46px;
    height: 60px;
    border-radius: 6px;
  }

  .piles-row {
    gap: 36px;
    padding: 4px 14px 2px;
  }

  .piles-area {
    gap: 12px;
  }

  .hud-left,
  .hud-right {
    gap: 24px;
  }

  .hud-info-label {
    font-size: 10px;
  }

  .pile-label {
    font-size: 10px;
  }

  .stock-count {
    font-size: 16px;
  }

  .pile-stock .card:nth-child(1) {
    top: -3px;
    left: -3px;
  }
  .pile-stock .card:nth-child(2) {
    top: -1.5px;
    left: -1.5px;
  }

  .donut-timer {
    width: 40px;
    height: 40px;
  }

  .donut-text {
    font-size: 12px;
  }

  .hud-level-value {
    font-size: 17px;
  }

  .hud-score-value {
    font-size: 15px;
  }

  .donut-streak {
    width: 42px;
    height: 42px;
  }

  .streak-text {
    font-size: 16px;
  }

  .level-banner {
    font-size: 24px;
  }

  .settings-list {
    margin: 4px 0;
  }

  .settings-row {
    padding: 6px 10px;
    margin-bottom: 4px;
  }

  .settings-label {
    font-size: 13px;
  }

  .color-swatch {
    width: 24px;
    height: 24px;
  }

  .color-swatches {
    grid-template-columns: repeat(4, 24px);
    gap: 5px;
  }

  .card-back-picker {
    gap: 10px;
  }

  .card-preview {
    width: 34px;
    height: 49px;
    border-radius: 4px;
  }

  .theme-btn {
    font-size: 11px;
    padding: 4px 8px;
  }
}

/* Short viewport (large phone / small tablet landscape, 421–500px tall) */
@media (min-height: 421px) and (max-height: 500px) and (orientation: landscape) {
  .card {
    width: 54px;
    height: 70px;
    border-radius: 7px;
    margin: 0 3px;
  }

  .card-face,
  .card-back {
    border-radius: 7px;
  }

  .corner {
    font-size: 13px;
  }

  .corner .suit {
    font-size: 15px;
  }

  .corner.top-left {
    top: 3px;
    left: 3px;
  }

  .corner.top-right {
    top: 3px;
    right: 3px;
  }

  .corner.bottom-left {
    bottom: 3px;
    left: 3px;
  }

  .corner.bottom-right {
    bottom: 3px;
    right: 3px;
  }

  .center-value {
    font-size: 37px;
  }

  .tableau {
    padding: 6px 0 0;
  }

  .tableau-row {
    margin-top: -60px;
  }

  .tableau-row:first-child {
    margin-top: 0;
  }

  .tableau-layer.tableau-layer-offset {
    transform: translateY(-48px);
  }

  .pile {
    width: 54px;
    height: 70px;
    border-radius: 7px;
  }

  .piles-row {
    gap: 52px;
    padding: 6px 16px 4px;
  }

  .piles-area {
    gap: 16px;
  }

  .hud-left,
  .hud-right {
    gap: 36px;
  }

  .hud-info-label {
    font-size: 11px;
  }

  .pile-label {
    font-size: 11px;
  }

  .stock-count {
    font-size: 16px;
  }

  .pile-stock .card:nth-child(1) {
    top: -3px;
    left: -3px;
  }
  .pile-stock .card:nth-child(2) {
    top: -1.5px;
    left: -1.5px;
  }

  .donut-timer {
    width: 46px;
    height: 46px;
  }

  .donut-text {
    font-size: 13px;
  }

  .hud-level-value {
    font-size: 18px;
  }

  .hud-score-value {
    font-size: 17px;
  }

  .donut-streak {
    width: 46px;
    height: 46px;
  }

  .streak-text {
    font-size: 17px;
  }

  .level-banner {
    font-size: 28px;
  }
}

/* ── Auth UI ── */

.auth-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.board-action-auth .btn-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: #ccc;
}

.signin-banner {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  text-align: center;
}

.signin-banner p {
  font-size: 13px;
  color: #aaa;
  margin-bottom: 12px;
}

.signin-banner .signin-rank {
  font-size: 15px;
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 6px;
}

.signin-banner .btn {
  width: auto;
}

.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  color: #3c4043;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.btn-google:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.btn-google svg {
  flex-shrink: 0;
}

.account-menu {
  text-align: center;
  max-width: 340px;
}

.account-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.account-avatar-display {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.account-avatar-display img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.account-avatar-display .avatar-emoji {
  font-size: 36px;
  line-height: 1;
}

.account-avatar-display .avatar-initial {
  font-size: 28px;
  font-weight: 700;
  color: #94a3b8;
}

.account-name-edit {
  width: 100%;
}

.account-name-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
}

.account-name-input:focus {
  border-color: rgba(165, 180, 252, 0.5);
}

.avatar-picker {
  margin-bottom: 16px;
}

.avatar-picker-label {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  justify-items: center;
}

.avatar-option {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  padding: 0;
  transition: border-color 0.2s, background 0.2s;
}

.avatar-option:hover {
  background: rgba(255, 255, 255, 0.12);
}

.avatar-option.active {
  border-color: #a5b4fc;
  background: rgba(165, 180, 252, 0.15);
}

.avatar-option-img {
  overflow: hidden;
}

.avatar-option-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.auth-avatar-emoji {
  font-size: 18px;
  line-height: 1;
}

.menu-header-avatar-emoji {
  font-size: 20px;
  line-height: 1;
}

/* ── Opponent Bar ── */

.opponent-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  font-size: 13px;
  color: #e0e0e0;
  margin: 2px 0;
  z-index: 1;
}

.opp-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  font-size: 16px;
  line-height: 20px;
  text-align: center;
  flex-shrink: 0;
}

.opp-name {
  opacity: 0.8;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opp-score {
  font-weight: 700;
  color: #fff;
  min-width: 40px;
  text-align: right;
}

.opp-level {
  opacity: 0.6;
  font-size: 11px;
}

.opp-score-pulse {
  animation: opp-pulse 0.3s ease;
}

@keyframes opp-pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); color: #4ade80; }
  100% { transform: scale(1); }
}

.mp-scoreboard-bar {
  position: absolute;
  top: 50px;
  left: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 10px;
  font-size: 12px;
  color: #e0e0e0;
  z-index: 10;
}

.mp-sb-entry {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mp-code-input {
  font-family: 'Courier New', monospace;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
  padding: 12px 20px;
  border-radius: 12px;
  text-align: center;
  width: 220px;
  margin: 12px auto;
  display: block;
  outline: none;
  text-transform: uppercase;
}

.mp-code-input:focus {
  border-color: rgba(255, 255, 255, 0.5);
}

.mp-result-scores {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 16px 0;
}

.mp-result-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
}

.mp-result-you {
  background: rgba(74, 222, 128, 0.12);
}

.mp-rank {
  font-size: 14px;
  opacity: 0.5;
  font-weight: 700;
  min-width: 24px;
}

.mp-result-name {
  flex: 1;
  font-size: 15px;
}

.mp-result-total {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.mp-result-playing {
  font-size: 11px;
  opacity: 0.5;
  font-style: italic;
}

/* ── Multiplayer Countdown ── */
.mp-countdown {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 72px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 4px 16px rgba(0,0,0,0.6);
  z-index: 40;
  pointer-events: none;
  animation: countdownPulse 1s ease-out infinite;
}

@keyframes countdownPulse {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.9); }
}

/* ── Social layer ──────────────────────────────────────────────── */

.menu-header-bell {
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  margin-right: 8px;
}

.menu-bell-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
  box-sizing: border-box;
}

.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
}

.presence-dot.online {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
  min-width: 0;
  flex-shrink: 0;
}

.subtle-label {
  font-size: 13px;
  color: #94a3b8;
  flex-shrink: 0;
}

.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  z-index: 1000;
  max-width: 90vw;
  animation: toast-in 0.25s ease-out;
}

.app-toast-clickable {
  cursor: pointer;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* In a game: top centre, clear of the cards, the opponents' scores
   (top left) and the buttons (right) */
.app-toast.app-toast-game {
  top: max(12px, env(safe-area-inset-top));
  bottom: auto;
  max-width: min(280px, 45vw);
  padding: 8px 12px;
  font-size: 13px;
  pointer-events: none;
  animation: toast-game-in 0.2s ease-out;
}

.app-toast.app-toast-game.app-toast-clickable {
  pointer-events: auto;
}

@keyframes toast-game-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.h2h-record {
  margin-left: auto;
  font-size: 12px;
  color: #94a3b8;
}

.lb-row-clickable {
  cursor: pointer;
}

.lb-row-clickable:hover {
  background: rgba(255, 255, 255, 0.06);
}

.lb-row small {
  color: #94a3b8;
  font-weight: 400;
}

.friend-picker-menu .lb-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 12px;
}

.social-search {
  letter-spacing: normal;
  text-transform: none;
  font-size: 15px;
  margin-bottom: 12px;
}

.lb-row .btn {
  width: auto;
  flex: 0 0 auto;
}

.lb-row .lb-name {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.mp-session-line {
  color: #a0c0a0;
  margin-top: 4px;
}

.opp-done-badge {
  color: #4ade80;
  font-weight: 700;
  margin-left: 4px;
}

.mp-sb-entry.opp-done {
  opacity: 0.75;
}

.opp-quit {
  opacity: 0.5;
}

.opp-quit-badge {
  color: #9ca3af;
  font-size: 11px;
  font-style: italic;
  margin-left: 4px;
}

/* Opponent disconnected (grace countdown) or away past it */
.opp-away {
  opacity: 0.6;
}

.opp-away-badge {
  color: #fbbf24;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
  white-space: nowrap;
}

/* "Waiting for others" — who is still on this level */
.mp-waiting-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mp-waiting-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
}

.mp-waiting-name {
  font-weight: 600;
}

.mp-waiting-note {
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}

.mp-waiting-away .mp-waiting-note {
  color: #fbbf24;
}

/* ── Home screen: actions left, leaderboard right ──────────────
   The page itself never scrolls; only the leaderboard list does. */

.main-menu-page.home-page {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  overflow: hidden;
}

.home-header {
  position: static;
  flex: 0 0 auto;
  padding: 8px 16px;
  padding-top: calc(8px + env(safe-area-inset-top));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.home-grid {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 34%) minmax(0, 1fr);
  gap: 12px;
  padding: 4px 16px 12px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.home-play {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 14px 16px;
  border: none;
  border-radius: 12px;
  background: #4f46e5;
  color: #fff;
  font: inherit;
  cursor: pointer;
  flex: 0 0 auto;
}

.home-play:active,
.home-secondary:active,
.home-tile:active {
  transform: scale(0.98);
}

.home-play-icon {
  font-size: 22px;
}

.home-play-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.home-play-title {
  font-size: 18px;
  font-weight: 700;
}

.home-play-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.home-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  flex: 0 0 auto;
}

.home-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.home-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
  gap: 8px;
  margin-top: auto;
  flex: 0 0 auto;
}

.home-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 2px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.home-tile-icon {
  font-size: 18px;
  line-height: 1.2;
}

.home-board {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  color: #fff;
}

.home-board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex: 0 0 auto;
}

.home-board-tabs {
  margin-bottom: 0;
  flex-wrap: nowrap;
}

.home-board-tabs .hs-tab {
  flex: 0 0 auto;
  padding: 6px 12px;
  white-space: nowrap;
}

.home-board-title {
  font-size: 13px;
  font-weight: 600;
  color: #a5b4fc;
}

.home-board-reset {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  white-space: nowrap;
}

.home-board-list {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
  padding: 6px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.home-board-me {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(79, 70, 229, 0.25);
  border-top: 1px solid rgba(165, 180, 252, 0.3);
  color: #c7d2fe;
  font-size: 13px;
  font-weight: 600;
  flex: 0 0 auto;
}

.home-board-me .lb-name {
  flex: 1;
  text-align: left;
}

/* Guests: the pinned row invites them to sign in */
.home-board-me-action {
  cursor: pointer;
}

.home-board-me-action:hover {
  background: rgba(79, 70, 229, 0.4);
}

.home-board-me-go {
  color: #a5b4fc;
  white-space: nowrap;
}

/* Guests: under the top 10, the rest of the board is behind sign-in */
.lb-show-all {
  display: block;
  width: auto;
  margin: 10px auto 4px;
  padding: 6px 16px;
  font-size: 13px;
}

/* Upright phone / narrow browser tab: stack actions over the board */
@media (orientation: portrait) {
  .home-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }

  .home-actions {
    overflow: visible;
  }

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

/* Very short landscape screens: tighten the Play button */
@media (orientation: landscape) and (max-height: 360px) {
  .home-play {
    padding: 8px 14px;
  }

  .home-play-title {
    font-size: 16px;
  }
}

/* ── Touch devices: finger-sized targets, in both orientations ── */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
  }

  .btn-small {
    min-height: 40px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .hs-tab {
    min-height: 40px;
  }

  .theme-btn {
    min-height: 40px;
  }

  .color-swatch {
    min-width: 36px;
    min-height: 36px;
  }

  .color-swatches {
    grid-template-columns: repeat(4, 36px);
    gap: 8px;
  }

  .avatar-option {
    width: 40px;
    height: 40px;
  }

  .menu-header-avatar,
  .menu-header-bell {
    min-width: 40px;
    min-height: 40px;
  }
}

/* Dialogs taller than a short (landscape) screen scroll inside themselves
   instead of clipping their content */
.overlay .menu {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ── Room lobby (Join a room) ──────────────────────────────── */

.rooms-code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.rooms-code-row .rooms-code-input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  margin: 0;
  font-size: 22px;
  letter-spacing: 4px;
  padding: 8px 12px;
}

.rooms-code-row .btn {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

.rooms-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rooms-name {
  font-size: 15px;
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rooms-meta {
  font-size: 12px;
  color: #94a3b8;
}

.rooms-empty {
  padding: 16px 0;
  font-size: 14px;
  color: #94a3b8;
  text-align: center;
}

/* The host's connection dropped: the room closes unless they come back */
.lobby-host-note {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.lobby-host-note[hidden] {
  display: none;
}

.invite-search {
  width: 100%;
  margin: 6px 0 4px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  outline: none;
}

.invite-search:focus {
  border-color: #818cf8;
}

.invite-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 45vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.invite-row:first-child {
  border-top: none;
}

.invite-offline .lb-avatar,
.invite-offline .rooms-name {
  opacity: 0.6;
}

.invite-row .invite-btn {
  width: auto;
  flex: 0 0 auto;
  margin: 0;
}

.invite-sent {
  flex: 0 0 auto;
  font-size: 13px;
  color: #86efac;
  font-weight: 600;
}

.invite-friend {
  color: #fbbf24;
  font-size: 12px;
}

.presence-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  background: #64748b;
  vertical-align: middle;
}

.presence-dot.on {
  background: #22c55e;
}

/* ── Sign in / create account / reset / nickname dialogs ─────────── */
.signin-menu {
  gap: 12px;
  overflow-y: auto;
}

.signin-menu h2 {
  margin: 0;
}

.signin-menu .subtitle {
  margin: 0;
}

.signin-google {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.signin-google[hidden] {
  display: none;
}

.signin-google .btn-google {
  width: auto;
}

.signin-or {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: rgba(255, 255, 255, 0.45);
  font-size: 12px;
}

.signin-or::before,
.signin-or::after {
  content: '';
  flex: 1;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.signin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 600;
  color: #c7d2fe;
}

.form-field small {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.5);
}

.form-field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-family: inherit;
  font-size: 16px; /* no zoom-on-focus on phones */
  font-weight: 400;
  outline: none;
}

.form-field input:focus {
  border-color: rgba(165, 180, 252, 0.7);
}

.form-field input[aria-invalid='true'] {
  border-color: #f87171;
}

.form-hint-bad {
  color: #fca5a5 !important;
}

.form-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.12);
  color: #fca5a5;
  font-size: 13px;
  text-align: left;
}

.form-error[hidden] {
  display: none;
}

.signin-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.link-btn {
  background: none;
  border: none;
  padding: 6px 2px;
  color: #a5b4fc;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: #c7d2fe;
}

.account-name-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
}

.account-name-edit .form-error {
  margin-top: 8px;
}
.rooms-lock {
  font-size: 0.85em;
}
.ask-join {
  max-width: 360px;
}
.ask-join-spinner {
  width: 28px;
  height: 28px;
  margin: 4px auto 12px;
  border: 3px solid rgba(148, 163, 184, 0.3);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: ask-join-spin 0.9s linear infinite;
}
@keyframes ask-join-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .ask-join-spinner { animation-duration: 3s; }
}

/* ── Game chooser (the site's start screen) ───────────────────── */

.menu-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.menu-header-back {
  width: 32px;
  height: 32px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.menu-header-back:hover {
  background: rgba(255, 255, 255, 0.16);
}

.chooser {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 8px 16px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
}

.chooser-title {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: #f1f5f9;
  text-align: center;
}

.chooser-games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.game-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 112px;
  padding: 16px;
  border-radius: 14px;
  border: 1px solid rgba(165, 180, 252, 0.35);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.35), rgba(79, 70, 229, 0.12));
  color: #f1f5f9;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.game-card:not([disabled]):hover {
  border-color: rgba(165, 180, 252, 0.7);
}

.game-card:not([disabled]):active {
  transform: scale(0.98);
}

.game-card-soon {
  cursor: default;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(241, 245, 249, 0.6);
}

.game-card-icon {
  font-size: 40px;
  line-height: 1;
  flex: none;
}

.game-card-soon .game-card-icon {
  filter: grayscale(1);
  opacity: 0.6;
}

.game-card-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.game-card-name {
  font-size: 18px;
  font-weight: 700;
}

.game-card-tagline {
  font-size: 13px;
  color: rgba(241, 245, 249, 0.75);
}

.game-card-soon .game-card-tagline {
  color: rgba(241, 245, 249, 0.5);
}

.game-card-players {
  font-size: 12px;
  color: #a5b4fc;
}

.game-card-soon .game-card-players {
  color: rgba(165, 180, 252, 0.5);
}

.game-card-go {
  flex: none;
  font-size: 28px;
  color: #a5b4fc;
}

.game-card-badge {
  flex: none;
  align-self: flex-start;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(251, 191, 36, 0.15);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: #fbbf24;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-height: 420px) {
  .chooser { gap: 10px; }
  .chooser-title { font-size: 18px; }
  .game-card { min-height: 88px; padding: 12px; }
  .game-card-icon { font-size: 32px; }
}

/* ── Top of the screen ─────────────────────────────────────────
   The safe-area inset already clears the notch or camera (and, in the
   installed full-screen app, the hidden status bar's place); a small gap
   is added only where there is no inset, so nothing is doubled. */

.menu-header {
  padding-top: max(12px, env(safe-area-inset-top));
}

.home-header {
  padding-top: max(8px, env(safe-area-inset-top));
}

.main-menu-page:not(.home-page) {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* ── Tabs: Home, Rooms, Friends, Settings ──────────────────────
   Header on top, the tab's content in the middle (the only part that
   scrolls), the tab bar at the bottom, above the gesture bar. */

.menu-header-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: #e2e8f0;
}

.tab-page .home-grid {
  padding-bottom: 12px;
}

.tab-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.tab-body .main-menu-content {
  margin: 0 auto;
}

.rooms-create {
  width: 100%;
  margin-bottom: 14px;
}

.tab-bar {
  flex: 0 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 120px);
  justify-content: center;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.96);
  padding: 4px calc(8px + env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
}

.tab-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 4px 2px;
  border: none;
  border-radius: 10px;
  background: none;
  color: rgba(255, 255, 255, 0.55);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar-icon {
  font-size: 20px;
  line-height: 1.1;
  filter: grayscale(1);
  opacity: 0.65;
}

.tab-bar-item.active {
  color: #a5b4fc;
}

.tab-bar-item.active .tab-bar-icon {
  filter: none;
  opacity: 1;
}

.tab-bar-item:hover:not(.active) {
  color: rgba(255, 255, 255, 0.8);
}

.tab-bar-item:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: -2px;
}

/* Sideways phone: a bottom bar would eat the little height there is, so
   the tabs become a rail down the left side */
@media (orientation: landscape) and (max-height: 560px) {
  .main-menu-page.tab-page {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "rail header"
      "rail body";
  }

  .tab-page > .home-header {
    grid-area: header;
    padding-left: 16px;
  }

  .tab-page > .home-grid,
  .tab-page > .tab-body {
    grid-area: body;
    padding-left: 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .tab-bar {
    grid-area: rail;
    grid-auto-flow: row;
    grid-template-columns: 72px;
    grid-auto-rows: min-content;
    align-content: center;
    border-top: none;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    padding: max(8px, env(safe-area-inset-top)) 4px max(8px, env(safe-area-inset-bottom)) calc(4px + env(safe-area-inset-left));
  }

  .tab-bar-item {
    min-height: 56px;
  }
}

/* Friends tab: the search is an ordinary full-width field, not a room code */
.tab-body .social-search {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 500;
  text-align: left;
}

/* Settings: on a narrow phone a row's controls (the card back picker) go
   under the label instead of squeezing it */
.settings-row {
  flex-wrap: wrap;
  gap: 8px 12px;
}

/* A tab a guest can't use yet: what signing in gives them */
.tab-signin {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding-top: 48px;
}

.tab-signin-icon {
  font-size: 44px;
  line-height: 1;
}

.tab-signin-text {
  max-width: 280px;
  margin: 0;
  font-size: 15px;
  color: rgba(255, 255, 255, 0.75);
}

.tab-signin .btn {
  width: auto;
  min-width: 160px;
}

/* ── Rooms as cards ────────────────────────────────────────── */

.rooms-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 6px 2px 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #94a3b8;
}

.rooms-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.rooms-grid .rooms-empty {
  grid-column: 1 / -1;
}

.room-card {
  --room-hue: 230;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border-radius: 16px;
  text-align: left;
  background:
    linear-gradient(160deg, hsl(var(--room-hue) 55% 45% / 0.28), transparent 55%),
    #1e293b;
  border: 1px solid hsl(var(--room-hue) 40% 60% / 0.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.room-card-off {
  opacity: 0.55;
}

.room-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.room-card .room-card-avatar {
  width: 40px;
  height: 40px;
  background: hsl(var(--room-hue) 45% 38%);
  box-shadow: 0 0 0 2px hsl(var(--room-hue) 50% 60% / 0.35);
}

.room-card-avatar .lb-avatar-initial {
  font-size: 17px;
  color: #fff;
}

.room-card-avatar .lb-avatar-emoji {
  font-size: 22px;
}

.room-card-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.room-tag {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.55);
  font-size: 11px;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
}

.room-tag-private {
  padding: 2px 5px;
}

.room-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #f1f5f9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-card-seats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-seat-row {
  display: flex;
  gap: 3px;
}

.room-seat {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.room-seat.on {
  background: hsl(var(--room-hue) 75% 68%);
}

.room-card-count {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

.room-card-status {
  font-size: 12px;
  color: #94a3b8;
}

.room-card .rooms-join {
  width: 100%;
  margin: auto 0 0;
  padding: 8px 12px;
  font-size: 14px;
}

/* ── Waiting room ──────────────────────────────────────────────
   Header (Back leaves), then a scrolling body: the room's ticket (code,
   sharing, who may join), anyone asking to join, and a seat for each
   player the room holds. A bar at the bottom holds the one thing to do
   next. The host invites from a sheet that slides up over it all. */

.wr-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wr-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
}

.wr-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 4px 16px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.wr-content {
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.wr-note {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
}

.wr-content .lobby-host-note {
  margin: 0;
}

.wr-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

/* The room's ticket */
.wr-ticket {
  --room-hue: 230;
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(160deg, hsl(var(--room-hue) 55% 45% / 0.3), transparent 60%),
    #1e293b;
  border: 1px solid hsl(var(--room-hue) 40% 60% / 0.2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.wr-ticket-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wr-code-box {
  min-width: 0;
}

.wr-code {
  margin-top: 2px;
  font: 700 28px/1.1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 5px;
  color: #fff;
  user-select: all;
}

.wr-share {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex: none;
}

.wr-btn {
  height: 40px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.wr-btn:hover {
  background: rgba(15, 23, 42, 0.8);
}

.wr-btn-primary,
.wr-btn-primary:hover {
  background: #4f46e5;
  color: #fff;
}

.wr-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.wr-seg {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
}

.wr-seg button {
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.wr-seg button.on {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.wr-hint {
  margin: 8px 2px 0;
  font-size: 12px;
  color: #94a3b8;
}

.wr-hint-top {
  margin-top: 4px;
}

/* Asking to join */
.wr-requests {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wr-requests:empty {
  display: none;
}

.wr-ask {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-radius: 14px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.wr-ask-text {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wr-ask-text b {
  color: #fde68a;
}

.wr-ask .wr-btn {
  height: 36px;
  border-radius: 10px;
}

.wr-ask .wr-ask-no {
  width: 36px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
}

/* Seats */
.wr-players {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wr-section-head {
  display: flex;
  justify-content: space-between;
  margin: 2px 2px 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94a3b8;
}

.wr-seats {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px 8px;
}

.wr-seat {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.wr-av {
  --room-hue: 230;
  position: relative;
  width: 56px;
  height: 56px;
  flex: none;
  padding: 0;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: hsl(var(--room-hue) 45% 40%);
  box-shadow: 0 0 0 2px hsl(var(--room-hue) 55% 65% / 0.45);
  color: #fff;
  font-family: inherit;
}

.wr-av .lb-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.wr-av .lb-avatar-initial {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
}

.wr-av .lb-avatar-emoji {
  font-size: 28px;
}

.wr-av-small {
  width: 36px;
  height: 36px;
}

.wr-av-small .lb-avatar-initial {
  font-size: 15px;
}

.wr-av-small .lb-avatar-emoji {
  font-size: 18px;
}

.wr-crown {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  line-height: 1;
}

.wr-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px #1e293b;
}

.wr-av-small .wr-dot {
  width: 10px;
  height: 10px;
}

.wr-dot.off {
  background: #64748b;
}

.wr-seat.opp-away {
  opacity: 1;
}

.wr-seat.opp-away .wr-av {
  opacity: 0.6;
}

.wr-seat.opp-away .wr-dot {
  background: #f59e0b;
}

.wr-kick {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #334155;
  box-shadow: 0 0 0 2px #1e293b;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.wr-kick:hover {
  background: #7f1d1d;
  color: #fecaca;
}

/* A bigger target for fingers, without a bigger badge */
@media (pointer: coarse) {
  .wr-kick::after {
    content: "";
    position: absolute;
    inset: -8px;
  }
}

.wr-name {
  max-width: 100%;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wr-sub {
  max-width: 100%;
  font-size: 11px;
  color: #94a3b8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wr-sub:empty {
  display: none;
}

.wr-seat .opp-away-badge {
  margin: 0;
  color: #fbbf24;
}

.wr-wins {
  color: #fde68a;
}

.wr-empty .wr-av {
  background: transparent;
  box-shadow: none;
  border: 2px dashed rgba(148, 163, 184, 0.35);
  color: #64748b;
  font-size: 26px;
  font-weight: 400;
}

.wr-empty button.wr-av {
  cursor: pointer;
}

.wr-empty button.wr-av:hover {
  border-color: #818cf8;
  color: #a5b4fc;
}

.wr-empty .wr-name {
  color: #64748b;
  font-weight: 500;
}

/* Bottom bar */
.wr-bar {
  flex: none;
  padding: 12px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: rgba(15, 23, 42, 0.92);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.wr-bar > * {
  max-width: 520px;
  margin: 0 auto;
}

.wr-bar .wr-start {
  display: block;
  width: 100%;
  height: 52px;
  margin: 0 auto;
  border-radius: 14px;
  font-size: 17px;
}

.wr-start small {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0.75;
}

.wr-wait {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-size: 15px;
}

.wr-pulse {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: #818cf8;
  animation: wr-pulse 1.6s ease-in-out infinite;
}

@keyframes wr-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.45); }
  50% { box-shadow: 0 0 0 7px rgba(129, 140, 248, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .wr-pulse { animation: none; }
}

/* Invite sheet */
.wr-sheet-wrap {
  position: absolute;
  inset: 0;
  z-index: 5;
}

.wr-sheet-wrap[hidden] {
  display: none;
}

.wr-scrim {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  opacity: 0;
  transition: opacity 0.2s;
}

.wr-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-width: 560px;
  max-height: 78%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: #1e293b;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  text-align: left;
  transform: translateY(100%);
  transition: transform 0.22s ease-out;
}

.wr-sheet-wrap.open .wr-scrim {
  opacity: 1;
}

.wr-sheet-wrap.open .wr-sheet {
  transform: none;
}

.wr-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.wr-sheet-head h2 {
  margin: 0;
  font-size: 18px;
  color: #f1f5f9;
}

.wr-sheet-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
  color: #cbd5e1;
  font-size: 14px;
  cursor: pointer;
}

.wr-sheet .invite-search {
  margin: 0;
}

.wr-pills {
  display: flex;
  gap: 6px;
  margin: 10px 0 4px;
}

.wr-pill {
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: #94a3b8;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.wr-pill.on {
  background: #e2e8f0;
  color: #0f172a;
}

.wr-sheet .invite-list {
  flex: 1;
  min-height: 120px;
  max-height: none;
}

.wr-sheet .invite-row {
  gap: 12px;
  padding: 9px 0;
}

.wr-sheet .invite-row .wr-btn {
  height: 34px;
  flex: none;
  border-radius: 10px;
}

.wr-sent {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  cursor: default;
}

/* Sideways phone: the room on the left, the seats on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .wr-content {
    max-width: 860px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-auto-flow: row dense;
    align-content: start;
    column-gap: 20px;
    row-gap: 10px;
  }

  .wr-content > * {
    grid-column: 1;
  }

  .wr-content > .wr-players {
    grid-column: 2;
    grid-row: 1 / span 8;
    align-self: start;
  }

  .wr-av {
    width: 46px;
    height: 46px;
  }

  .wr-bar {
    padding-top: 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  .wr-bar .wr-start,
  .wr-wait {
    height: 44px;
  }

  .wr-sheet {
    max-height: 92%;
  }
}

/* A room link: the room on a card, before joining */
.room-preview {
  max-width: 340px;
}

.room-preview .room-preview-card {
  margin: 12px 0 18px;
}

.room-preview .room-card-status {
  font-size: 13px;
}


/* ══ Redesign: Home · Lobby · Boards · More ═════════════════════════
   Buttons with depth (a soft gradient, a thin highlight on top, a 1px
   darker edge below and a soft shadow), Play / Create room pinned above
   the tab bar, pages with a Back header, people rows, sheets. */

[hidden] { display: none !important; }

.home-play,
.btn-primary {
  background: linear-gradient(180deg, #6f68f0 0%, #5850e8 45%, #4338ca 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 -1px 0 rgba(30, 27, 75, 0.6), 0 6px 14px rgba(0, 0, 0, 0.5);
  text-shadow: 0 2px 0 rgba(30, 27, 75, 0.45);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #7a73f3 0%, #6058ec 45%, #4a40d3 100%);
}

.btn-secondary,
.home-tile,
.home-secondary {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.35);
}

.btn-gold {
  background: linear-gradient(180deg, #fcd34d, #f59e0b 50%, #d97706);
  color: #1c1917;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -1px 0 rgba(120, 53, 15, 0.5), 0 6px 14px rgba(0, 0, 0, 0.5);
}

.btn-gold:hover { filter: brightness(1.05); }

.btn-icon {
  width: auto;
  flex: 0 0 auto;
  padding: 7px 10px;
  font-size: 14px;
  line-height: 1;
  border-radius: 10px;
}

.person-row .btn-small,
.premium-row .btn-small {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
}

/* Pinned above the tab bar (or at the bottom of a page) */
.page-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
}

.sub-page .page-dock {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.page-dock .home-play,
.page-dock .home-secondary {
  width: 100%;
  margin: 0;
}

.page-dock .home-play { padding: 16px 18px; }
.page-dock .home-play-title { font-size: 20px; }

.menu-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.menu-header-right .menu-header-bell + .menu-header-bell { margin-right: 0; }

.menu-bell-badge {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Section headings in a page */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 14px 2px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.55);
}

.section-head .link {
  border: 0;
  background: none;
  padding: 0;
  color: #a5b4fc;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

/* A boxed list or section on the app screens (`.card` is the playing card) */
.panel {
  display: block;
  width: 100%;
  text-align: left;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  color: #e2e8f0;
  font: inherit;
}

button.panel { cursor: pointer; }

.card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-empty {
  padding: 18px 16px;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  border-radius: 14px;
  color: rgba(226, 232, 240, 0.6);
  font-size: 14px;
  line-height: 1.45;
}

.card-empty.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
  padding: 26px 16px;
}

.card-empty b { color: #e2e8f0; font-size: 15px; }
.empty-icon { font-size: 30px; margin-bottom: 4px; }
.sub-note { margin: 8px 2px; font-size: 13px; color: rgba(226, 232, 240, 0.5); }
.sub-note.center, .center { text-align: center; }
.go { color: rgba(226, 232, 240, 0.4); font-size: 22px; line-height: 1; }

/* ── Home ── */
.home-body { display: flex; flex-direction: column; }
.home-body > .home-tiles { margin-top: 0; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.home-body .home-tile { min-height: 64px; font-size: 14px; background: #1e293b; color: #e2e8f0; border-radius: 14px; }
.home-body .home-tile-icon { font-size: 22px; }

.week-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.week-rank {
  min-width: 54px;
  text-align: center;
  font-size: 28px;
  font-weight: 800;
  color: #fbbf24;
}

.week-text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.week-text b { font-size: 15px; }
.week-text span { font-size: 13px; color: rgba(226, 232, 240, 0.6); }

.room-strip {
  display: flex;
  grid-template-columns: none;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  margin: 0 -16px;
  padding: 0 16px 6px;
  scrollbar-width: none;
}

.room-strip::-webkit-scrollbar { display: none; }
.room-strip .room-card { flex: 0 0 min(74%, 280px); scroll-snap-align: start; }

/* ── Switches (Rooms | Players, Everyone | Friends, All | Solo | Rooms) ── */
.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  margin-bottom: 12px;
  padding: 3px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  background: #0f172a;
}

.seg button {
  border: 0;
  border-radius: 9px;
  padding: 8px 4px;
  background: none;
  color: rgba(226, 232, 240, 0.6);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.seg button.on {
  background: #334155;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.seg-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(148, 163, 184, 0.2);
  font-size: 12px;
}

.seg-count:empty { display: none; }
.seg button.on .seg-count { background: rgba(255, 255, 255, 0.2); }

/* ── People ── */
.person-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-align: left;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  color: #e2e8f0;
  font: inherit;
}

.row-button { width: 100%; cursor: pointer; }
.person-off { opacity: 0.6; }
.person-invite { border-color: rgba(129, 140, 248, 0.45); background: linear-gradient(135deg, rgba(79, 70, 229, 0.22), #1e293b 70%); }
.person-challenge { border-color: rgba(251, 191, 36, 0.45); background: linear-gradient(135deg, rgba(251, 191, 36, 0.16), #1e293b 70%); }

.person-avatar {
  position: relative;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: hsl(var(--room-hue, 230) 45% 30%);
}

.person-avatar.big { width: 56px; height: 56px; font-size: 30px; }
.person-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.person-avatar .lb-avatar-initial { font-size: 0.8em; font-weight: 700; color: #e2e8f0; }

.person-dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #64748b;
  border: 2px solid #1e293b;
}

.person-dot.on { background: #22c55e; }

.person-who {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.person-who b {
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-who > span {
  font-size: 12.5px;
  color: rgba(226, 232, 240, 0.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-who > span.live { color: #4ade80; }

.friend-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.25);
  font-size: 12px;
  cursor: pointer;
}

.friend-chip.on { outline: 2px solid #818cf8; }

.friend-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: -2px 0 4px 48px;
  padding: 12px 14px;
  border: 1px solid rgba(129, 140, 248, 0.5);
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.friend-card .ln { display: flex; justify-content: space-between; color: rgba(226, 232, 240, 0.7); }
.friend-card .ln span:last-child { color: #e2e8f0; font-weight: 600; }
.friend-card .ln .lead { color: #4ade80 !important; }

.online-head { justify-content: flex-start; }
.online-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: #22c55e; vertical-align: 1px; }

.lobby-view .social-search { margin-bottom: 4px; }
.rooms .lobby-view .rooms-code-row { margin-bottom: 14px; }

/* ── Boards ── */
.boards-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 12px;
}

.boards-body .home-board { flex: 1; }
.home-board-head .who-seg { width: 100%; margin-bottom: 0; }
.home-board-head .home-board-tabs { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.home-board-head .home-board-tabs .hs-tab { padding: 6px 4px; }

/* ── Game history ── */
.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-tile {
  padding: 10px 6px;
  text-align: center;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 12px;
  color: #e2e8f0;
}

.stat-tile b { display: block; font-size: 19px; }
.stat-tile span { font-size: 12px; color: rgba(226, 232, 240, 0.55); }

.history-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 12px;
  color: #e2e8f0;
}

.history-kind {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.12);
}

.history-score { text-align: right; font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.history-score small { display: block; font-size: 12px; font-weight: 600; color: rgba(226, 232, 240, 0.5); }
.history-score small.won { color: #4ade80; }

.premium-card {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: #1e293b;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.45);
}

.premium-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), #1e293b 70%);
  color: #e2e8f0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.premium-row:first-child { border-top: 0; }
.premium-icon { font-size: 22px; flex: none; }

/* ── More ── */
.more-body { display: flex; flex-direction: column; gap: 12px; }
.profile-card { display: flex; align-items: center; gap: 14px; }
.profile-card .person-who b { font-size: 18px; }
.guest-card .person-who > span { white-space: normal; }

.menu-group {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  background: #1e293b;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-top: 1px solid rgba(148, 163, 184, 0.08);
  background: none;
  color: #e2e8f0;
  font: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
}

.menu-item:first-child { border-top: 0; }
.menu-item-icon { width: 26px; text-align: center; font-size: 19px; }
.menu-item-label { flex: 1; display: flex; flex-direction: column; }
.menu-item-label small { font-size: 12px; color: rgba(226, 232, 240, 0.5); }

.link-danger {
  align-self: center;
  border: 0;
  background: none;
  padding: 8px;
  color: #f87171;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ── Pages over a tab (Back in the header) ── */
.sub-body .settings-list { padding: 4px 14px; }
.learn-card ul { margin: 0; padding-left: 18px; line-height: 1.6; }

/* ── Sheets ── */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: rgba(2, 6, 23, 0.6);
  animation: fadeIn 0.2s ease;
}

.sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 18px max(22px, env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: #1e293b;
  color: #e2e8f0;
  animation: sheetUp 0.22s ease;
}

@keyframes sheetUp {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}

.sheet-grab { width: 40px; height: 5px; margin: 0 auto 4px; border-radius: 3px; background: rgba(148, 163, 184, 0.35); }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet p { margin: 0; font-size: 14px; line-height: 1.45; color: rgba(226, 232, 240, 0.65); }
.sheet .btn { width: 100%; padding: 14px; border-radius: 14px; font-size: 16px; }
.sheet .sheet-main { width: 100%; justify-content: center; padding: 14px; }
.sheet-person { display: flex; align-items: center; gap: 14px; }
.sheet-rule { padding: 10px 12px; border-radius: 12px; background: rgba(148, 163, 184, 0.1); font-size: 13.5px; color: rgba(226, 232, 240, 0.8); }
.sheet-danger { color: #fca5a5 !important; }
.premium-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.best-levels { max-height: 45vh; overflow-y: auto; }

/* Wide screens: keep the tab pages to a readable width */
@media (min-width: 720px) {
  .tab-body > *, .page-dock > * { max-width: 640px; margin-left: auto; margin-right: auto; }
  .tab-body > .main-menu-content { max-width: 900px; }
}

/* ── A challenge waiting for its answer ── */
.challenge-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 24px 0 12px;
}

.challenge-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #e2e8f0;
}

.challenge-side .person-avatar.big { width: 72px; height: 72px; font-size: 38px; }
.challenge-pending { opacity: 0.6; animation: challengePulse 1.6s ease-in-out infinite; }
.challenge-x { font-size: 30px; }
.challenge-note { margin: 0 auto; max-width: 320px; text-align: center; font-size: 14px; line-height: 1.45; color: rgba(226, 232, 240, 0.65); }

@keyframes challengePulse {
  50% { opacity: 0.95; }
}

/* Settings as a page: the rows are the cards; the list never clips */
.sub-body .settings-list.panel { overflow: visible; flex: none; margin: 0; padding: 0; background: none; border: 0; }
.panel { margin: 0; }

/* A room on a longer clock */
.room-tag-clock { background: rgba(251, 191, 36, 0.18) !important; color: #fbbf24 !important; }
.wr-clock-label { margin-top: 12px; }
.wr-clock button { padding-left: 4px; padding-right: 4px; }
.wr-clock { display: grid; grid-template-columns: repeat(4, 1fr); }
.friend-card { text-align: left; }
.home-board-head .lb-period-tabs { width: 100%; margin-bottom: 0; }


/* ══ End of a game: a card over the board ═══════════════════════════
   Score (or who won, with a podium), then the levels or standings, then
   the buttons. Upright phones stack it; sideways phones (where the game
   is played) put the two halves side by side. */

.result-overlay { padding: 12px; }

.result-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main" "side" "actions";
  gap: 14px;
  width: 100%;
  max-width: 460px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 20px;
  background: linear-gradient(180deg, #1f2b40, #182235);
  color: #e2e8f0;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: sheetUp 0.25s ease;
}

.result-main { grid-area: main; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.result-side { grid-area: side; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.result-actions { grid-area: actions; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result-actions .btn { padding: 13px 10px; border-radius: 14px; }
.result-actions .btn:only-child { grid-column: 1 / -1; }

.result-kicker {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a5b4fc;
}

.result-score {
  font-size: 44px;
  font-weight: 800;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 3px 0 rgba(30, 27, 75, 0.5);
}

.result-sub { margin: 0; font-size: 14px; color: rgba(226, 232, 240, 0.65); }
.result-rank { margin: 2px 0 0; padding: 6px 12px; border-radius: 999px; background: rgba(251, 191, 36, 0.14); color: #fbbf24; font-size: 13px; font-weight: 600; }
.result-session { margin: 0; font-size: 13px; color: rgba(226, 232, 240, 0.55); }
.result-title { margin: 0; font-size: 22px; }

.result-signin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(79, 70, 229, 0.16);
  font-size: 13.5px;
  color: rgba(226, 232, 240, 0.8);
}

.result-signin p { margin: 0; }
.result-signin .btn { width: auto; }

.result-levels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.result-level {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 2px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.1);
  font-size: 11px;
  color: rgba(226, 232, 240, 0.55);
}

.result-level b { font-size: 12.5px; color: #e2e8f0; font-variant-numeric: tabular-nums; }
.result-level.cleared { background: rgba(34, 197, 94, 0.14); }
.result-level.cleared span { color: #4ade80; }

/* Room results: a podium for the top three, then everyone */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}

.podium-spot {
  flex: 1;
  max-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.podium-spot b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.podium-spot > span:not(.person-avatar) { font-size: 13px; color: rgba(226, 232, 240, 0.7); font-variant-numeric: tabular-nums; }
.podium-you b { color: #a5b4fc; }

.podium-step {
  width: 100%;
  margin-top: 4px;
  border-radius: 10px 10px 4px 4px;
  font-size: 20px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.75);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 4px;
}

.podium-1 .podium-step { height: 58px; background: linear-gradient(180deg, #fde68a, #f59e0b); }
.podium-2 .podium-step { height: 42px; background: linear-gradient(180deg, #e2e8f0, #94a3b8); }
.podium-3 .podium-step { height: 30px; background: linear-gradient(180deg, #fdba74, #c2410c); }

.result-standings { display: flex; flex-direction: column; gap: 4px; }

.standing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.08);
  text-align: left;
}

.standing .person-avatar { width: 30px; height: 30px; font-size: 16px; }
.standing-you { background: rgba(79, 70, 229, 0.25); }
.standing-rank { width: 18px; font-weight: 700; color: rgba(226, 232, 240, 0.5); text-align: center; }
.standing-name { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.standing-name small { margin-left: 6px; font-weight: 500; font-size: 12px; color: rgba(226, 232, 240, 0.5); }
.standing-score { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Waiting for the others at the end of a level */
.result-small { max-width: 380px; grid-template-areas: "main"; }
.result-wait h2 { margin: 0; font-size: 20px; }
.result-wait .subtitle { margin: 0; color: rgba(226, 232, 240, 0.6); }
.result-wait .mp-waiting-list { width: 100%; }
.result-wait .mp-waiting-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(148, 163, 184, 0.08); }
.result-wait .mp-waiting-row .person-avatar { width: 30px; height: 30px; font-size: 16px; }
.result-wait .mp-waiting-name { flex: 1; text-align: left; font-weight: 600; }
.result-wait .mp-waiting-note { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: rgba(226, 232, 240, 0.55); }

/* Sideways phones: score on the left, levels or standings on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .result-card {
    max-width: 760px;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    grid-template-areas: "main side" "actions actions";
    padding: 14px 18px;
    gap: 10px 18px;
    align-items: center;
  }
  .result-small { max-width: 420px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "main"; }
  .result-score { font-size: 36px; }
  .result-side { max-height: 52vh; overflow-y: auto; }
  .podium-1 .podium-step { height: 40px; }
  .podium-2 .podium-step { height: 30px; }
  .podium-3 .podium-step { height: 22px; }
}

/* ── Profile page ── */
.profile-page .profile-since { margin-top: 0; }
.profile-edit { margin-top: 12px; }
.profile-edit .account-info { display: flex; align-items: center; gap: 14px; }
.profile-edit .avatar-picker { margin-top: 14px; }
.profile-save { width: 100%; padding: 15px; border-radius: 14px; font-size: 17px; }
.profile-challenges { margin-top: -4px; }
.panel.profile-edit { background: none; border: 0; padding: 0; overflow: visible; }
.profile-edit .account-info { flex-direction: column; }
@media (orientation: landscape) and (max-height: 560px) {
  .podium-step { font-size: 15px; padding-top: 2px; }
}
