/* ============================================================
   Xoodle — lobby.css
   Styles for the lobby / landing page
   ============================================================ */

/* ============================================================
   Page Layout
   ============================================================ */
body.lobby-body {
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Animated gradient background */
.lobby-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 20% 20%, rgba(244, 114, 182, 0.12) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 80%, rgba(167, 139, 250, 0.12) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 50%, rgba(56, 189, 248, 0.08) 0%, transparent 70%),
              var(--bg);
  pointer-events: none;
}

/* ============================================================
   Floating Doodle Decorations
   ============================================================ */
.floating-doodles {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.doodle-emoji {
  position: absolute;
  font-size: 2.5rem;
  opacity: 0.18;
  user-select: none;
  filter: blur(0.5px);
  animation: float 8s ease-in-out infinite;
}

.doodle-emoji:nth-child(1)  { top: 8%;  left: 5%;   font-size: 2rem;   animation-duration: 7s;  animation-delay: 0s;    opacity: 0.2; }
.doodle-emoji:nth-child(2)  { top: 15%; right: 8%;  font-size: 2.8rem; animation-duration: 9s;  animation-delay: -2s;   opacity: 0.16; animation-name: floatAlt; }
.doodle-emoji:nth-child(3)  { top: 55%; left: 3%;   font-size: 2.2rem; animation-duration: 6s;  animation-delay: -4s;   opacity: 0.18; }
.doodle-emoji:nth-child(4)  { top: 70%; right: 5%;  font-size: 3rem;   animation-duration: 10s; animation-delay: -1s;   opacity: 0.14; animation-name: floatAlt; }
.doodle-emoji:nth-child(5)  { top: 40%; left: 2%;   font-size: 1.8rem; animation-duration: 8s;  animation-delay: -3s;   opacity: 0.22; }
.doodle-emoji:nth-child(6)  { top: 30%; right: 3%;  font-size: 2.4rem; animation-duration: 11s; animation-delay: -5s;   opacity: 0.16; animation-name: float; }
.doodle-emoji:nth-child(7)  { top: 85%; left: 10%;  font-size: 2rem;   animation-duration: 7s;  animation-delay: -2.5s; opacity: 0.2;  animation-name: floatAlt; }
.doodle-emoji:nth-child(8)  { top: 90%; right: 12%; font-size: 2.6rem; animation-duration: 9s;  animation-delay: -1.5s; opacity: 0.15; }
.doodle-emoji:nth-child(9)  { top: 5%;  left: 40%;  font-size: 1.6rem; animation-duration: 6s;  animation-delay: -6s;   opacity: 0.18; animation-name: floatAlt; }
.doodle-emoji:nth-child(10) { top: 92%; left: 50%;  font-size: 2rem;   animation-duration: 8s;  animation-delay: -3.5s; opacity: 0.2;  }

/* Decorative CSS shapes */
.doodle-shape {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.06;
  animation: float 12s ease-in-out infinite;
}

.doodle-shape-1 {
  width: 200px;
  height: 200px;
  background: var(--primary);
  top: -60px;
  left: -60px;
  animation-delay: 0s;
}

.doodle-shape-2 {
  width: 150px;
  height: 150px;
  background: var(--accent);
  bottom: 100px;
  right: -40px;
  border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
  animation-delay: -3s;
  animation-name: floatAlt;
}

.doodle-shape-3 {
  width: 100px;
  height: 100px;
  background: var(--secondary);
  top: 40%;
  right: 10%;
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  animation-delay: -6s;
}

/* ============================================================
   Lobby Container
   ============================================================ */
.lobby-container {
  position: relative;
  z-index: 10;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 60px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ============================================================
   Header / Nav
   ============================================================ */
.lobby-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  margin-bottom: 8px;
}

.lobby-header .logo-sm {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   Hero Section
   ============================================================ */
.hero-section {
  text-align: center;
  padding: 30px 0 36px;
  width: 100%;
  animation: slideUp 0.6s ease both;
}

/* Xoodle Logo */
.xoodle-logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(244, 114, 182, 0.4);
  position: relative;
  animation: float 5s ease-in-out infinite;
  flex-shrink: 0;
}

.logo-icon-svg {
  width: 44px;
  height: 44px;
  stroke: #fff;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logo-text {
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 60%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px rgba(244, 114, 182, 0.3));
  position: relative;
}

