/* ============================================================
   WORD SPY — skribbl.io-inspired UI
   ------------------------------------------------------------
   Bright friendly game aesthetic:
   - Sky-blue gradient background
   - Chunky rounded white panels with soft drop shadows
   - Colorful multi-color logo letters with thick white outlines
   - 3D press-in buttons (darker bottom shadow → press down)
   - Rounded display typography (Baloo 2) + Nunito body
   - Primary blue + yellow + green + red accents
   ============================================================ */

:root {
  /* Backgrounds */
  --bg-top: #a0cbff;
  --bg-mid: #bddaff;
  --bg-bot: #dcebff;
  --white: #ffffff;
  --panel: #ffffff;

  /* Text */
  --ink: #1f2f4c;
  --ink-soft: #38476a;
  --muted: #7a89a8;
  --muted-soft: #9aa7c3;

  /* Primary brand */
  --blue: #1e9df5;
  --blue-dark: #0f78c4;
  --blue-darker: #0a5a95;
  --blue-soft: #d5ecff;

  --yellow: #ffcb05;
  --yellow-dark: #d9a500;

  --green: #38c668;
  --green-dark: #219a48;

  --red: #ff5252;
  --red-dark: #d63434;

  --purple: #8b5cf6;
  --purple-dark: #6a3fd1;

  --orange: #ff9233;
  --orange-dark: #d96b14;

  --pink: #ff5c9a;
  --pink-dark: #d63574;

  /* Structural */
  --border: #dbe6f5;
  --border-soft: #eaf2ff;
  --border-strong: #b8c8e3;

  --shadow-card: 0 6px 0 #c5d6ee, 0 14px 32px rgba(31, 47, 76, 0.14);
  --shadow-tile: 0 4px 0 #c5d6ee, 0 8px 18px rgba(31, 47, 76, 0.10);
  --shadow-btn-h: 5px;

  /* Type */
  --f-display: 'Baloo 2', 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --f-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', 'Courier New', monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--f-body);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(circle 600px at 85% 15%, rgba(255, 203, 5, 0.20), transparent 65%),
    radial-gradient(circle 520px at 10% 80%, rgba(139, 92, 246, 0.16), transparent 65%),
    radial-gradient(circle 440px at 95% 90%, rgba(255, 92, 154, 0.14), transparent 60%),
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--bg-mid), transparent 70%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bot) 100%);
  background-attachment: fixed;
}

/* Subtle dot pattern overlay for playful depth */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.35) 1.2px, transparent 1.5px);
  background-size: 26px 26px;
  opacity: 0.7;
  z-index: 0;
}

/* ---------- Layout ---------- */

main {
  position: relative;
  z-index: 2;
  max-width: 560px;
  margin: 0 auto;
  padding: max(32px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 100dvh;
}

.page-landing main { max-width: 960px; }
.page-room main { max-width: 1080px; }

/* ---------- Brand / landing header ---------- */

.brand {
  position: relative;
  text-align: center;
  padding-top: 28px;
}

.brand-title-wrap {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
}

/* Floating decorative shapes around the logo */
.brand-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: visible;
}

.deco {
  position: absolute;
  font-family: var(--f-display);
  font-weight: 800;
  line-height: 1;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(15, 23, 42, 0.22);
  user-select: none;
}

.deco-1 { top: -8%;  left: 3%;   font-size: 2.2rem; color: var(--pink);   animation: bob1 4.2s ease-in-out infinite; }
.deco-2 { top: -14%; right: 4%;  font-size: 2.6rem; color: var(--green);  animation: bob2 5s   ease-in-out infinite; }
.deco-3 { top: 72%;  left: 2%;   font-size: 1.9rem; color: var(--purple); animation: bob3 4.6s ease-in-out infinite; }
.deco-4 { top: 62%;  right: 2%;  font-size: 2.4rem; color: var(--orange); animation: bob4 5.4s ease-in-out infinite; }
.deco-5 { top: 28%;  right: 10%; font-size: 1.5rem; color: var(--yellow); animation: bob5 4s   ease-in-out infinite; }

