/* Base styles */
:root {
  --primary-color: #00A896;
  --primary-hover: #007A6B;
  --light-bg: #f4f7f6;
  --border-color: #c5d6d3;
  --text-color: #4a5f5c;
  --system-msg-color: #789995;
  --your-msg-bg: #c6f2e8;
  --partner-msg-bg: #ffffff;
  --male-color: #5fb3d4;
  --female-color: #f7b7cd;
  --other-color: #a695c7;
  --any-color: #97d4c8;
  
  /* Pill selector colors */
  --pill-border: #00A896;
  --pill-bg-hover: #e0f4f2;
  --pill-bg-active: #00A896;
  --pill-text-default: #00A896;
  --pill-text-active: #ffffff;
  
  /* Modern gradient colors */
  --primary-gradient: linear-gradient(135deg, #00A896 0%, #1FCC9F 100%);
  --primary-gradient-hover: linear-gradient(135deg, #007A6B 0%, #16A085 100%);
  --subtle-bg-gradient: linear-gradient(180deg, #f4f7f6 0%, #e8f2f0 100%);
  --card-gradient: linear-gradient(145deg, #ffffff 0%, #f8fbfa 100%);
}

/* Dark mode styles */
body.dark-mode {
  --primary-color: #1FCC9F;
  --primary-hover: #16A085;
  --light-bg: #1a1f1e;
  --border-color: #3a4540;
  --text-color: #b8c5c2;
  --system-msg-color: #7a8b87;
  --your-msg-bg: #0f4c41;
  --partner-msg-bg: #2a3f3b;
  --male-color: #4a9bc7;
  --female-color: #d19bb5;
  --other-color: #9082b8;
  --any-color: #5fb3a6;
  
  /* Pill selector colors for dark mode */
  --pill-border: #1FCC9F;
  --pill-bg-hover: #1e3b35;
  --pill-bg-active: #1FCC9F;
  --pill-text-default: #1FCC9F;
  --pill-text-active: #ffffff;
  
  /* Dark mode gradients */
  --primary-gradient: linear-gradient(135deg, #1FCC9F 0%, #26E8B8 100%);
  --primary-gradient-hover: linear-gradient(135deg, #16A085 0%, #1DA894 100%);
  --subtle-bg-gradient: linear-gradient(180deg, #1a1f1e 0%, #151a19 100%);
  --card-gradient: linear-gradient(145deg, #2a2f2e 0%, #242928 100%);
}

/* Accessibility and SEO */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: sans-serif;
  background: var(--subtle-bg-gradient);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.4s ease, color 0.3s ease;
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle input[type="checkbox"] {
  display: none;
}

.sun-icon {
  font-size: 14px;
  opacity: 0.8;
  filter: grayscale(100%);
  transition: opacity 0.3s ease;
}

.moon-icon {
  font-size: 14px;
  opacity: 0.4;
  filter: grayscale(100%);
  transition: opacity 0.3s ease;
}

.switch-label {
  display: block;
  width: 30px;
  height: 15px;
  background: linear-gradient(45deg, #ccc, #ddd);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.switch-label:hover {
  background: linear-gradient(45deg, #bbb, #ccc);
  transform: scale(1.05);
}

.slider {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 13px;
  height: 13px;
  background: linear-gradient(145deg, #ffffff, #f5f5f5);
  border-radius: 50%;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.theme-toggle input[type="checkbox"]:checked + .switch-label {
  background: var(--primary-gradient);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.theme-toggle input[type="checkbox"]:checked + .switch-label .slider {
  transform: translateX(15px);
  box-shadow: 0 2px 8px rgba(0, 168, 150, 0.4);
}

.theme-toggle input[type="checkbox"]:checked + .switch-label:hover {
  background: var(--primary-gradient-hover);
}

body.dark-mode .theme-toggle input[type="checkbox"]:checked + .switch-label .slider {
  box-shadow: 0 2px 8px rgba(31, 204, 159, 0.5);
}

/* Update icon opacity based on theme state */
.theme-toggle input[type="checkbox"]:checked ~ .sun-icon {
  opacity: 0.4;
}

.theme-toggle input[type="checkbox"]:checked ~ .moon-icon {
  opacity: 0.8;
}

main {
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 60px;
  position: relative;
}

/* Animated Values Background */
.values-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Only show values background when welcome screen is visible */
main:has(#welcome-screen[style*="display:none"]) .values-background,
main:has(#waiting-screen:not([style*="display:none"])) .values-background,
main:has(#chat:not([style*="display:none"])) .values-background {
  display: none;
}

.rotating-value {
  position: absolute;
  bottom: 7%;
  left: 50%;
  transform: translateX(-50%) rotate(-5deg);
  transform-origin: center center;
  font-size: 1.8em;
  font-weight: bold;
  color: var(--primary-color);
  opacity: 0;
  text-align: center;
  white-space: nowrap;
  transition: opacity 2s ease-in-out;
  text-shadow: 0 0 20px rgba(0, 168, 150, 0.3);
  user-select: none;
  max-width: 70%;
  word-wrap: break-word;
  line-height: 1.2;
}

.rotating-value.show {
  opacity: 0.15;
}

body.dark-mode .rotating-value {
  text-shadow: 0 0 30px rgba(31, 204, 159, 0.4);
}

/* Status display */
#status {
  padding: 10px;
  font-style: italic;
  color: var(--text-color);
  text-align: center;
}

/* Welcome screen and gender selection */
#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px;
  padding-top: 40px;
  text-align: center;
  min-height: calc(100vh - 40px);
  position: relative;
  z-index: 1;
}

/* Title and subtitle styling */
#app-title {
  font-size: 2.5em;
  margin: 0 0 10px 0;
  color: var(--primary-color);
  font-weight: bold;
}

#app-subtitle {
  font-size: 1.1em;
  margin: 0 0 15px 0;
  color: var(--text-color);
  font-style: normal;
  opacity: 0.9;
}

.gender-selection {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 20px 0;
  padding: 15px;
  background: var(--card-gradient);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  gap: 20px;
  transition: box-shadow 0.3s ease;
}

body.dark-mode .gender-selection {
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.selection-group {
  width: 100%;
}

.selection-group h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--text-color);
  text-align: left;
}

/* Pill Selector Styles */
.pill-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  position: relative;
  border: 1px solid var(--pill-border);
  border-radius: 9999px;
  overflow: hidden;
}

/* Special styling for unicorn users with only one option */
.pill-selector.unicorn-restricted {
  max-width: 120px;
  margin: 0 auto;
  grid-template-columns: 1fr;
}

.pill-selector.unicorn-restricted label {
  justify-content: center;
  padding: 12px 16px;
}

/* Hide dividers when only one column is shown for unicorn users */
.pill-selector.unicorn-restricted label::before {
  display: none;
}

.pill-selector input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.pill-selector label {
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  color: var(--pill-text-default);
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  position: relative;
}

.pill-selector label:hover {
  background-color: var(--pill-bg-hover);
}

.pill-selector input[type="radio"]:checked + label {
  background: var(--primary-gradient);
  color: var(--pill-text-active);
  font-weight: 600;
  z-index: 1;
  position: relative;
  margin: -1px;
}

.pill-selector input[type="radio"]:disabled + label {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Dividers between segments */
.pill-selector label:nth-child(4)::before, 
.pill-selector label:nth-child(6)::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15%;
  height: 70%;
  width: 1px;
  background-color: var(--pill-border);
  z-index: 0;
}

/* Hide dividers when this label is selected */
.pill-selector input[type="radio"]:checked + label::before {
  display: none;
}

/* Locked/disabled state for own gender after selection */
.pill-selector.locked label:not(:has(+ input:checked)) {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Turnstile widget container */
.turnstile-container {
  margin: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 65px; /* Turnstile widget is roughly 65px tall */
}

#startChatBtn {
  padding: 24px 48px;
  font-size: 18px;
  margin-top: 15px;
  border-radius: 48px;
  font-weight: 600;
  background: var(--primary-gradient);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0) scale(1);
  box-shadow: 0 4px 12px rgba(0, 168, 150, 0.3);
}

#startChatBtn:hover {
  background: var(--primary-gradient-hover);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 168, 150, 0.4);
}

#startChatBtn:active {
  transform: translateY(0) scale(0.98);
}

body.dark-mode #startChatBtn {
  box-shadow: 0 4px 12px rgba(31, 204, 159, 0.4);
}

body.dark-mode #startChatBtn:hover {
  box-shadow: 0 8px 20px rgba(31, 204, 159, 0.5);
}

/* Waiting screen */
#waiting-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.status-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  margin-bottom: 30px;
}

#waiting-status {
  font-size: 18px;
  margin-bottom: 20px;
  color: var(--text-color);
}

.spinner {
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top: 3px solid var(--primary-color);
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Gender pills */
.gender-pill {
  padding: 4px 6px;
  border-radius: 12px;
  background-color: #f0f0f0;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.gender-pill span {
  font-weight: bold;
  margin-left: 4px;
  font-size: 14px;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gender-pill span.MALE::before {
  content: "♂️";
}

.gender-pill span.FEMALE::before {
  content: "♀️";
}

.gender-pill span.OTHER::before {
  content: "🦄";
}


/* Hide the original text content and show emoji */
.gender-pill span.MALE,
.gender-pill span.FEMALE,
.gender-pill span.OTHER,
.gender-pill span.ANY {
  font-size: 0;
  position: relative;
}

.gender-pill span.MALE::before,
.gender-pill span.FEMALE::before,
.gender-pill span.OTHER::before,
.gender-pill span.ANY::before {
  font-size: 14px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

/* Preference selector */
.preference-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.preference-selector h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
}

/* Exit chat button styling - positioned inside chat container */
#exitChatButton {
  background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  color: white;
  border: none;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1001;
  transform: scale(1);
  box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

#exitChatButton:hover {
  background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

#exitChatButton:active {
  transform: scale(0.9);
}

#exitChatButton:disabled {
  background-color: #6c757d;
  color: #adb5bd;
  cursor: not-allowed;
}

#exitChatButton:disabled:hover {
  background-color: #6c757d;
}

