:root {
  --bg-deep: #090d16;
  --bg-surface: #111827;
  --bg-card: #182235;
  --bg-card-elevated: #1e293b;
  --bg-input: #0b1120;
  --border-subtle: rgba(148, 163, 184, 0.16);
  --border-bright: rgba(148, 163, 184, 0.32);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.35);

  /* Strict Contexto Semantic Color Tiers */
  --tier-gold-start: #f59e0b;
  --tier-gold-end: #10b981;
  --tier-green-fill: linear-gradient(90deg, rgba(16, 185, 129, 0.88) 0%, rgba(5, 150, 105, 0.95) 100%);
  --tier-green-border: #10b981;
  --tier-yellow-fill: linear-gradient(90deg, rgba(245, 158, 11, 0.85) 0%, rgba(217, 119, 6, 0.95) 100%);
  --tier-yellow-border: #f59e0b;
  --tier-red-fill: linear-gradient(90deg, rgba(239, 68, 68, 0.82) 0%, rgba(185, 28, 28, 0.92) 100%);
  --tier-red-border: #ef4444;
  --tier-gray-track: #161f30;
  --tier-gray-border: rgba(148, 163, 184, 0.18);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html,
body {
  min-height: 100%;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(99, 102, 241, 0.14), transparent 35%),
    radial-gradient(circle at 88% 12%, rgba(16, 185, 129, 0.1), transparent 35%);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ==========================================
   TOP BAR & MODE SWITCHER
   ========================================== */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(17, 24, 39, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 30;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #10b981);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  color: #fff;
}