@keyframes bob1 {
  0%, 100% { transform: translateY(0)    rotate(-18deg); }
  50%      { transform: translateY(-9px) rotate(-14deg); }
}
@keyframes bob2 {
  0%, 100% { transform: translateY(0)     rotate(14deg); }
  50%      { transform: translateY(-11px) rotate(18deg); }
}
@keyframes bob3 {
  0%, 100% { transform: translateY(0)    rotate(-10deg); }
  50%      { transform: translateY(-8px) rotate(-6deg); }
}
@keyframes bob4 {
  0%, 100% { transform: translateY(0)     rotate(22deg); }
  50%      { transform: translateY(-10px) rotate(18deg); }
}
@keyframes bob5 {
  0%, 100% { transform: translateY(0)    rotate(0deg); }
  50%      { transform: translateY(-12px) rotate(20deg); }
}

.brand-title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.6rem, 12vw, 6rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 2px;
  user-select: none;
  max-width: 100%;
  padding: 0 6px;
}

.brand-title .letter {
  display: inline-block;
  color: var(--white);
  -webkit-text-stroke: 0.14em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.13em 0 rgba(15, 23, 42, 0.28);
  transform: translateY(0);
  transition: transform 0.3s var(--ease);
  position: relative;
  z-index: 2;
}

/* "WORD" stays white, "SPY" gets the accent color */
.brand-title .letter.c5,
.brand-title .letter.c6,
.brand-title .letter.c7 {
  color: var(--yellow);
}

/* Wonky rotation per letter for the hand-drawn feel */
.brand-title .letter.c1 { transform: rotate(-4deg); }
.brand-title .letter.c2 { transform: rotate(2deg); }
.brand-title .letter.c3 { transform: rotate(-2deg); }
.brand-title .letter.c4 { transform: rotate(3deg); }
.brand-title .letter.c5 { transform: rotate(-3deg); }
.brand-title .letter.c6 { transform: rotate(2deg); }
.brand-title .letter.c7 { transform: rotate(-4deg); }

.brand-title .letter:hover {
  transform: translateY(-6px) rotate(0deg);
}

.brand-title .letter-gap {
  display: inline-block;
  width: 0.4em;
}

.tagline {
  color: var(--ink-soft);
  max-width: 40ch;
  margin: 22px auto 0;
  font-size: 1.02rem;
  line-height: 1.55;
  font-weight: 600;
}

/* ---------- Card / panel ---------- */

.card {
  position: relative;
  background: var(--panel);
  border: 3px solid var(--white);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: var(--shadow-card);
  animation: rise 0.55s var(--ease) both;
}

.card h2 {
  font-family: var(--f-display);
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0.005em;
  line-height: 1.1;
  margin: 0 0 8px;
  color: var(--ink);
}

.card-wide { padding: 26px 22px; }
.card-center { text-align: center; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--blue-soft);
  border-radius: 14px;
  margin-bottom: 22px;
}

.tab {
  flex: 1;
  background: transparent;
  color: var(--ink-soft);
  border: none;
  padding: 11px 14px;
  border-radius: 10px;
  font-family: var(--f-display);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.15s var(--ease), background 0.2s var(--ease), box-shadow 0.15s;
}

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

.tab.active {
  background: var(--white);
  color: var(--blue-dark);
  box-shadow: 0 3px 0 #c5d6ee, 0 4px 12px rgba(31, 47, 76, 0.08);
}

/* ---------- Panels / form ---------- */

.panel {
  display: none;
  flex-direction: column;
  gap: 18px;
  animation: fade 0.25s var(--ease);
}

.panel.active { display: flex; }

@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-family: var(--f-body);
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-weight: 800;
  display: flex;
  justify-content: space-between;
  align-items: center;
  letter-spacing: 0.01em;
}

.field-label em {
  color: var(--blue-dark);
  font-style: normal;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.05em;
  padding: 2px 10px;
  background: var(--blue-soft);
  border-radius: 999px;
}

/* Text input */
.field input[type='text'] {
  background: var(--white);
  border: 3px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  padding: 14px 16px;
  font-family: var(--f-body);
  font-size: 1.05rem;
  font-weight: 700;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  box-shadow: 0 3px 0 var(--border);
}

