/**
 * App chrome: auth, modals, leaderboards.
 */

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
}

.app-header {
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(0, 229, 229, 0.2);
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.2), transparent);
}

.app-title {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, var(--accent-cyan), var(--hot-pink), var(--soft-lilac));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.user-chip {
  font-size: 0.85rem;
  color: var(--warm-pink);
}

/* User stats display */
.user-stats {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.user-stats span {
  color: var(--text-muted);
}

.user-stats #high-score {
  color: var(--accent);
}

.stats-separator {
  opacity: 0.5;
}

main.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1rem;
  max-width: 1100px;
  margin: 0 auto;
}

@media (min-width: 900px) {
  main.layout {
    grid-template-columns: 1fr 320px;
    align-items: start;
  }
}

.panel {
  background: var(--bg-panel);
  border-radius: 14px;
  padding: 1rem;
  border: 1px solid rgba(64, 224, 208, 0.25);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--baby-blue);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--bold-magenta), var(--deep-violet));
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 20, 147, 0.35);
}

.btn-secondary {
  background: rgba(0, 229, 229, 0.15);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(157, 183, 208, 0.35);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 14, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(420px, 100%);
  background: var(--bg-panel);
  border-radius: 16px;
  padding: 1.25rem;
  border: 1px solid var(--highlight-fuchsia);
  box-shadow: var(--glow);
}

.modal h3 {
  margin-top: 0;
  color: var(--cool-turquoise);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.field input {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(135, 206, 235, 0.4);
  background: rgba(10, 15, 26, 0.85);
  color: var(--text-primary);
}

.form-error {
  color: var(--hot-pink);
  font-size: 0.85rem;
  min-height: 1.2rem;
}

.form-hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
  margin-bottom: 0.75rem;
  display: block;
  line-height: 1.3;
}

input:focus + .form-hint {
  color: var(--accent);
}

.leader-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
}

.leader-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.88rem;
}

.leader-list .name {
  color: var(--warm-pink);
  margin-right: auto;
}

.leader-list .pts {
  font-family: ui-monospace, monospace;
  color: var(--accent-cyan);
  margin-left: 0.5rem;
}

.word-log-panel h2 {
  margin-bottom: 0.35rem;
}

.word-log-hint {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
}

.word-log-hint[hidden] {
  display: none;
}

.word-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Custom scrollbar styling to match game aesthetic */
.word-log-list::-webkit-scrollbar,
.def-modal-body::-webkit-scrollbar {
  width: 8px;
}

.word-log-list::-webkit-scrollbar-track,
.def-modal-body::-webkit-scrollbar-track {
  background: rgba(32, 178, 170, 0.1);
  border-radius: 4px;
}

.word-log-list::-webkit-scrollbar-thumb,
.def-modal-body::-webkit-scrollbar-thumb {
  background: linear-gradient(145deg, var(--accent-cyan), var(--cool-turquoise));
  border-radius: 4px;
  transition: background 0.2s ease;
}

.word-log-list::-webkit-scrollbar-thumb:hover,
.def-modal-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(145deg, var(--cool-turquoise), var(--accent-cyan));
}

/* Firefox scrollbar styling */
.word-log-list,
.def-modal-body {
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan) rgba(32, 178, 170, 0.1);
}

