/* ============================================
   Preferans — Lobby Styles
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background-color: #1a3a2a;
  color: #e8e0d0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
  line-height: 1.5;
}

/* --- Lobby Container --- */
.lobby {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* --- Header --- */
.lobby-header {
  text-align: center;
  margin-bottom: 40px;
}

.lobby-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #f0e6d0;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.lobby-subtitle {
  margin-top: 8px;
  font-size: 0.9rem;
  color: #9aaa97;
  font-weight: 400;
}

/* --- Main Content --- */
.lobby-main {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* --- Sections --- */
.lobby-section {
  margin-bottom: 8px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 24px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

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

.btn-primary {
  background-color: #c8a94e;
  color: #1a2a1e;
}

.btn-primary:hover {
  background-color: #d4b85c;
}

.btn-primary:active {
  background-color: #b89a40;
}

.btn-secondary {
  background-color: #2e5e42;
  color: #e8e0d0;
  flex-shrink: 0;
}

.btn-secondary:hover {
  background-color: #367050;
}

.btn-secondary:active {
  background-color: #264e36;
}

/* --- Divider --- */
.lobby-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
}

.lobby-divider::before,
.lobby-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: #3a5a48;
}

.lobby-divider span {
  font-size: 0.85rem;
  color: #7a9a80;
  text-transform: lowercase;
}

/* --- Join Group --- */
.join-group {
  display: flex;
  gap: 10px;
}

.input-room-code {
  flex: 1;
  min-height: 48px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 1rem;
  color: #e8e0d0;
  background-color: #1e3028;
  border: 2px solid #3a5a48;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease;
  min-width: 0;
}

.input-room-code::placeholder {
  color: #6a8a70;
}

.input-room-code:focus {
  border-color: #c8a94e;
}

.join-group .btn-secondary {
  width: auto;
  white-space: nowrap;
  padding: 12px 20px;
}

/* --- Settings --- */
.lobby-settings {
  margin-top: 24px;
  background-color: #1e3028;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #2e4e3a;
}

.settings-heading {
  font-size: 0.85rem;
  font-weight: 600;
  color: #7a9a80;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 20px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-row + .setting-row {
  margin-top: 18px;
}

.setting-label {
  font-size: 0.95rem;
  color: #c0c8b8;
  font-weight: 500;
  flex-shrink: 0;
}

/* --- Radio Group (Bullet Size) --- */
.radio-group {
  display: flex;
  gap: 6px;
  background-color: #162822;
  border-radius: 8px;
  padding: 4px;
}

.radio-option {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.radio-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 44px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #7a9a80;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease;
  user-select: none;
}

.radio-option input[type="radio"]:checked + .radio-btn {
  background-color: #c8a94e;
  color: #1a2a1e;
}

.radio-option:hover .radio-btn {
  color: #b0c0a8;
}

.radio-option input[type="radio"]:checked + .radio-btn:hover {
  color: #1a2a1e;
}

/* --- Toggle Switch (Polvista) --- */
.toggle {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 7px 0;
}

.toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.toggle-track {
  display: flex;
  align-items: center;
  width: 52px;
  height: 30px;
  background-color: #2a4a38;
  border-radius: 15px;
  padding: 3px;
  transition: background-color 0.2s ease;
}

.toggle-thumb {
  width: 24px;
  height: 24px;
  background-color: #6a8a70;
  border-radius: 50%;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.toggle input[type="checkbox"]:checked + .toggle-track {
  background-color: #c8a94e;
}

.toggle input[type="checkbox"]:checked + .toggle-track .toggle-thumb {
  transform: translateX(22px);
  background-color: #1a2a1e;
}

/* --- Footer --- */
.lobby-footer {
  margin-top: 40px;
  text-align: center;
}

.footer-text {
  font-size: 0.8rem;
  color: #5a7a60;
}

/* --- Waiting Screen --- */
.waiting-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 0;
}

.waiting-label {
  font-size: 0.9rem;
  color: #7a9a80;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.room-code-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.room-code {
  font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace;
  font-size: 3rem;
  font-weight: 700;
  color: #c8a94e;
  letter-spacing: 0.2em;
  cursor: pointer;
  padding: 12px 24px;
  border-radius: 12px;
  background-color: #1e3028;
  border: 2px solid #3a5a48;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  user-select: all;
}

.room-code:hover {
  border-color: #c8a94e;
  background-color: #243a2e;
}

.room-code:active {
  background-color: #1a3026;
}

.copy-feedback {
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #2e5e42;
  color: #e8e0d0;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.copy-feedback.visible {
  opacity: 1;
}

.waiting-message {
  font-size: 1rem;
  color: #9aaa97;
  margin-top: 8px;
}

.btn-copy-link {
  margin-top: 8px;
  width: auto;
  padding: 10px 24px;
}

/* --- Error Message --- */
.error-message {
  font-size: 0.85rem;
  color: #e05555;
  min-height: 1.3em;
  margin-top: 8px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.error-message.visible {
  opacity: 1;
}

/* ============================================
   Responsive — Mobile
   ============================================ */
@media (max-width: 480px) {
  body {
    padding: 20px 16px;
    align-items: flex-start;
    padding-top: 48px;
  }

  .lobby {
    max-width: 100%;
  }

  .lobby-title {
    font-size: 1.5rem;
  }

  .lobby-header {
    margin-bottom: 32px;
  }

  /* Stack join group vertically on narrow screens */
  .join-group {
    flex-direction: column;
  }

  .join-group .btn-secondary {
    width: 100%;
  }

  .lobby-settings {
    padding: 16px;
  }

  .setting-row {
    flex-wrap: wrap;
  }

  .radio-group {
    width: 100%;
    justify-content: center;
  }

  .radio-btn {
    flex: 1;
    min-width: 0;
  }

  /* Waiting screen on mobile */
  .room-code {
    font-size: 2.5rem;
    padding: 10px 20px;
  }

  .btn-copy-link {
    width: 100%;
  }
}

/* Prevent any horizontal overflow */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}