.field input[type='text']:focus {
  border-color: var(--blue);
  box-shadow: 0 3px 0 var(--blue-soft), 0 0 0 4px rgba(30, 157, 245, 0.14);
}

.field input[type='text']::placeholder {
  color: var(--muted-soft);
  font-weight: 600;
}

#join-code {
  text-transform: uppercase;
  letter-spacing: 0.4em;
  text-align: center;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--blue-dark);
}

/* Range slider */
.field input[type='range'] {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  background: var(--blue-soft);
  border-radius: 999px;
  outline: none;
  margin: 8px 0 0;
  border: none;
}

.field input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 3px solid var(--white);
  box-shadow: 0 3px 0 var(--blue-darker);
  transition: transform 0.12s var(--ease);
}
.field input[type='range']::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}
.field input[type='range']::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
  border: 3px solid var(--white);
  box-shadow: 0 3px 0 var(--blue-darker);
}

.range-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  margin-top: 6px;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 0.96rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
}

.field-check input {
  appearance: none;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  background: var(--white);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  border-radius: 7px;
  box-shadow: 0 2px 0 var(--border);
  transition: all 0.12s var(--ease);
}
.field-check input:checked {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 2px 0 var(--green-dark);
}
.field-check input:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 900;
  font-size: 1rem;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 26px;
  border-radius: 14px;
  font-family: var(--f-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: none;
  cursor: pointer;
  text-decoration: none;
  width: 100%;
  color: var(--white);
  position: relative;
  transition: transform 0.1s var(--ease), box-shadow 0.1s var(--ease), filter 0.15s;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* Primary = blue */
.btn-primary {
  background: var(--blue);
  box-shadow: 0 5px 0 var(--blue-dark), 0 8px 18px rgba(14, 120, 196, 0.25);
}
.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 6px 0 var(--blue-dark), 0 10px 22px rgba(14, 120, 196, 0.3);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--blue-dark), 0 4px 10px rgba(14, 120, 196, 0.18);
}

/* Secondary = white/slate */
.btn-secondary {
  background: var(--white);
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 5px 0 var(--border-strong), 0 8px 18px rgba(31, 47, 76, 0.1);
}
.btn-secondary:hover:not(:disabled) {
  filter: brightness(0.98);
  transform: translateY(-1px);
  box-shadow: 0 6px 0 var(--border-strong), 0 10px 22px rgba(31, 47, 76, 0.14);
}
.btn-secondary:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--border-strong), 0 4px 10px rgba(31, 47, 76, 0.08);
}

/* ---------- Error & muted ---------- */

.error {
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 14px 0 0;
  padding: 12px 16px;
  background: var(--red);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--red-dark);
}

.muted {
  color: var(--muted);
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.5;
  font-weight: 600;
}

.small { font-size: 0.86rem; margin-top: 12px; }

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: auto;
  padding-top: 16px;
}

/* ============================================================
   ROOM PAGE
   ============================================================ */

.room-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--white);
  border: 3px solid var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.leave {
  font-family: var(--f-display);
  font-size: 0.95rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 700;
  transition: color 0.15s, background 0.15s;
}
.leave:hover {
  color: var(--red);
  background: #ffe7e7;
}

.room-code-block {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.room-code-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.room-code {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: 0.22em;
  color: var(--blue-dark);
  line-height: 1;
}

.copy-btn {
  background: var(--blue-soft);
  color: var(--blue-dark);
  border: none;
  padding: 4px 12px;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
  margin-top: 3px;
  border-radius: 8px;
  transition: all 0.12s var(--ease);
  box-shadow: 0 2px 0 #c4dbef;
}
.copy-btn:hover {
  background: var(--blue);
  color: var(--white);
  box-shadow: 0 2px 0 var(--blue-dark);
}
.copy-btn.copied {
  background: var(--green);
  color: var(--white);
  box-shadow: 0 2px 0 var(--green-dark);
}

.round-badge {
  font-family: var(--f-display);
  font-size: 0.9rem;
  font-weight: 800;
  padding: 8px 14px;
  background: var(--yellow);
  color: var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--yellow-dark);
}

.view { animation: fade 0.3s var(--ease); }