/* Report button styling - positioned in top left corner of chat */
#reportButton {
  background: #f8f9fa;
  color: #6c757d;
  border: 1px solid #dee2e6;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: normal;
  transition: all 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1001;
  white-space: nowrap;
  gap: 4px;
}

#reportButton:hover {
  background: #e9ecef;
  color: #495057;
  border-color: #adb5bd;
}

#reportButton:active {
  background: #dee2e6;
}

body.dark-mode #reportButton {
  background: #343a40;
  color: #adb5bd;
  border-color: #495057;
}

body.dark-mode #reportButton:hover {
  background: #495057;
  color: #ced4da;
  border-color: #6c757d;
}

/* Report dropdown menu */
.report-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 1002;
  width: 260px;
  max-width: calc(100vw - 20px);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 200ms ease;
  pointer-events: none;
  margin-top: 4px;
}

.report-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

body.dark-mode .report-dropdown {
  background: #2a2f2e;
  border-color: #4a5550;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.report-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-color);
  font-size: 14px;
}

.report-dropdown-content {
  padding: 8px 0;
  max-height: 300px;
  overflow-y: auto;
}

.report-option {
  padding: 10px 16px;
  cursor: pointer;
  color: var(--text-color);
  font-size: 13px;
  line-height: 1.4;
  transition: background-color 200ms ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.report-option:hover {
  background-color: var(--pill-bg-hover);
}

.report-option:active {
  background-color: var(--pill-bg-active);
  color: var(--pill-text-active);
}

/* Tooltip styles for report options */
.report-option .tooltip {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: normal;
  max-width: 240px;
  z-index: 1003;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  margin-bottom: 4px;
  line-height: 1.3;
  text-align: center;
}

/* For the first two report options, show tooltip below instead of above */
.report-option:nth-child(1) .tooltip,
.report-option:nth-child(2) .tooltip {
  bottom: auto;
  top: 100%;
  margin-bottom: 0;
  margin-top: 4px;
}

.report-option:hover .tooltip {
  opacity: 1;
}

body.dark-mode .report-option .tooltip {
  background: rgba(255, 255, 255, 0.95);
  color: #212529;
}

/* Mobile adjustments for report dropdown */
@media (max-width: 600px) {
  .report-dropdown {
    right: 0;
    left: auto;
  }
  
  .report-option .tooltip {
    display: none; /* Hide tooltips on mobile to prevent scrolling issues */
  }
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
}

/* Custom Confirmation Dialog */
.confirm-dialog {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.confirm-modal {
  position: relative;
  background-color: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  max-width: 400px;
  width: 90%;
  animation: confirmSlideIn 0.2s ease-out;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode .confirm-modal {
  background-color: #2a2f2e;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

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

.confirm-header {
  padding: 20px 20px 0 20px;
  text-align: center;
}

.confirm-header h3 {
  margin: 0;
  color: var(--text-color);
  font-size: 18px;
  font-weight: 600;
}

.confirm-body {
  padding: 15px 20px;
  text-align: center;
}

.confirm-body p {
  margin: 0;
  color: var(--text-color);
  font-size: 14px;
  line-height: 1.4;
}

.confirm-footer {
  padding: 0 20px 20px 20px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.confirm-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.confirm-btn-cancel {
  background-color: #f8f9fa;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.confirm-btn-cancel:hover {
  background-color: #e9ecef;
}

body.dark-mode .confirm-btn-cancel {
  background-color: #3a4540;
  color: #d4e1de;
  border-color: #5a6560;
}

body.dark-mode .confirm-btn-cancel:hover {
  background-color: #4a5550;
}

.confirm-btn-yes {
  background-color: #dc3545;
  color: white;
}

.confirm-btn-yes:hover {
  background-color: #c82333;
}

/* Center the button and status vertically when no chat is visible */
main:has(#chat[style*="display:none"]) {
  justify-content: flex-start;
  align-items: center;
  padding-top: 40px;
}

#findPartnerBtn {
  padding: 12px 20px;
  font-size: 16px;
  margin: 10px auto;
  border-radius: 24px;
  display: block;
  background: var(--primary-gradient);
  border: none;
  color: white;
  cursor: pointer;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0) scale(1);
  box-shadow: 0 3px 8px rgba(0, 168, 150, 0.3);
}

#findPartnerBtn:hover {
  background: var(--primary-gradient-hover);
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 16px rgba(0, 168, 150, 0.4);
}

#findPartnerBtn:active {
  transform: translateY(0) scale(0.98);
}

body.dark-mode #findPartnerBtn {
  box-shadow: 0 3px 8px rgba(31, 204, 159, 0.4);
}

