/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */
.modal-veil {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--app-h, 100dvh);
  background: rgba(6, 10, 16, 0.92);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top, 0px)) 12px max(10px, env(safe-area-inset-bottom, 0px));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-veil.open {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: linear-gradient(180deg, #182232 0%, #0e1520 100%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 22px;
  padding: clamp(14px, 3dvh, 24px);
  max-width: 440px;
  width: 100%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
  transform: scale(0.94);
  transition: transform 0.25s var(--spring);
  max-height: calc(var(--app-h, 100dvh) - max(20px, env(safe-area-inset-top, 0px) + env(safe-area-inset-bottom, 0px) + 12px));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.modal-veil.open .modal-card {
  transform: scale(1);
}

/* High-Impact Final Round Modal */
.final-round-veil {
  z-index: 120;
}
.final-round-card {
  text-align: center;
  border: 2px solid var(--ruby);
  box-shadow: 0 0 32px rgba(244, 63, 94, 0.45), 0 12px 32px rgba(0, 0, 0, 0.7);
  background: linear-gradient(180deg, #22121e 0%, #111827 100%);
}
.final-round-siren-halo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.2);
  border: 2px solid var(--ruby);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  box-shadow: 0 0 20px rgba(244, 63, 94, 0.5);
  animation: pulseAlert 1.2s infinite alternate;
}
@keyframes pulseAlert {
  0% { transform: scale(0.95); opacity: 0.85; }
  100% { transform: scale(1.08); opacity: 1; }
}
.final-round-siren-halo svg {
  width: 32px;
  height: 32px;
  fill: var(--ruby);
}
.final-round-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(244, 63, 94, 0.5);
}
.final-round-subtitle {
  font-size: 15px;
  color: var(--gold-light);
  font-weight: 700;
  margin-top: 5px;
  margin-bottom: 14px;
}
.final-round-rules-box {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.55;
}
.final-rule-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.final-rule-item.penalty-highlight {
  background: rgba(244, 63, 94, 0.18);
  border-radius: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(244, 63, 94, 0.45);
  color: #ffe4e6;
}
.final-rule-icon {
  font-size: 18px;
  flex-shrink: 0;
  line-height: 1.2;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title {
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.01em;
}
.veil-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.veil-close:active {
  transform: scale(0.92);
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.opt-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
.opt-label {
  font-size: 12.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-item {
  padding: 9px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s var(--spring);
}
.chip-item.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.35);
}

.cta-btn {
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.15s var(--spring), box-shadow 0.15s ease, opacity 0.15s ease;
}
.cta-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.cta-btn:disabled {
  opacity: 0.65;
  cursor: default;
}
.cta-btn-primary {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35);
}
.cta-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Turn Handover Overlay for Around the Table (Pass & Play) */
.privacy-screen {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 18, 0.94);
  z-index: 95;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
  gap: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.privacy-screen.open {
  opacity: 1;
  pointer-events: auto;
}

.privacy-icon-halo {
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: linear-gradient(135deg, #1e3a8a, #0284c7);
  border: 1px solid rgba(56, 189, 248, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(2, 132, 199, 0.45);
}
.privacy-icon-halo svg {
  width: 42px;
  height: 42px;
  fill: #fff;
}

/* Score Summary Table */
.score-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}
.score-table th {
  text-align: left;
  padding: 9px 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.score-table td {
  padding: 11px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 14px;
  font-weight: 700;
}
.score-table tr.winner-row {
  background: rgba(245, 158, 11, 0.15);
  font-weight: 800;
}

/* QR Code Container for P2P */
.qr-frame {
  background: #fff;
  padding: 10px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto;
  max-width: 158px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.qr-frame svg {
  width: 100%;
  height: auto;
  display: block;
}

.code-badge {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--gold-light);
  text-align: center;
  font-family: monospace;
  text-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* Friends Multiplayer Styles */
.friends-name-box {
  background: rgba(15, 23, 42, 0.72);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 13px;
  padding: 9px 12px 10px;
  margin-bottom: 12px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.friends-name-box:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.28);
}
.friends-name-box.needs-name {
  border-color: #f87171;
  background: rgba(127, 29, 29, 0.24);
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.38);
}
.friends-name-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #e2e8f0;
  margin-bottom: 6px;
}
.friends-name-hint {
  font-size: 11px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-muted);
}
.friends-name-box.needs-name .friends-name-hint {
  color: #fca5a5;
  font-weight: 800;
}
.friends-name-input {
  width: 100%;
  font-size: 16px;
  font-weight: 800;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  background: rgba(8, 13, 22, 0.92);
  color: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.friends-name-input::placeholder {
  color: rgba(148, 163, 184, 0.65);
  font-weight: 600;
}
.friends-name-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.22);
}
.friends-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  gap: 6px;
}
.friends-tab-btn {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 9px;
  font-weight: 800;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.friends-tab-btn.active {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.45);
}
.code-badge-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.room-code-input {
  width: 100%;
  max-width: 280px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 2px solid rgba(56, 189, 248, 0.45);
  background: rgba(13, 19, 29, 0.95);
  color: #fff;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.room-code-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}
.lobby-box {
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 12px;
}
.lobby-header {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 800;
}
.lobby-roster {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.roster-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.roster-item.host {
  background: rgba(2, 132, 199, 0.15);
  border-color: rgba(2, 132, 199, 0.3);
}
.roster-avatar {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.2);
  color: var(--cyan);
  font-size: 11px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.roster-name {
  color: #fff;
}
.roster-status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
}
.roster-status.ready {
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.15);
}
.join-status-box {
  margin-top: 12px;
  font-size: 13.5px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.join-status-box.connected {
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4);
}
.join-status-box.connecting {
  color: var(--gold-light);
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
}
.join-status-box.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.4);
}
.host-status-box {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s ease;
}
.host-status-box.online {
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
}
.host-status-box.connecting {
  color: var(--gold-light);
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.35);
}
.friends-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #34d399;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  height: 31px;
  flex-shrink: 0;
}
.friends-pill-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.friends-pill-btn:hover {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.35), rgba(6, 182, 212, 0.35));
  border-color: #34d399;
}