/* Lobby players */
.players {
  list-style: none;
  padding: 0;
  margin: 18px 0 4px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.players li {
  background: var(--blue-soft);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  box-shadow: 0 3px 0 #c4dbef;
  animation: rise 0.35s var(--ease) both;
  color: var(--ink);
}

.players li.host {
  background: #fff5cc;
  box-shadow: 0 3px 0 var(--yellow-dark);
}
.players li.host::before {
  content: '★';
  color: var(--yellow-dark);
  font-size: 1.05rem;
}

.players li .pname {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.players li .pscore {
  font-family: var(--f-display);
  font-size: 0.82rem;
  color: var(--white);
  background: var(--blue);
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}

.host-only { margin-top: 22px; }
[hidden] { display: none !important; }

#lobby-host-controls { text-align: center; }
#lobby-wait-msg { text-align: center; margin-top: 14px; }

/* ---------- Reveal card (flip card) ---------- */

.reveal-card {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 4 / 5;
  margin: 22px auto;
  position: relative;
  perspective: 1200px;
  cursor: pointer;
}

.reveal-front, .reveal-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transition: transform 0.75s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  border-radius: 22px;
}

.reveal-front {
  background: linear-gradient(160deg, var(--blue), var(--purple));
  box-shadow:
    0 8px 0 var(--blue-darker),
    0 14px 30px rgba(14, 120, 196, 0.35),
    inset 0 0 0 5px var(--white);
  flex-direction: column;
  gap: 28px;
}

.reveal-front-mark {
  font-family: var(--f-display);
  font-size: clamp(6rem, 22vw, 9rem);
  font-weight: 800;
  color: var(--white);
  line-height: 0.8;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.2);
  -webkit-text-stroke: 3px rgba(0, 0, 0, 0.1);
  paint-order: stroke fill;
  transform: translateY(8px);
}

.reveal-tap {
  font-family: var(--f-display);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.22);
  padding: 8px 18px;
  border-radius: 999px;
  white-space: nowrap;
}

.reveal-back {
  background: var(--white);
  transform: rotateY(180deg);
  flex-direction: column;
  text-align: center;
  gap: 14px;
  box-shadow:
    0 8px 0 #c5d6ee,
    0 14px 30px rgba(31, 47, 76, 0.18),
    inset 0 0 0 5px var(--blue-soft);
}

.reveal-card.flipped .reveal-front { transform: rotateY(180deg); }
.reveal-card.flipped .reveal-back { transform: rotateY(0); }

.reveal-back-label {
  font-family: var(--f-body);
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.reveal-word {
  font-family: var(--f-display);
  font-size: clamp(2.2rem, 9vw, 3.2rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--blue-dark);
  padding: 0 12px;
  -webkit-text-stroke: 3px var(--white);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(31, 47, 76, 0.14);
}

.reveal-hint {
  font-family: var(--f-body);
  font-weight: 800;
  color: var(--blue-dark);
  font-size: 0.85rem;
  padding: 5px 14px;
  background: var(--blue-soft);
  border-radius: 999px;
}

/* ---------- Timer ---------- */

.timer {
  font-family: var(--f-display);
  font-size: clamp(3.2rem, 10vw, 4.4rem);
  font-weight: 800;
  text-align: center;
  margin: 18px 0 12px;
  color: var(--blue-dark);
  line-height: 1;
  -webkit-text-stroke: 3px var(--white);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(31, 47, 76, 0.14);
}

.timer.low {
  color: var(--red);
  animation: pulseFast 0.8s ease-in-out infinite;
}

@keyframes pulseFast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.timer-bar {
  height: 12px;
  background: var(--blue-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 22px;
  box-shadow: inset 0 2px 4px rgba(31, 47, 76, 0.1);
}

.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), var(--orange));
  transition: width 1s linear;
  border-radius: 999px;
}

/* ---------- Discussion turn order ---------- */

.turn-order {
  background: var(--blue-soft);
  border-radius: 14px;
  padding: 14px 18px;
  margin-top: 8px;
  text-align: left;
}

.turn-label {
  font-family: var(--f-body);
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.02em;
  display: block;
  margin-bottom: 4px;
}