body.dark-mode #findPartnerBtn:hover {
  box-shadow: 0 6px 16px rgba(31, 204, 159, 0.5);
}

/* Chat container */
#chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  height: calc(100% - 100px);
  background-color: #e5ddd5;
  background-image: linear-gradient(rgba(255,255,255,0.7), rgba(255,255,255,0.7));
  position: relative;
  z-index: 1;
  max-width: 100%;
  box-sizing: border-box;
  transition: background-color 0.3s ease, background-image 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode #chat {
  background-color: #1e2423;
  background-image: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Hide/show toggle logic */
#chat[style*="display:none"] {
  position: absolute;
  visibility: hidden;
}

/* Hide FindPartnerBtn, status, and waiting-screen when chat is visible */
#chat:not([style*="display:none"]) ~ #findPartnerBtn,
#chat:not([style*="display:none"]) ~ #status {
  display: none;
}

/* This selector correctly targets the button and status that appear before #chat in the DOM */
#findPartnerBtn, #status {
  display: block;
}

main:has(#chat:not([style*="display:none"])) #findPartnerBtn,
main:has(#chat:not([style*="display:none"])) #status,
main:has(#chat:not([style*="display:none"])) #waiting-screen {
  display: none;
}

/* Messages display */
#messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 15px;
  padding-bottom: 15px;
  height: 100%;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

#messages div {
  margin-bottom: 10px;
  max-width: 80%;
  word-wrap: break-word;
}

/* Add auto margin to push content to the bottom */
#messages::after {
  content: "";
  flex: 1;
  min-height: 15px;
}