.brand-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.mode-switcher {
  display: inline-flex;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

/* ==========================================
   MAIN VIEWS
   ========================================== */
.app-main {
  width: 100%;
  max-width: 1760px;
  margin: 0 auto;
  padding: 18px 24px 48px;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* ==========================================
   MODERN WEB GUIDANCE: STATE-AWARE STICKY HEADERS
   ========================================== */
/* Disable scroll anchoring on the direct parent of position: sticky to prevent scroll oscillation */
.mobile-controller-section,
.solo-controller-section,
.mobile-game-wrapper,
.solo-container {
  overflow-anchor: none;
}

.sticky-container {
  position: sticky;
  top: 0;
  /* MANDATORY: Always specify a container name to avoid collisions if CQs are nested */
  container-type: scroll-state;
  container-name: mobile-top-bar;
  z-index: 20;
  margin-bottom: 14px;
}

.sticky-header {
  background: rgba(24, 34, 53, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease, padding 0.2s ease, border-radius 0.2s ease;
}

/* Apply styles when the named container is stuck at the top */
@container mobile-top-bar scroll-state(stuck: top) {
  .sticky-header {
    background: rgba(11, 17, 32, 0.98);
    border-color: rgba(99, 102, 241, 0.55);
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    padding: 9px 12px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(99, 102, 241, 0.25);
  }
}

/* IntersectionObserver Fallback for browsers without scroll-state queries */
.sticky-container.is-stuck .sticky-header {
  background: rgba(11, 17, 32, 0.98);
  border-color: rgba(99, 102, 241, 0.55);
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  padding: 9px 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(99, 102, 241, 0.25);
}

/* ==========================================
   MODERN WEB GUIDANCE: DYNAMIC SIBLING ANIMATIONS
   ========================================== */
@keyframes bar-drop-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stagger-list > .guess-bar-item,
.tv-columns-grid > .tv-player-column {
  --stagger-time: 0.035s;
  animation: bar-drop-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--sibling-index, 1) * var(--stagger-time, 0.035s));
  animation-delay: calc(sibling-index() * var(--stagger-time, 0.035s));
}

@media (prefers-reduced-motion: reduce) {
  .stagger-list > .guess-bar-item,
  .tv-columns-grid > .tv-player-column,
  .guess-bar-item,
  .winner-banner {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================
   TV HOST SCREEN STYLES
   ========================================== */
.tv-control-deck {
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(240px, 0.85fr) minmax(380px, 1.4fr);
  gap: 18px;
  margin-bottom: 16px;
}

.tv-room-badge-card,
.tv-clock-card,
.tv-host-controls {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.tv-room-badge-card {
  display: flex;
  align-items: center;
  gap: 18px;
}

.tv-qr-box {
  width: 108px;
  height: 108px;
  flex-shrink: 0;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.tv-qr-box:hover {
  transform: scale(1.04);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.3);
}

.tv-qr-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tv-qr-placeholder {
  color: #0f172a;
  font-weight: 800;
  font-size: 0.9rem;
}

.tv-room-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.tv-room-label {
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #818cf8;
  text-transform: uppercase;
}

.tv-room-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tv-room-code {
  font-family: var(--font-mono);
  font-size: 2.85rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 0 24px rgba(99, 102, 241, 0.45);
}

.tv-join-url {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #fff;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Center Clock Card */
.tv-clock-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}

.tv-round-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.badge-round {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.badge-status {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-status.playing {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
  border-color: rgba(245, 158, 11, 0.45);
}

.tv-timer-display {
  font-family: var(--font-mono);
  font-size: 3.1rem;
  font-weight: 800;
  line-height: 1.05;
  color: #fff;
  letter-spacing: 0.04em;
}

.tv-timer-display.urgent {
  color: #f87171;
  animation: urgent-pulse 0.85s infinite alternate;
}

@keyframes urgent-pulse {
  from {
    transform: scale(1);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
  }
  to {
    transform: scale(1.05);
    text-shadow: 0 0 24px rgba(239, 68, 68, 0.9);
  }
}

.tv-timer-progress-track {
  width: 100%;
  height: 7px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.tv-timer-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #6366f1);
  transition: width 0.4s linear;
}

/* Right Host Controls */
.tv-host-controls {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.host-controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.control-select,
.control-input {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-bright);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
}

.control-select:focus,
.control-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.masked-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mask-toggle-btn {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-bright);
  background: var(--bg-card-elevated);
  color: #fff;
  cursor: pointer;
}

.host-action-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #4f46e5, #4338ca);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
  background: var(--bg-card-elevated);
  color: var(--text-primary);
  border-color: var(--border-bright);
}

.btn-secondary:hover {
  background: #283548;
}

.btn-lg {
  flex: 1;
  padding: 11px 20px;
  font-size: 0.98rem;
}

.btn-xl {
  padding: 14px 24px;
  font-size: 1.08rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* Legend Strip */
.tv-legend-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(17, 24, 39, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.legend-tiers {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tier-pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.tier-pill.tier-gold {
  background: rgba(245, 158, 11, 0.2);
  border-color: #f59e0b;
  color: #fde68a;
}

.tier-pill.tier-green {
  background: rgba(16, 185, 129, 0.18);
  border-color: #10b981;
  color: #a7f3d0;
}

.tier-pill.tier-yellow {
  background: rgba(245, 158, 11, 0.16);
  border-color: #f59e0b;
  color: #fde68a;
}

.tier-pill.tier-red {
  background: rgba(239, 68, 68, 0.16);
  border-color: #ef4444;
  color: #fecaca;
}

.tier-pill.tier-gray {
  background: rgba(148, 163, 184, 0.12);
  border-color: rgba(148, 163, 184, 0.3);
  color: var(--text-muted);
}

/* End of Round Reveal Banner */
.tv-reveal-banner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.18), rgba(99, 102, 241, 0.22));
  border: 2px solid #10b981;
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  margin-bottom: 18px;
  box-shadow: 0 12px 32px rgba(16, 185, 129, 0.2);
}

.reveal-banner-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.reveal-eyebrow {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: #6ee7b7;
  text-transform: uppercase;
}

.reveal-secret-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
}

.reveal-secret-title strong {
  color: #fde047;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  border: 1px solid rgba(253, 224, 71, 0.45);
}

.reveal-highlights {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.highlight-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 0.84rem;
}

.highlight-card strong {
  color: #fff;
}

.reveal-top-words-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.top-word-chip {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: #d1fae5;
}

/* ==========================================
   SIDE-BY-SIDE PLAYER COLUMNS ON TV
   ========================================== */
.tv-columns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(265px, 1fr));
  gap: 16px;
  align-items: start;
}

.tv-empty-lobby {
  grid-column: 1 / -1;
  background: rgba(24, 34, 53, 0.65);
  border: 2px dashed var(--border-bright);
  border-radius: var(--radius-xl);
  padding: 56px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tv-empty-lobby h3 {
  font-size: 1.5rem;
  font-weight: 800;
}

.tv-empty-lobby p {
  color: var(--text-secondary);
  max-width: 520px;
}

.tv-player-column {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: 75vh;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.tv-player-column.solved-column {
  border-color: #f59e0b;
  box-shadow: 0 0 28px rgba(245, 158, 11, 0.28);
}

.tv-column-header {
  padding: 14px 16px;
  background: rgba(15, 23, 42, 0.75);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tv-column-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tv-player-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tv-player-name {
  font-size: 1.18rem;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tv-score-pill {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.2);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.tv-column-sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Winner Banner (#1 Solved) */
@keyframes winner-flash {
  0% {
    background-position: 0% 50%;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.55);
  }
  50% {
    background-position: 100% 50%;
    box-shadow: 0 0 24px rgba(16, 185, 129, 0.75);
  }
  100% {
    background-position: 0% 50%;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.55);
  }
}

.winner-banner {
  width: 100%;
  padding: 10px 14px;
  background: linear-gradient(270deg, #f59e0b, #10b981, #eab308, #059669);
  background-size: 300% 300%;
  animation: winner-flash 2.4s ease infinite;
  color: #06120e;
  font-weight: 900;
  font-size: 0.9rem;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
}

.tv-column-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ==========================================
   PROGRESS BARS & 3D FLIP REVEAL CARDS
   ========================================== */
.guess-bar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess-bar-item {
  position: relative;
  height: 42px;
  perspective: 900px;
  border-radius: var(--radius-sm);
}

.guess-bar-item.is-latest {
  outline: 2px solid #ffffff;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.25);
}

.guess-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.guess-bar-item.is-flipped .guess-card-inner {
  transform: rotateX(180deg);
}

.guess-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--tier-gray-track);
  border: 1px solid var(--tier-gray-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
}

.guess-card-back {
  transform: rotateX(180deg);
}

/* Colored Fill Bar inside the track */
.guess-fill-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100%;
  border-radius: calc(var(--radius-sm) - 1px);
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}

.tier-gold .guess-fill-bar,
.tier-solved .guess-fill-bar {
  background: linear-gradient(270deg, #f59e0b, #10b981, #eab308);
  background-size: 200% 200%;
  animation: winner-flash 2.2s ease infinite;
}

.tier-green .guess-fill-bar {
  background: var(--tier-green-fill);
}

.tier-yellow .guess-fill-bar {
  background: var(--tier-yellow-fill);
}

.tier-red .guess-fill-bar {
  background: var(--tier-red-fill);
}

.tier-gray .guess-fill-bar {
  width: 0% !important;
  background: transparent;
}

.guess-bar-item.tier-gold .guess-card-face,
.guess-bar-item.tier-solved .guess-card-face {
  border-color: #f59e0b;
}

.guess-bar-item.tier-green .guess-card-face {
  border-color: rgba(16, 185, 129, 0.55);
}

.guess-bar-item.tier-yellow .guess-card-face {
  border-color: rgba(245, 158, 11, 0.55);
}

.guess-bar-item.tier-red .guess-card-face {
  border-color: rgba(239, 68, 68, 0.5);
}

/* Foreground Content inside Bar */
.guess-bar-content {
  position: relative;
  z-index: 2;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

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

.guess-num-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  opacity: 0.75;
}

.guess-word-text {
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guess-word-masked {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.28);
  padding: 2px 8px;
  border-radius: 6px;
}

.guess-rank-right {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* ==========================================
   MOBILE CONTROLLER VIEW STYLES
   ========================================== */
.mobile-controller-section,
.solo-controller-section {
  max-width: 600px;
  margin: 0 auto;
}

.mobile-join-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 28px 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.join-card-header {
  text-align: center;
  margin-bottom: 22px;
}

.join-icon {
  font-size: 2.5rem;
  margin-bottom: 6px;
}

.join-card-header h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
}

.join-card-header p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

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

.form-field label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.room-code-input {
  width: 100%;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  background: var(--bg-input);
  border: 2px solid var(--border-bright);
  border-radius: var(--radius-md);
  color: #fff;
  outline: none;
}

.room-code-input:focus,
.player-name-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.player-name-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--bg-input);
  border: 2px solid var(--border-bright);
  border-radius: var(--radius-md);
  color: #fff;
  outline: none;
}

.join-error {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid #ef4444;
  color: #fecaca;
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
}

/* Mini-Leaderboard Bar at Very Top of Mobile Controller */
.mini-leaderboard-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 8px;
  margin-bottom: 8px;
  background: rgba(9, 13, 22, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  scrollbar-width: thin;
  white-space: nowrap;
}

.mini-lb-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
}

.mini-lb-item.is-me {
  border-color: #818cf8;
  background: rgba(99, 102, 241, 0.22);
}

.mini-lb-rank {
  font-family: var(--font-mono);
  font-weight: 800;
}

.mini-lb-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Mobile Status & Fast Guess Input */
.mobile-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mobile-player-identity {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-room-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

.mobile-player-name {
  font-size: 0.95rem;
  font-weight: 800;
}

.mobile-stats-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
}

.stat-timer.urgent {
  color: #f87171;
  border-color: #ef4444;
}

.btn-leave {
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.fast-guess-form {
  display: flex;
  gap: 8px;
}

.fast-guess-input {
  flex: 1;
  min-width: 0;
  padding: 13px 15px;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--bg-input);
  border: 2px solid var(--border-bright);
  border-radius: var(--radius-md);
  color: #ffffff;
  outline: none;
}

.fast-guess-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.fast-guess-submit {
  padding: 0 22px;
  border-radius: var(--radius-md);
  font-size: 1rem;
}

.mobile-feedback-strip {
  margin-top: 8px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 700;
  text-align: center;
}

.mobile-feedback-strip.error {
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid #ef4444;
  color: #fecaca;
}

.mobile-feedback-strip.info {
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid #6366f1;
  color: #e0e7ff;
}

.mobile-feedback-strip.success {
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid #10b981;
  color: #d1fae5;
}

.mobile-round-banner {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(16, 185, 129, 0.22));
  border: 1px solid #10b981;
  margin-bottom: 14px;
  text-align: center;
  font-weight: 700;
}