.turn-order ol {
  margin: 4px 0 0;
  padding-left: 24px;
  color: var(--ink);
  font-weight: 700;
}

.turn-order li {
  padding: 4px 0;
  transition: opacity 0.2s, color 0.2s;
}
.turn-order li::marker {
  color: var(--blue-dark);
  font-weight: 800;
}
.turn-order li.past-speaker {
  opacity: 0.45;
  text-decoration: line-through;
  color: var(--muted);
}
.turn-order li.current-speaker {
  color: var(--blue-dark);
  font-weight: 900;
}
.turn-order li.current-speaker::marker {
  content: '▶ ';
  color: var(--red);
}

/* Current speaker headline block */
.current-speaker-block {
  margin: 14px auto 8px;
  padding: 12px 18px;
  background: var(--blue-soft);
  border-radius: 14px;
  display: inline-block;
  min-width: 60%;
  box-shadow: 0 3px 0 #c4dbef;
}

.current-speaker-label {
  font-family: var(--f-body);
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: block;
}

.lap-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 10px;
  background: var(--yellow);
  color: var(--ink);
  border-radius: 999px;
  font-family: var(--f-display);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  font-weight: 800;
  vertical-align: 1px;
  box-shadow: 0 2px 0 var(--yellow-dark);
}

.current-speaker-name {
  font-family: var(--f-display);
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 800;
  color: var(--blue-dark);
  line-height: 1.05;
  margin-top: 2px;
}

/* Next-turn button row */
.next-row {
  margin: 16px 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.next-row .btn { width: 100%; }

#disc-host-controls { margin-top: 14px; }

/* ---------- Voting (ballot) ---------- */

.vote-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 10px;
}

.vote-list li {
  background: var(--white);
  border: 3px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.12s var(--ease);
  user-select: none;
  box-shadow: 0 4px 0 var(--border);
  border-radius: 14px;
  font-weight: 800;
  color: var(--ink);
}

.vote-list li:hover {
  background: var(--yellow);
  border-color: var(--yellow-dark);
  transform: translateY(-1px);
  box-shadow: 0 5px 0 var(--yellow-dark);
}

.vote-list li.selected {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue-dark);
  box-shadow: 0 4px 0 var(--blue-darker);
}
.vote-list li.selected .vcount {
  background: var(--white);
  color: var(--blue-dark);
}

.vote-list li.self {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--blue-soft);
  border-color: var(--border);
}

.vote-list .vname { font-weight: 800; }
.vote-list .vcount {
  font-family: var(--f-display);
  font-size: 0.75rem;
  color: var(--white);
  background: var(--green);
  padding: 3px 12px;
  font-weight: 800;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

.tie-banner {
  background: var(--red);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 14px;
  text-align: center;
  font-family: var(--f-display);
  font-size: 1.15rem;
  font-weight: 800;
  margin: 4px 0 16px;
  box-shadow: 0 4px 0 var(--red-dark);
  letter-spacing: 0.02em;
  animation: pulseFast 1.1s ease-in-out infinite;
}

/* ---------- Results ---------- */

.results-spy {
  background: var(--blue-soft);
  border-radius: 18px;
  padding: 22px 20px;
  margin: 20px 0;
  text-align: center;
}

.results-accused {
  font-family: var(--f-body);
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}
.results-accused span {
  color: var(--ink);
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.05rem;
}

.results-spy-name {
  font-family: var(--f-display);
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  font-weight: 800;
  color: var(--red);
  margin: 10px 0 14px;
  line-height: 1.1;
  -webkit-text-stroke: 3px var(--white);
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(31, 47, 76, 0.12);
}

.results-spy-word, .results-civ-word {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 5px 0;
  font-weight: 700;
}
.results-spy-word span, .results-civ-word span {
  color: var(--blue-dark);
  font-family: var(--f-display);
  font-size: 1.05rem;
  font-weight: 800;
}

.results-outcome {
  text-align: center;
  padding: 16px;
  margin-bottom: 16px;
  font-family: var(--f-display);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border-radius: 14px;
  color: var(--white);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.16);
}
.results-outcome.caught {
  background: var(--green);
  box-shadow: 0 5px 0 var(--green-dark);
}
.results-outcome.escaped {
  background: var(--red);
  box-shadow: 0 5px 0 var(--red-dark);
}
.results-outcome.tied {
  background: var(--yellow);
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 5px 0 var(--yellow-dark);
}