/* Message types */
.system-message {
  color: var(--system-msg-color);
  font-style: italic;
  text-align: center;
  width: 100%;
  max-width: 100% !important;
  margin: 15px auto;
  background-color: rgba(0,0,0,0.03);
  padding: 8px;
  border-radius: 8px;
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  box-sizing: border-box;
  transition: background-color 0.3s ease;
}

/* First system message in chat needs more top margin to avoid button overlap */
#messages .system-message:first-child {
  margin-top: 45px;
}

body.dark-mode .system-message {
  background-color: rgba(255,255,255,0.05);
}

.your-message {
  margin-left: auto;
  background-color: var(--your-msg-bg);
  border-radius: 18px 0 18px 18px;
  padding: 10px 15px;
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
}

.partner-message {
  margin-right: auto;
  background-color: var(--partner-msg-bg);
  border-radius: 0 18px 18px 18px;
  padding: 10px 15px;
  color: var(--text-color);
  transition: background-color 0.3s ease, color 0.3s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(0, 168, 150, 0.08);
}

/* Rate-limited message styling */
.rate-limited-message {
  margin-left: auto;
  background-color: #d3d3d3;
  color: #666;
  border-radius: 18px 0 18px 18px;
  padding: 10px 15px;
  opacity: 0.7;
  max-width: 80%;
  transition: background-color 0.3s ease, color 0.3s ease;
}