/* Welcome / Mode Picker Launch Screen */
.welcome-veil {
  z-index: 95;
  background: rgba(6, 10, 17, 0.95);
}
.welcome-card {
  padding: 18px 18px 16px;
  max-width: 410px;
}
.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: 12px;
  gap: 4px;
}
.welcome-crest {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, #5b21b6, #7c3aed);
  border: 1.5px solid rgba(196, 181, 253, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
  margin-bottom: 2px;
}
.welcome-crest svg {
  width: 25px;
  height: 25px;
  fill: #fff;
}
.welcome-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff;
  line-height: 1.1;
}
.welcome-title span {
  color: #c4b5fd;
}
.welcome-subtitle {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.35;
}
.welcome-resume-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 13px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1.5px solid rgba(251, 191, 36, 0.55);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(180, 83, 9, 0.2));
  color: #fef3c7;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s var(--spring), border-color 0.2s ease;
}
.welcome-resume-btn:active {
  transform: scale(0.98);
}
.mode-launch-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.mode-launch-card {
  background: rgba(15, 23, 38, 0.78);
  border: 1.5px solid rgba(255, 255, 255, 0.11);
  border-radius: 15px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, transform 0.18s var(--spring), box-shadow 0.2s ease;
}
.mode-launch-card.primary-mode {
  border-color: rgba(56, 189, 248, 0.38);
  background: linear-gradient(165deg, rgba(14, 30, 52, 0.88), rgba(13, 21, 34, 0.92));
}
.mode-launch-card.friends-mode {
  border-color: rgba(16, 185, 129, 0.42);
  background: linear-gradient(165deg, rgba(10, 38, 36, 0.78), rgba(13, 21, 34, 0.92));
}
.mode-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.mode-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mode-card-title {
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mode-live-pill {
  font-size: 9.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.22);
  border: 1px solid rgba(52, 211, 153, 0.55);
  color: #6ee7b7;
}
.mode-daily-pill {
  font-size: 9.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: var(--gold-light);
}
.mode-daily-pill.done {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(52, 211, 153, 0.55);
  color: #6ee7b7;
}
.summary-daily-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.4);
  color: var(--gold-light);
}
.summary-daily-banner.completed-earlier {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
}
.mode-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
}
.mode-go-btn {
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  color: #fff;
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
  transition: transform 0.15s var(--spring), filter 0.15s ease;
}
.mode-go-btn:active {
  transform: scale(0.95);
}
.mode-go-btn.gold {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.38);
}
.mode-go-btn.purple {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.38);
}
.mode-inline-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.mode-mini-chip {
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}
.mode-mini-chip.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: rgba(56, 189, 248, 0.65);
  color: #fff;
}
.mode-friends-actions {
  display: flex;
  gap: 8px;
}
.mode-friends-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.15s var(--spring);
}
.mode-friends-btn:active {
  transform: scale(0.96);
}
.mode-friends-btn.host {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}
.mode-friends-btn.join {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.5);
  color: #6ee7b7;
}
.welcome-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.welcome-link-btn {
  flex: 1;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.welcome-link-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
@media (max-width: 380px) {
  .nav-btn { width: 29px; height: 29px; }
  .friends-pill-btn { height: 29px; padding: 3px 6px; font-size: 10.5px; }
  .brand-crest { width: 24px; height: 24px; }
}
@media (max-height: 640px) {
  .welcome-hero { margin-bottom: 10px; gap: 3px; }
  .welcome-crest { width: 38px; height: 38px; border-radius: 12px; }
  .welcome-crest svg { width: 20px; height: 20px; }
  .welcome-title { font-size: 20px; }
  .welcome-subtitle { font-size: 11.5px; }
  .mode-launch-list { gap: 7px; }
  .mode-launch-card { padding: 9px 11px; gap: 6px; }
  .welcome-footer { margin-top: 10px; }
}