.scoreboard {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  gap: 8px;
}

.scoreboard li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--border);
  font-weight: 700;
  color: var(--ink);
}

.scoreboard li .sname { font-weight: 800; }
.scoreboard li .sscore {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--blue-dark);
  background: var(--blue-soft);
  padding: 2px 12px;
  border-radius: 999px;
  min-width: 34px;
  text-align: center;
}

.scoreboard li.top {
  background: #fff5cc;
  border-color: var(--yellow-dark);
  box-shadow: 0 3px 0 var(--yellow-dark);
}
.scoreboard li.top .sname::before { content: '👑 '; }
.scoreboard li.top .sscore {
  background: var(--yellow);
  color: var(--white);
}

#results-nav-controls { margin-top: 8px; }
#results-nav-controls .btn + .btn { margin-top: 12px; }

/* ============================================================
   LANDING: name bar + lobby grid + public server browser + modal
   ============================================================ */

.name-bar {
  margin: 6px auto 0;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.name-bar label { text-align: center; color: var(--ink-soft); }
.name-bar input {
  background: var(--white);
  border: 3px solid var(--border);
  border-radius: 12px;
  color: var(--ink);
  padding: 12px 16px;
  font-family: var(--f-body);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 3px 0 var(--border);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.name-bar input:focus {
  border-color: var(--blue);
  box-shadow: 0 3px 0 var(--blue-soft), 0 0 0 4px rgba(30, 157, 245, 0.14);
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 22px;
  align-items: start;
}

.lobby-side { min-width: 0; }
.lobby-main { min-width: 0; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 12px;
}
.card-head-count {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 4px 12px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  border-radius: 999px;
}
.small-lead {
  margin: 0 0 14px;
  font-size: 0.9rem;
}

/* Server list */
.server-list {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
  display: grid;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  padding-right: 4px;
}

.server-list::-webkit-scrollbar { width: 10px; }
.server-list::-webkit-scrollbar-track { background: var(--blue-soft); border-radius: 999px; }
.server-list::-webkit-scrollbar-thumb { background: var(--blue); border-radius: 999px; border: 2px solid var(--blue-soft); }

.server-empty {
  text-align: center;
  padding: 28px 14px;
  color: var(--muted);
  font-weight: 700;
  background: var(--blue-soft);
  border-radius: 14px;
  font-size: 0.95rem;
}

.server-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 3px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 3px 0 var(--border);
  transition: all 0.12s var(--ease);
}
.server-row:hover {
  border-color: var(--blue);
  box-shadow: 0 4px 0 var(--blue-dark);
}

.server-meta { min-width: 0; }
.server-name {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-sub {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.server-mode {
  color: var(--blue-dark);
}
.server-dot { opacity: 0.5; }

.server-count {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--blue-soft);
  padding: 4px 12px;
  border-radius: 999px;
  min-width: 54px;
  text-align: center;
}

.server-join {
  width: auto;
  padding: 10px 16px;
  font-size: 0.92rem;
}
.server-join:disabled {
  background: var(--muted-soft);
  box-shadow: 0 4px 0 #6a7691;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 30, 55, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade 0.2s var(--ease);
}

.modal {
  position: relative;
  background: var(--panel);
  border: 3px solid var(--white);
  border-radius: 22px;
  padding: 26px 22px 22px;
  box-shadow: var(--shadow-card);
  width: 100%;
  max-width: 420px;
  max-height: 92dvh;
  overflow-y: auto;
  animation: rise 0.35s var(--ease) both;
}

.modal h3 {
  margin: 0 0 14px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.6rem;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  font-family: var(--f-display);
  font-weight: 800;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { color: var(--red); background: #ffe7e7; }

.modal .field { margin-bottom: 14px; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.modal-actions .btn { flex: 1; }

/* Mode toggle buttons */
.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}
.mode-btn {
  background: var(--white);
  border: 3px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--ink);
  box-shadow: 0 3px 0 var(--border);
  transition: all 0.12s var(--ease);
}
.mode-btn:hover { border-color: var(--blue); }
.mode-btn.active {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue-dark);
  box-shadow: 0 3px 0 var(--blue-darker);
}

/* ============================================================
   ROOM: grid layout, spectator banner, chat panel, canvas
   ============================================================ */

.room-grid {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 20px;
  align-items: start;
}

.room-main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.spectator-banner {
  background: #fff5cc;
  border: 2.5px solid var(--yellow-dark);
  border-radius: 14px;
  padding: 10px 14px;
  text-align: center;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.95rem;
  color: #7a5b0f;
  box-shadow: 0 3px 0 var(--yellow-dark);
}

/* Public-room auto-start countdown */
.public-countdown {
  margin: 16px auto 6px;
  text-align: center;
  padding: 14px 16px;
  background: var(--blue-soft);
  border-radius: 14px;
  box-shadow: 0 3px 0 #c4dbef;
}
.public-countdown-label {
  font-family: var(--f-display);
  font-weight: 800;
  color: var(--blue-dark);
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.public-countdown-num {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(3rem, 8vw, 4rem);
  line-height: 1;
  margin-top: 6px;
  color: var(--blue-dark);
  -webkit-text-stroke: 0.12em var(--white);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(31, 47, 76, 0.14);
}
.public-countdown-num.low {
  color: var(--red);
  animation: pulseFast 0.6s ease-in-out infinite;
}

/* Chat panel */
.chat-panel {
  background: var(--panel);
  border: 3px solid var(--white);
  border-radius: 22px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: calc(100dvh - 160px);
  position: sticky;
  top: 20px;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 6px 10px;
  border-bottom: 2px dashed var(--border);
  margin-bottom: 8px;
}
.chat-title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--ink);
}
.chat-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

/* Side players list (inside chat panel) */
.side-players {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 4px 10px;
  margin-bottom: 8px;
  border-bottom: 2px dashed var(--border);
}

.side-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0 4px 4px;
}
.side-section-title {
  font-family: var(--f-body);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.side-section-count {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--blue-soft);
  padding: 1px 8px;
  border-radius: 999px;
}