/* Decorative X with doodle style */
.logo-text .x-letter {
  display: inline-block;
  position: relative;
}

.logo-text .x-letter::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  transform: scaleX(0);
  transition: transform 0.3s ease;
}

.xoodle-logo:hover .logo-text .x-letter::after {
  transform: scaleX(1);
}

.hero-tagline {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.hero-tagline span {
  color: var(--primary);
}

.hero-sub {
  font-size: 0.9375rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ============================================================
   Main Panel — Tab Interface
   ============================================================ */
.main-panel {
  width: 100%;
  max-width: 560px;
  animation: slideUp 0.7s ease 0.1s both;
}

/* Tabs */
.tab-bar {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1.5px solid var(--border);
  border-bottom: none;
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 14px 16px;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(244, 114, 182, 0.04);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(244, 114, 182, 0.06);
}

.tab-btn .tab-icon {
  font-size: 1.1rem;
}

/* Tab Content */
.tab-content {
  background: var(--bg-card);
  border-radius: 0 0 var(--radius) var(--radius);
  border: 1.5px solid var(--border);
  border-top: none;
  padding: 28px;
  box-shadow: var(--shadow);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease;
}

.tab-pane.active {
  display: block;
}

/* ============================================================
   Play Tab
   ============================================================ */
.play-tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nickname-group {
  position: relative;
}

.nickname-group .nickname-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  pointer-events: none;
}

.nickname-group .input {
  padding-left: 42px;
}

.nickname-char-count {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  pointer-events: none;
}

.play-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.play-actions .btn {
  width: 100%;
  padding: 14px 16px;
  font-size: 1rem;
}

.action-btn-icon {
  font-size: 1.3rem;
}

/* ============================================================
   Rooms Tab
   ============================================================ */
.rooms-tab {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rooms-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rooms-header h3 {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(244, 114, 182, 0.08);
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: var(--transition);
}

.refresh-btn:hover {
  background: rgba(244, 114, 182, 0.15);
  transform: scale(1.03);
}

.refresh-icon {
  font-size: 0.9rem;
  transition: transform 0.5s ease;
}

.refresh-btn.spinning .refresh-icon {
  animation: spinSlow 0.8s linear infinite;
}

/* Public Rooms Grid */
.public-rooms {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.rooms-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.rooms-empty .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.rooms-empty p {
  font-size: 0.9rem;
  font-weight: 600;
}

/* Room Card */
.room-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  transition: var(--transition);
  cursor: pointer;
  animation: slideUp 0.3s ease both;
}

.room-card:hover {
  border-color: var(--primary);
  background: rgba(244, 114, 182, 0.04);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(244, 114, 182, 0.12);
}

.room-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.room-card-info {
  flex: 1;
  min-width: 0;
}

.room-card-name {
  font-weight: 800;
  font-size: 0.9375rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.room-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.room-card-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-muted);
}

.room-card-players {
  display: flex;
  align-items: center;
  gap: 4px;
}

.players-icon { font-size: 0.8rem; }

.room-status {
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.room-status.waiting {
  background: rgba(52, 211, 153, 0.15);
  color: #059669;
}

.room-status.in-game {
  background: rgba(251, 191, 36, 0.15);
  color: #b45309;
}

.room-card-join {
  padding: 7px 16px;
  font-size: 0.8125rem;
  border-radius: 8px;
  flex-shrink: 0;
}

.rooms-loading {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 46, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
  overflow-y: auto;
}

.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: bounceIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  border: 1.5px solid var(--border);
}

.modal-header {
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-title-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(244, 114, 182, 0.1);
  color: var(--primary);
  transform: scale(1.1);
}

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 16px 24px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.modal-footer .btn {
  flex: 1;
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Options Grid */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Collapsible Section */
.collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  transition: var(--transition);
  user-select: none;
}

.collapsible-header:hover {
  border-color: var(--primary);
  background: rgba(244, 114, 182, 0.05);
}

.collapsible-title {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapsible-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: transform 0.25s ease;
}

.collapsible.open .collapsible-arrow {
  transform: rotate(180deg);
}

.collapsible-content {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  opacity: 0;
}

.collapsible.open .collapsible-content {
  max-height: 500px;
  opacity: 1;
}

.collapsible-inner {
  padding: 14px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom Words Help Text */
.help-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.4;
}

/* Join Modal Code Input */
.code-input {
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 1.5rem;
  font-weight: 800;
}

/* Avatar Preview */
.avatar-preview-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}

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