body.dark-mode .rate-limited-message {
  background-color: #4a4a4a;
  color: #999;
}

.rate-limit-note {
  font-size: 0.85em;
  color: #999;
  font-style: italic;
}

/* Message form */
#messageForm {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px;
  padding: 10px;
  background-color: #f0f0f0;
  width: 100%;
  box-sizing: border-box;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  z-index: 1000;
  flex-wrap: nowrap !important;
  transition: background-color 0.3s ease;
}

body.dark-mode #messageForm {
  background-color: #1a1f1e;
  border-top: 1px solid var(--border-color);
}

/* Chat ended form */
#chatEndedForm {
  display: none;
  padding: 10px;
  background-color: #f0f0f0;
  border-top: 1px solid var(--border-color);
  width: 100%;
  box-sizing: border-box;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  z-index: 1000;
  transition: background-color 0.3s ease;
}

body.dark-mode #chatEndedForm {
  background-color: #1a1f1e;
}

.chat-ended-content {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.chat-ended-content .selection-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.chat-ended-content .selection-group h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  white-space: nowrap;
}

.chat-ended-content .pill-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  position: relative;
  border: 1px solid var(--pill-border);
  border-radius: 9999px;
  overflow: hidden;
  min-width: 200px;
  height: 36px;
}

.chat-ended-content .pill-selector label {
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  color: var(--pill-text-default);
  transition: all 200ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  min-height: auto;
  height: 36px;
  box-sizing: border-box;
}

/* Specific styles for unicorn users in chat-ended interface */
.chat-ended-content .pill-selector.unicorn-restricted {
  grid-template-columns: 1fr;
  max-width: 120px;
  margin: 0 auto;
  min-width: 120px;
}

.chat-ended-content .pill-selector.unicorn-restricted label {
  justify-content: center;
  padding: 8px 16px;
}

/* Hide dividers for unicorn users in chat-ended interface */
.chat-ended-content .pill-selector.unicorn-restricted label::before {
  display: none;
}

#newChatBtn {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 18px;
  background: var(--primary-gradient);
  color: white;
  border: none;
  cursor: pointer;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  height: 36px;
  white-space: nowrap;
  transform: scale(1);
  box-shadow: 0 2px 6px rgba(0, 168, 150, 0.3);
}

#newChatBtn:hover {
  background: var(--primary-gradient-hover);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 168, 150, 0.4);
}

#newChatBtn:active {
  transform: scale(0.95);
}

body.dark-mode #newChatBtn {
  box-shadow: 0 2px 6px rgba(31, 204, 159, 0.4);
}

body.dark-mode #newChatBtn:hover {
  box-shadow: 0 4px 12px rgba(31, 204, 159, 0.5);
}

/* Message input with less rounded corners */
#messageInput {
  flex: 1 1 auto !important;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background-color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  height: 36px;
  box-sizing: border-box;
  min-width: 0;
  max-width: none;
  width: auto;
  color: var(--text-color);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode #messageInput {
  background-color: #2a2f2e;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

#messageInput:focus {
  outline: 1px solid var(--primary-color);
}

/* Button redesigned as a square with arrow */
#messageForm button[type="submit"] {
  position: relative;
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  border-radius: 8px;
  background: var(--primary-gradient);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(1);
  box-shadow: 0 2px 6px rgba(0, 168, 150, 0.3);
}

/* Hover effect for message form button */
#messageForm button[type="submit"]:hover {
  background: var(--primary-gradient-hover);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 168, 150, 0.4);
}

#messageForm button[type="submit"]:active {
  transform: scale(0.9);
}

body.dark-mode #messageForm button[type="submit"] {
  box-shadow: 0 2px 6px rgba(31, 204, 159, 0.4);
}

body.dark-mode #messageForm button[type="submit"]:hover {
  box-shadow: 0 4px 12px rgba(31, 204, 159, 0.5);
}

/* Arrow icon using CSS */
#messageForm button[type="submit"]:after {
  content: "";
  display: block;
  width: 12px;
  height: 12px;
  border-top: 2px solid white;
  border-right: 2px solid white;
  transform: rotate(45deg) translate(-2px, 2px);
}

button {
  padding: 8px 12px;
  border: none;
  background-color: var(--primary-color);
  color: white;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s;
}

button:hover {
  background-color: var(--primary-hover);
}

button:disabled {
  background-color: var(--border-color);
  cursor: not-allowed;
}