.side-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}
.side-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 10px;
  background: var(--blue-soft);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}
.side-list li.is-host .side-name::before {
  content: '★ ';
  color: var(--yellow-dark);
}
.side-list li.is-me {
  background: #fff3cc;
  outline: 2px solid var(--yellow);
}
.side-list-spec li {
  background: #ececec;
  color: var(--muted);
  font-style: italic;
}
.side-list-spec li.is-me {
  background: #fff3cc;
  font-style: normal;
  color: var(--ink);
}
.side-list .side-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.side-list .side-score {
  font-family: var(--f-display);
  font-weight: 800;
  color: var(--blue-dark);
  background: var(--white);
  padding: 1px 8px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
  font-size: 0.78rem;
}

/* Spectate toggle button */
.spectate-btn {
  background: var(--white);
  border: 2.5px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px;
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 0.88rem;
  color: var(--ink-soft);
  cursor: pointer;
  margin-bottom: 8px;
  box-shadow: 0 3px 0 var(--border);
  transition: all 0.12s var(--ease);
  width: 100%;
}
.spectate-btn:hover {
  border-color: var(--blue);
  color: var(--blue-dark);
}
.spectate-btn.active {
  background: var(--yellow);
  border-color: var(--yellow-dark);
  color: var(--ink);
  box-shadow: 0 3px 0 var(--yellow-dark);
}