.avatar-preview-name {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
  margin-top: 1px;
}

/* Private Toggle Row */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
}

.toggle-row-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-row-title {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
}

.toggle-row-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================================================
   Loading Overlay
   ============================================================ */
.page-loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  animation: fadeIn 0.2s ease;
}

.page-loading .loading-logo {
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: pulse 1.2s ease-in-out infinite;
}

.page-loading p {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* ============================================================
   Connection Status
   ============================================================ */
.connection-status {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 0.8125rem;
  font-weight: 700;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  animation: slideDown 0.3s ease;
}

.connection-status.connected {
  background: rgba(52, 211, 153, 0.12);
  color: #059669;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.connection-status.disconnected {
  background: rgba(248, 113, 113, 0.12);
  color: #dc2626;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

.connection-status.connecting {
  background: rgba(251, 191, 36, 0.12);
  color: #b45309;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.connection-status.connected .status-dot {
  animation: pulse 1.5s ease-in-out infinite;
}

.connection-status.connecting .status-dot {
  animation: pulse 0.8s ease-in-out infinite;
}

/* ============================================================
   How To Play Section
   ============================================================ */
.how-to-play {
  margin-top: 28px;
  width: 100%;
  max-width: 560px;
  animation: slideUp 0.8s ease 0.2s both;
}

.how-to-play h3 {
  text-align: center;
  font-weight: 800;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.step-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  text-align: center;
  transition: var(--transition);
}

.step-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.step-emoji {
  font-size: 1.8rem;
  margin-bottom: 8px;
  display: block;
}

.step-title {
  font-weight: 800;
  font-size: 0.875rem;
  color: var(--text);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ============================================================
   Footer
   ============================================================ */
.lobby-footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
}

.lobby-footer a {
  color: var(--primary);
  font-weight: 700;
}

.lobby-footer a:hover {
  text-decoration: underline;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 600px) {
  .hero-section {
    padding: 20px 0 28px;
  }

  .logo-text {
    font-size: 3rem;
  }

  .logo-icon {
    width: 56px;
    height: 56px;
  }

  .logo-icon-svg {
    width: 34px;
    height: 34px;
  }

  .hero-tagline {
    font-size: 1.125rem;
  }

  .tab-content {
    padding: 20px 16px;
  }

  .modal {
    border-radius: var(--radius);
  }

  .modal-body {
    padding: 16px 18px;
  }

  .modal-footer {
    padding: 14px 18px 18px;
    flex-direction: column;
  }

  .options-grid {
    grid-template-columns: 1fr;
  }

  .steps-grid {
    grid-template-columns: 1fr;
  }

  .play-actions {
    grid-template-columns: 1fr;
  }

  .doodle-emoji {
    display: none;
  }

  .doodle-emoji:nth-child(1),
  .doodle-emoji:nth-child(2),
  .doodle-emoji:nth-child(3) {
    display: block;
  }
}

@media (max-width: 400px) {
  .lobby-container {
    padding: 12px 12px 40px;
  }

  .logo-text {
    font-size: 2.4rem;
  }

  .tab-btn {
    font-size: 0.8125rem;
    padding: 12px 8px;
  }
}