.mobile-latest-wrap {
  margin-bottom: 14px;
}

.section-caption-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.section-caption {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}

/* ==========================================
   SOLO MODE STYLES
   ========================================== */
.solo-header-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.solo-title-block h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 800;
}

.solo-title-block p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.solo-controls-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.solo-controls-bar .control-select {
  flex: 1;
  min-width: 150px;
}

.solo-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}

.solo-stat {
  background: rgba(9, 13, 22, 0.75);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  text-align: center;
}

.solo-stat-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.solo-stat-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}

/* ==========================================
   MODALS (SCOREBOARD & QR CODE)
   ========================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.82);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  background: var(--bg-card);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

.modal-qr-card {
  max-width: 420px;
  text-align: center;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.qr-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-modal-img {
  width: 280px;
  height: 280px;
  background: #fff;
  padding: 12px;
  border-radius: var(--radius-md);
}

.qr-modal-url {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #a5b4fc;
  word-break: break-all;
}

.scoreboard-table {
  width: 100%;
  border-collapse: collapse;
}

.scoreboard-table th,
.scoreboard-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.scoreboard-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.scoreboard-table td {
  font-weight: 700;
}

/* ==========================================
   RESPONSIVE BREAKPOINTS
   ========================================== */
@media (max-width: 1120px) {
  .tv-control-deck {
    grid-template-columns: 1fr;
  }
  .host-controls-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .app-topbar {
    flex-direction: column;
    padding: 10px 14px;
    gap: 10px;
  }
  .app-main {
    padding: 12px 12px 36px;
  }
  .host-controls-grid {
    grid-template-columns: 1fr;
  }
  .solo-stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==========================================
   AUDIO CONTROLS (TV TOPBAR)
   ========================================== */
.audio-control-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 4px 10px;
}