/* Desktop styles for better spacing */
@media (min-width: 601px) {
  #welcome-screen {
    padding-top: 5px;
    justify-content: flex-start;
  }
  
  .gender-selection {
    margin: 15px 0;
  }
  
  .turnstile-container {
    margin: 8px 0;
  }
  
  #startChatBtn {
    margin-top: 8px;
  }
}

/* Mobile responsiveness */
@media (max-width: 600px) {
  main {
    max-width: 100%;
  }
  
  #chat {
    border-radius: 0;
    border-left: none;
    border-right: none;
    height: 100%;
  }
  
  #messageForm {
    max-width: 100%;
  }
  
  /* Hide "Looking for:" text on mobile to save space */
  .chat-ended-content .selection-group h4 {
    display: none;
  }
  
  .chat-ended-content {
    gap: 5px;
  }
  
  .chat-ended-content .pill-selector {
    min-width: auto;
    flex: 1;
  }
  
  /* Unicorn users in chat-ended interface on mobile */
  .chat-ended-content .pill-selector.unicorn-restricted {
    min-width: 120px;
    flex: 0 0 120px;
  }
}

/* Footer Styles */
.main-footer {
  position: fixed;
  bottom: 10px;
  left: 10px;
  z-index: 100;
}

/* Hide footer on non-starting pages */
main:has(#welcome-screen[style*="display:none"]) .main-footer {
  display: none;
}

/* Hide footer specifically when chat is active */
main:has(#chat:not([style*="display:none"])) .main-footer {
  display: none;
}


.rules-link {
  color: var(--text-color);
  text-decoration: none;
  font-size: 12px;
  opacity: 0.7;
  transition: opacity 0.3s ease, color 0.3s ease;
  display: inline-block;
  padding: 2px 4px;
  border-radius: 6px;
  background-color: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.rules-link:hover {
  opacity: 1;
  color: var(--primary-color);
  background-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .rules-link {
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .rules-link:hover {
  background-color: rgba(0, 0, 0, 0.5);
}

/* Rules Page Styles */
main.rules-page {
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 40px;
  overflow: auto !important;
  height: auto !important;
  display: block !important;
}

.rules-header {
  margin-bottom: 40px;
  text-align: center;
}

.rules-header .back-link-button {
  margin-bottom: 20px;
}

.rules-footer .back-link-button {
  margin-bottom: 20px;
}

.rules-header h1 {
  color: var(--primary-color);
  font-size: 2.2em;
  margin: 20px 0;
  font-weight: bold;
}



.rules-content {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.rules-section,
.values-section {
  background-color: white;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease;
}

body.dark-mode .rules-section,
body.dark-mode .values-section {
  background-color: #2a2f2e;
}

.rules-section h2,
.values-section h2 {
  color: var(--primary-color);
  font-size: 1.8em;
  margin: 0 0 20px 0;
  font-weight: bold;
}

.rules-list,
.values-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.rules-list li,
.values-list li {
  color: var(--text-color);
  padding: 8px 0;
  margin: 0;
  border-bottom: 1px solid rgba(0, 168, 150, 0.1);
  line-height: 1.5;
  position: relative;
  padding-left: 20px;
}

.rules-list li:last-child,
.values-list li:last-child {
  border-bottom: none;
}


.values-list li strong {
  color: var(--primary-color);
}

.values-list h3 {
  color: var(--primary-color);
  margin-top: 25px;
  margin-bottom: 10px;
  font-size: 1.2em;
}

.values-list p {
  margin-bottom: 20px;
  line-height: 1.6;
  color: var(--text-color);
}

body.dark-mode .values-list h3 {
  color: var(--primary-color);
}

body.dark-mode .values-list p {
  color: var(--text-color);
}

.rules-footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px 0;
}

.back-link-button {
  background-color: var(--primary-color);
  color: white;
  text-decoration: none;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 16px;
  font-weight: bold;
  display: inline-block;
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.back-link-button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Responsive styles for rules page */
@media (max-width: 600px) {
  .rules-page {
    padding: 15px;
  }
  
  .rules-header h1 {
    font-size: 1.8em;
  }
  
  .rules-section,
  .values-section {
    padding: 20px;
  }
  
  .rules-section h2,
  .values-section h2 {
    font-size: 1.5em;
  }
  
  .main-footer {
    left: 10px;
    bottom: 10px;
  }
  
  .rules-link {
    font-size: 11px;
    padding: 6px 10px;
  }
  
  /* Adjust animated values for mobile */
  .rotating-value {
    font-size: 1.3em;
    max-width: 80%;
    bottom: 20%;
  }
} 