/* ========== Mission: Hunt — App Shell Styles ========== */

/* ── Fullscreen Pages ── */
.fullscreen-page {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--bg-dark);
  overflow-y: auto;
}

/* ── Login Screen ── */
.login-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 40px) + 20px) calc(env(safe-area-inset-right, 0px) + 20px) calc(env(safe-area-inset-bottom, 0px) + 20px) calc(env(safe-area-inset-left, 0px) + 20px);
  background:
    radial-gradient(ellipse at 30% 30%, rgba(0, 229, 255, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 70%, rgba(0, 255, 136, 0.03) 0%, transparent 50%);
}

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

.login-logo {
  width: 80px;
  height: 80px;
  filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.8));
  margin-bottom: 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
}

.login-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.login-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 20px;
  border: none;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 10px;
}

.google-btn {
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
}
.google-btn:hover { background: #f5f5f5; }

.apple-btn {
  background: #000;
  color: #fff;
  border: 1px solid #333;
}
.apple-btn:hover { background: #1a1a1a; }

.guest-btn {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  border: 1px solid var(--border);
  letter-spacing: 1px;
}
.guest-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  gap: 12px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-divider span {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* Face ID login on sign-in screen */
.faceid-login-section {
  text-align: center;
  margin-bottom: 8px;
}
.faceid-login-section.hidden { display: none; }
.faceid-login-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 24px 16px;
  background: rgba(255,107,53,0.08);
  border: 1.5px solid rgba(255,107,53,0.3);
  border-radius: 14px;
  color: #ff6b35;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 4px;
}
.faceid-login-btn:active {
  background: rgba(255,107,53,0.18);
}

/* Email auth form */
.email-auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}
.auth-input {
  width: 100%;
  padding: 12px 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.auth-input:focus {
  border-color: #ff6b35;
}
.auth-input::placeholder {
  color: #666;
}
.email-auth-buttons {
  display: flex;
  gap: 10px;
}
.email-auth-buttons .login-btn {
  flex: 1;
  justify-content: center;
}
.email-btn {
  background: rgba(255,107,53,0.15);
  color: #ff6b35;
  border: 1px solid rgba(255,107,53,0.3);
}
.signup-btn {
  background: rgba(255,255,255,0.06);
  color: #ccc;
  border: 1px solid rgba(255,255,255,0.12);
}
.auth-signup-field.hidden {
  display: none;
}

.guest-note {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.6;
  margin-top: 4px;
}

.legal-links {
  text-align: center;
  font-size: 12px;
  color: #888;
}
.legal-links a {
  color: #ff6b35;
  text-decoration: none;
  opacity: 0.8;
}
.legal-links a:hover { opacity: 1; }
.legal-sep {
  margin: 0 8px;
  color: #555;
}
.legal-note {
  font-size: 10px;
  color: #666;
  margin-top: 8px;
  text-align: center;
}

/* Legal page modal */
.legal-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 9999;
  background: #0a0a0f;
  display: flex;
  flex-direction: column;
}
.legal-modal.hidden { display: none; }
.legal-modal-header {
  padding: calc(env(safe-area-inset-top, 20px) + 8px) 16px 12px;
  background: #12141c;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.legal-back-btn {
  background: none;
  border: none;
  color: #ff6b35;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 0;
}
.legal-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #0a0a0f;
}

/* Image crop modal */
.crop-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}
.crop-modal.hidden { display: none; }
.crop-container {
  background: #1a1c28;
  border-radius: 16px;
  padding: 24px;
  max-width: 90vw;
  text-align: center;
}
.crop-title {
  color: #fff;
  font-size: 18px;
  margin-bottom: 16px;
}
.crop-preview {
  margin: 0 auto;
  border-radius: 8px;
  overflow: hidden;
  touch-action: none;
}
.crop-preview canvas {
  display: block;
}
.crop-hint {
  color: #888;
  font-size: 12px;
  margin: 12px 0;
}
.crop-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.crop-actions .btn {
  min-width: 100px;
}

/* ── App Shell ── */
#app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: 72px; /* space for bottom nav */
}

/* ── Tab Content ── */
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 8000;
  display: flex;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
}

.nav-item.active {
  color: var(--accent);
}

.nav-icon {
  width: 22px;
  height: 22px;
}

/* ── Page Header ── */
.page-header {
  padding: calc(env(safe-area-inset-top, 20px) + 8px) 0 16px;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent), #00ff88);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Sub Tabs ── */
.sub-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}

.sub-tab {
  flex: 1;
  padding: 10px 8px;
  background: none;
  border: none;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.5px;
}

.sub-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Community Sections ── */
.community-section {
  display: none;
}
.community-section.active {
  display: block;
}

/* ── Search Bar ── */
.search-bar {
  margin-bottom: 16px;
}
.search-bar input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.2s;
}
.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.search-bar input::placeholder {
  color: var(--text-dim);
  opacity: 0.5;
}

/* ── Section Title ── */
.section-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 16px 0 10px;
}
.section-title-tight {
  margin-top: 0;
}
.search-bar-friends-filter {
  margin-bottom: 10px;
}
.friends-load-more {
  width: 100%;
  margin-top: 12px;
}

/* ── Friend List ── */
.friend-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.friend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.friend-avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  flex-shrink: 0;
}

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

.friend-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-status {
  font-size: 11px;
  color: var(--text-dim);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--accent-mid); }

.btn-icon-danger {
  border-color: var(--danger);
  background: var(--danger-dim);
  color: var(--danger);
  font-size: 14px;
}
.btn-icon-danger:hover { background: rgba(255,59,92,0.3); }