.chat-messages {
  list-style: none;
  padding: 0 6px;
  margin: 0;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chat-messages::-webkit-scrollbar { width: 8px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.chat-msg {
  padding: 6px 10px;
  background: var(--blue-soft);
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--ink);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.chat-msg-self { background: #fff3cc; }
.chat-msg-spec { background: #ececec; color: var(--muted); font-style: italic; }

.chat-author {
  font-weight: 800;
  color: var(--blue-dark);
  margin-right: 6px;
}
.chat-msg-self .chat-author { color: var(--yellow-dark); }
.chat-msg-spec .chat-author { color: var(--muted); }

.spec-badge {
  font-size: 0.68rem;
  background: var(--muted);
  color: var(--white);
  padding: 0 6px;
  border-radius: 999px;
  font-style: normal;
  font-weight: 800;
  vertical-align: 1px;
}

.chat-form {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.chat-form input {
  flex: 1;
  background: var(--white);
  border: 2.5px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  padding: 10px 12px;
  font-family: var(--f-body);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  box-shadow: 0 2px 0 var(--border);
  min-width: 0;
}
.chat-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 2px 0 var(--blue-soft), 0 0 0 3px rgba(30, 157, 245, 0.14);
}
.chat-form input:disabled {
  background: #eef2f8;
  color: var(--muted);
  cursor: not-allowed;
}
.chat-send {
  width: auto !important;
  padding: 10px 16px !important;
  font-size: 1rem !important;
  flex-shrink: 0;
}

.chat-warning {
  background: var(--red);
  color: var(--white);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 10px;
  margin: 6px 0 0;
  text-align: center;
  animation: fade 0.2s var(--ease);
}

/* ============================================================
   DRAW STAGE
   ============================================================ */

.draw-stage {
  margin: 18px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#draw-canvas {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 14px;
  max-width: 100%;
  height: auto;
  touch-action: none;
  box-shadow: 0 4px 0 var(--border);
  cursor: crosshair;
}

.draw-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 2.5px solid var(--ink);
  background: var(--white);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 3px 0 var(--border);
  transition: transform 0.1s var(--ease), box-shadow 0.1s var(--ease);
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--ink);
}
.tool-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 0 var(--border); }
.tool-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--border); }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.tool-btn.color-btn.active {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.tool-btn .dot-sm { width: 6px; height: 6px; background: var(--ink); border-radius: 50%; }
.tool-btn .dot-lg { width: 14px; height: 14px; background: var(--ink); border-radius: 50%; }

.tool-btn#draw-size-sm.active,
.tool-btn#draw-size-lg.active {
  background: var(--yellow);
}

.tool-btn.tool-clear {
  width: auto;
  padding: 0 12px;
}

.draw-hint {
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
}

/* ---------- Small screens ---------- */

/* Stack the lobby grid and room grid on anything below ~900px */
@media (max-width: 900px) {
  .page-landing main { max-width: 560px; }
  .page-room main { max-width: 720px; }
  .lobby-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .room-grid {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .chat-panel {
    position: static;
    max-height: 340px;
    min-height: 280px;
  }
}

@media (max-width: 560px) {
  main { padding: 20px 16px; gap: 18px; }
  .card { padding: 22px 18px; border-radius: 20px; }
  .brand { padding-top: 14px; }
  .brand-title { font-size: clamp(2.4rem, 13vw, 4.5rem); }
  /* Shrink and tuck decorations closer on narrow screens */
  .deco-1 { font-size: 1.6rem; top: -6%; left: 2%; }
  .deco-2 { font-size: 2rem;   top: -12%; right: 3%; }
  .deco-3 { font-size: 1.4rem; top: 75%;  left: 1%; }
  .deco-4 { font-size: 1.8rem; top: 65%;  right: 1%; }
  .deco-5 { font-size: 1.2rem; top: 20%;  right: 6%; }
  .players { grid-template-columns: 1fr 1fr; }
  .room-header {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 12px 14px;
  }
  .room-code { font-size: 1.3rem; letter-spacing: 0.2em; }
  .leave, .round-badge { font-size: 0.82rem; padding: 6px 10px; }
  .reveal-card { max-width: 260px; }
  .server-row { grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 8px 12px; }
  .server-row .server-join { grid-column: 1 / -1; width: 100%; }
  #draw-canvas { width: 100%; max-width: 100%; }
}

/* On very narrow iPhones, hide the side decorations so they don't
   crowd the logo. Keep only the above/below-logo ones. */
@media (max-width: 380px) {
  .brand-title { font-size: clamp(2.2rem, 14vw, 4rem); }
  .deco-3, .deco-4 { display: none; }
}