.audio-toggle-btn {
  font-size: 1.1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  transition: transform var(--transition-fast);
}

.audio-toggle-btn:hover {
  transform: scale(1.15);
}

.volume-slider {
  width: 65px;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #38bdf8;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}

/* ==========================================
   WORD MASTER BANNERS & DASHBOARD
   ========================================== */
.tv-awaiting-banner {
  display: flex;
  align-items: center;
  gap: 18px;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.28));
  border: 2px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: 20px 26px;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px rgba(245, 158, 11, 0.25);
  animation: pulse-border 2s infinite ease-in-out;
}

@keyframes pulse-border {
  0%, 100% { border-color: #f59e0b; box-shadow: 0 12px 32px rgba(245, 158, 11, 0.2); }
  50% { border-color: #fbbf24; box-shadow: 0 12px 40px rgba(251, 191, 36, 0.45); }
}

.awaiting-icon {
  font-size: 2.8rem;
  line-height: 1;
}

.awaiting-text h3 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.awaiting-text p {
  color: #fde68a;
  font-size: 1rem;
}

.highlight-name {
  color: #fde047;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.awaiting-spinner {
  width: 32px;
  height: 32px;
  border: 4px solid rgba(245, 158, 11, 0.3);
  border-top-color: #f59e0b;
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin-left: auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.tv-hint-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, rgba(234, 179, 8, 0.25), rgba(16, 185, 129, 0.2));
  border: 1px solid #eab308;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  margin-bottom: 16px;
  animation: slide-in 0.4s ease-out;
}

.hint-badge {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  background: #eab308;
  color: #0f172a;
  border-radius: var(--radius-full);
}

.hint-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

/* Mobile Word Master Control Dashboard */
.mobile-word-master-panel {
  padding: 4px 0 10px;
}

.wm-active-card {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
  border: 2px solid #f59e0b;
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.25);
}

.wm-crown-badge {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fde047;
  margin-bottom: 12px;
}

.wm-secret-box {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 12px;
}

.wm-secret-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.wm-secret-word {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: #fbbf24;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.wm-instructions {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.wm-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Word Master Setup Modal */
.wm-modal-card {
  max-width: 440px;
  border: 2px solid #f59e0b;
}

.wm-modal-desc {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.45;
}

.wm-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wm-input {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: lowercase;
  border-color: #f59e0b;
}

.wm-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 4px 0;
}

.wm-divider::before,
.wm-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-subtle);
}

.wm-divider span {
  padding: 0 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Word Master Column on TV */
.tv-player-column.is-word-master {
  border-color: #f59e0b;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.2);
}

.wm-column-card {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  color: #fde047;
  font-weight: 700;
  margin-top: 10px;
}

.wm-column-card-icon {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 6px;
}