/* Legal Agreement Modal Styles */
.legal-modal {
  width: min(580px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.legal-modal-title {
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 1.5rem;
  color: var(--warm-pink);
  text-align: center;
}

.legal-subtitle {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

.legal-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: rgba(0, 119, 182, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(0, 229, 229, 0.2);
}

.legal-section h4 {
  margin: 0 0 0.75rem;
  color: var(--accent-cyan);
  font-size: 1.1rem;
  font-weight: 700;
}

.legal-section h5 {
  margin: 0 0 0.5rem;
  color: var(--cool-turquoise);
  font-size: 1rem;
  font-weight: 600;
}

.age-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.age-option,
.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.age-option:hover,
.checkbox-option:hover {
  background: rgba(0, 229, 229, 0.1);
}

.age-option input,
.checkbox-option input {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent-cyan);
}

.age-option span,
.checkbox-option span {
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.legal-notice {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(255, 182, 217, 0.1);
  border: 1px solid var(--warm-pink);
  border-radius: 8px;
}

.legal-notice p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.legal-notice p:last-child {
  margin-bottom: 0;
}

.legal-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.legal-checkboxes a {
  color: var(--accent-cyan);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.legal-checkboxes a:hover {
  border-bottom-color: var(--accent-cyan);
}

.legal-promise {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(124, 58, 237, 0.1);
  border-radius: 8px;
}

.legal-promise ul {
  margin: 0.5rem 0 0;
  padding-left: 0;
  list-style: none;
}

.legal-promise li {
  margin: 0.25rem 0;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.legal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.legal-actions .btn {
  min-width: 140px;
}

.legal-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(0, 229, 229, 0.2);
  text-align: center;
}

.legal-footer p {
  margin: 0.25rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legal-footer a {
  color: var(--baby-blue);
  text-decoration: none;
}

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

/* Responsive adjustments */
@media (max-width: 600px) {
  .legal-modal {
    width: 95vw;
    max-height: 95vh;
  }
  
  .legal-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .legal-actions .btn {
    min-width: 200px;
  }
}

.word-log-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.86rem;
}

.word-log-list .word-log-word {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 600;
  color: var(--warm-pink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: auto;
}

.word-log-list .word-log-pts {
  font-family: ui-monospace, monospace;
  color: var(--cool-turquoise);
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.word-log-list li.word-log-row {
  cursor: pointer;
  border-radius: 8px;
  margin: 0 -0.25rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.word-log-list li.word-log-row:hover {
  background: rgba(255, 105, 180, 0.12);
}

.word-log-list li.word-log-row:focus {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

.definition-modal {
  width: min(480px, 100%);
  max-height: min(85vh, 640px);
  display: flex;
  flex-direction: column;
}

.def-modal-title {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 1.35rem;
  color: var(--warm-pink);
}

.def-modal-phonetic {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--baby-blue);
  font-family: ui-monospace, monospace;
}

.def-modal-body {
  flex: 1;
  overflow: auto;
  margin-bottom: 0.75rem;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-primary);
}

.def-modal-body .def-pos {
  margin: 0.65rem 0 0.25rem;
  font-weight: 700;
  color: var(--cool-turquoise);
  font-size: 0.82rem;
  text-transform: capitalize;
}

.def-modal-body .def-pos:first-child {
  margin-top: 0;
}

.def-modal-body ol.def-list {
  margin: 0 0 0.5rem;
  padding-left: 1.25rem;
}

.def-modal-body ol.def-list li {
  margin-bottom: 0.35rem;
  border: none;
  padding: 0;
  display: list-item;
  justify-content: flex-start;
}

.friends-tools {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.friends-tools input {
  padding: 0.45rem;
  border-radius: 8px;
  border: 1px solid rgba(200, 162, 255, 0.4);
  background: rgba(10, 15, 26, 0.85);
  color: var(--text-primary);
}

.friend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  max-width: min(360px, 92vw);
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: rgba(32, 178, 170, 0.95);
  color: #041018;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: opacity 0.25s ease;
}

.toast[hidden] {
  opacity: 0;
  pointer-events: none;
}

/* Authentication Overlay Styles */
.auth-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: inherit;
}

.auth-prompt {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--accent);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 229, 229, 0.2);
  max-width: 300px;
  animation: authPromptSlide 0.3s ease-out;
}

@keyframes authPromptSlide {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-prompt h3 {
  color: var(--accent);
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.auth-prompt p {
  color: var(--text-muted);
  margin: 0 0 1.5rem 0;
  line-height: 1.4;
}

.auth-prompt .btn {
  width: 100%;
  font-weight: 600;
}

/* Friend Notification Modal Styles */
.friend-notification-modal {
  max-width: 400px;
  text-align: center;
  padding: 2rem;
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.1), rgba(244, 63, 94, 0.1));
  border: 1px solid rgba(0, 229, 229, 0.3);
}

.friend-notification-modal h3 {
  font-size: 1.5rem;
  margin: 0 0 1rem 0;
  background: linear-gradient(90deg, var(--accent-cyan), var(--hot-pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}

.friend-notif-message {
  font-size: 1.1rem;
  margin: 0 0 1.5rem 0;
  color: var(--text-primary);
  line-height: 1.4;
}

.friend-notification-modal .btn {
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  min-width: 120px;
}

/* Accepted friend styling */
.friend-accepted {
  color: var(--accent-cyan);
  font-weight: 500;
}

.friend-row {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  border-radius: 6px;
  background: rgba(32, 178, 170, 0.05);
  border: 1px solid rgba(32, 178, 170, 0.1);
}