.btn-icon-accept {
  border-color: var(--success);
  background: var(--success-dim);
  color: var(--success);
  font-size: 16px;
}
.btn-icon-accept:hover { background: rgba(0,255,136,0.3); }

.friend-status-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(0, 255, 136, 0.3);
  white-space: nowrap;
}

.friend-status-badge.pending {
  background: var(--warning-dim);
  color: var(--warning);
  border-color: rgba(255, 184, 0, 0.3);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Guest Gate ── */
.guest-gate {
  text-align: center;
  padding: 60px 24px;
}
.gate-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
.guest-gate h3 {
  font-family: var(--font-display);
  font-size: 20px;
  margin-bottom: 8px;
}
.guest-gate p {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}
.guest-gate .btn {
  max-width: 200px;
  margin: 0 auto;
}

/* ── Leaderboard ── */
.leaderboard-sort {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.leaderboard-sort label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  flex-shrink: 0;
}
.leaderboard-sort select {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  appearance: none;
  cursor: pointer;
}
.leaderboard-sort select:focus {
  outline: none;
  border-color: var(--accent);
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s;
}

.lb-row.medal-1 { border-color: #ffd700; background: rgba(255, 215, 0, 0.06); }
.lb-row.medal-2 { border-color: #c0c0c0; background: rgba(192, 192, 192, 0.06); }
.lb-row.medal-3 { border-color: #cd7f32; background: rgba(205, 127, 50, 0.06); }
.lb-row.lb-me { border-color: var(--accent); background: var(--accent-dim); }

.lb-rank {
  width: 32px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.lb-name {
  flex: 1;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-value {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}

/* ── Profile ── */
.profile-hero {
  text-align: center;
  padding: 20px 0 24px;
}

.avatar-wrapper {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

#avatar-initial {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  color: var(--accent);
}

.avatar-edit-badge {
  position: absolute;
  bottom: 12px;
  right: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-dark);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-dark);
}

.profile-hero h2 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 1px;
}

.profile-provider {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Bio Card */
.profile-bio-card {
  margin-bottom: 16px;
}
.profile-bio-card label {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}
.profile-bio-card textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text);
  resize: none;
  transition: border-color 0.2s;
}
.profile-bio-card textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-sm {
  padding: 8px 16px !important;
  font-size: 12px !important;
  width: auto !important;
  margin-top: 8px;
}

/* Stats Grid */
.card-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-box {
  text-align: center;
  padding: 14px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stats-detail {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-input);
  font-size: 13px;
}
.stat-row:first-child { border-radius: 8px 8px 0 0; }
.stat-row:last-child { border-radius: 0 0 8px 8px; }

.stat-row span:first-child {
  color: var(--text-dim);
}
.stat-row span:last-child {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
}

/* ── Mobile Tweaks ── */
@media (max-width: 380px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sub-tab {
    font-size: 11px;
    padding: 8px 4px;
  }

  .login-card {
    padding: 20px 16px;
  }

  .lb-row {
    padding: 10px 10px;
    gap: 8px;
  }

  .lb-name {
    font-size: 13px;
  }
}

/* Ensure the container has proper padding with safe areas */
#tab-community .container,
#tab-profile .container {
  max-width: 460px;
  margin: 0 auto;
  padding: 0 calc(env(safe-area-inset-right, 0px) + 16px) 20px calc(env(safe-area-inset-left, 0px) + 16px);
}

/* ── Safe area support for notched devices ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: calc(env(safe-area-inset-bottom));
  }
  #app-shell {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }
}

/* ── Prevent text selection on nav and buttons ── */
.bottom-nav, .sub-tabs, .nav-item, .sub-tab {
  -webkit-user-select: none;
  user-select: none;
}

/* ── Smooth scrolling on tab content ── */
.tab-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Hide bottom nav during game ── */
body:not(.lobby-page) .bottom-nav {
  display: none;
}

/* ── Ensure proper container spacing in Play tab ── */
#tab-play .container {
  padding-top: calc(env(safe-area-inset-top, 20px) + 12px);
  padding-left: calc(env(safe-area-inset-left, 0px) + 16px);
  padding-right: calc(env(safe-area-inset-right, 0px) + 16px);
  padding-bottom: 20px;
}

/* ── Action Menu (⋮ dropdown) ── */
.action-menu-wrapper {
  position: relative;
  flex-shrink: 0;
}

.btn-icon-more {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}
.btn-icon-more:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.action-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  min-width: 160px;
  background: #1a1c28;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin-top: 4px;
  animation: menuFadeIn 0.15s ease-out;
}
.action-menu.hidden { display: none; }

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

.action-menu button {
  display: block;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.action-menu button:hover {
  background: rgba(255,255,255,0.06);
}
.action-menu button:last-child {
  color: var(--danger);
}

/* Search result actions wrapper */
.search-result-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Feedback Buttons ── */
.card-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 16px;
  margin-top: -4px;
}

.feedback-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}
.feedback-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: var(--accent);
}
.feedback-btn:active {
  transform: scale(0.98);
}

.feedback-icon {
  font-size: 20px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Report Modal ── */
.report-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
}
.report-subtitle strong {
  color: var(--accent);
}

/* Select styling for report reason */
#report-reason {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  padding: 12px 14px;
  width: 100%;
  cursor: pointer;
}
#report-reason:focus {
  outline: none;
  border-color: #ff6b35;
}
#report-reason option {
  background: #1a1c28;
  color: #fff;
}
