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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3248;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --accent-glow: rgba(108, 99, 255, 0.25);
  --text: #e8eaf6;
  --text-muted: #7b82a8;
  --error: #ff5c72;
  --success: #4caf82;
  --radius: 14px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ───── AUTH WRAPPER ───── */
.wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 60% 20%, rgba(108,99,255,0.12) 0%, transparent 60%),
              radial-gradient(ellipse at 20% 80%, rgba(76,175,130,0.08) 0%, transparent 50%),
              var(--bg);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  overflow: hidden;
}

/* ───── TABS ───── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}

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

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
}

.tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255,255,255,0.03);
}

/* ───── FORM ───── */
.form {
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 4px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  width: 100%;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.field input::placeholder { color: var(--text-muted); }

/* password eye icon */
.input-icon {
  position: relative;
}
.input-icon input {
  padding-right: 42px !important;
}
.eye {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 16px;
  opacity: 0.5;
  transition: opacity .2s;
  user-select: none;
}
.eye:hover { opacity: 1; }

/* ───── GENDER ───── */
.gender-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.gender-option {
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
}

.gender-option input[type="radio"] {
  display: none;
}

.gender-option span {
  padding: 8px 16px;
  border-radius: 50px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-size: 14px;
  color: var(--text-muted);
  transition: all .2s;
}

.gender-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.gender-option:hover span {
  border-color: var(--accent);
  color: var(--text);
}

/* ───── BUTTON ───── */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s, box-shadow .2s;
  margin-top: 4px;
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 24px var(--accent-glow);
}

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

/* ───── MISC ───── */
.error-msg {
  color: var(--error);
  font-size: 13px;
  min-height: 18px;
}

.switch-text {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.switch-text a {
  color: var(--accent);
  cursor: pointer;
  font-weight: 500;
}

.switch-text a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ───── DASHBOARD ───── */
.dashboard {
  height: 100vh;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* inner scroll handled by dash-main */
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.dash-logo {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.btn-logout {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all .2s;
}

.btn-logout:hover {
  border-color: var(--error);
  color: var(--error);
}

.dash-main {
  flex: 1;
  padding: 28px 32px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  min-height: 0;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  display: flex;
  align-items: center;
  gap: 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 4px 20px var(--accent-glow);
  transition: filter .2s;
}

.avatar-wrap:hover .avatar { filter: brightness(0.75); }

.avatar-upload-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s, transform .2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.avatar-upload-btn:hover {
  background: var(--accent-hover);
  transform: scale(1.15);
}

/* Photo toast */
.photo-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: slideIn .3s ease, fadeOut .3s ease 2.4s forwards;
  z-index: 200;
}

.photo-toast.error { border-left-color: var(--error); }

@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(40px); }
}

.profile-info { flex: 1; }

.profile-info h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}

.profile-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.profile-meta span {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 4px 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.profile-email {
  font-size: 14px;
  color: var(--text-muted);
}

/* ───── STATS ───── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: border-color .2s, transform .2s;
}

.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.stat-icon { font-size: 28px; margin-bottom: 10px; }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.stat-value { font-size: 18px; font-weight: 600; }

/* ─── Dashboard nav grid ─── */
.dash-nav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 600px;
  margin: 0 auto;
}

.dash-nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .2s, transform .2s, box-shadow .2s;
  cursor: pointer;
}

.dash-nav-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px var(--accent-glow);
}

.dash-nav-icon  { font-size: 36px; }
.dash-nav-label { font-size: 14px; font-weight: 600; color: var(--text-muted); }

/* ─── Home layout ─── */
.home-layout {
  display: grid;
  grid-template-columns: 280px 1fr 220px;
  gap: 20px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  height: 100%;
}

.home-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}
.home-sidebar .home-section {
  flex: 1;
  min-height: 0;
}
.home-center  { display: flex; flex-direction: column; gap: 16px; min-height: 0; height: 100%; }

/* ─── Home grid (legacy, kept for compatibility) ─── */
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.home-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.home-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

/* ─── Leaderboard ─── */
.leaders-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.ltab {
  flex: 1;
  padding: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color .2s;
  position: relative;
}
.ltab.active { color: var(--accent); }
.ltab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
}

#home-leaders-list {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.home-leader-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background .15s;
}
.home-leader-row:hover { background: var(--surface2); }

.home-leader-rank  { font-size: 16px; width: 24px; flex-shrink: 0; text-align: center; }
.home-leader-av {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.home-leader-info  { flex: 1; }
.home-leader-name  { font-size: 13px; font-weight: 600; }
.home-leader-sub   { font-size: 11px; color: var(--text-muted); }
.home-leader-score { font-size: 14px; font-weight: 700; color: var(--accent); }

/* ─── Premium messages ─── */
.coin-balance {
  font-size: 13px;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245,158,11,.12);
  border: 1px solid rgba(245,158,11,.3);
  border-radius: 50px;
  padding: 3px 12px;
}


.premium-compose {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.prem-select-wrap { width: 100%; }
.prem-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  cursor: pointer;
}
.prem-select:focus { border-color: var(--accent); }

.prem-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  outline: none;
  font-family: inherit;
  transition: border-color .2s;
}
.prem-textarea:focus { border-color: #f59e0b; }
.prem-textarea::placeholder { color: var(--text-muted); }

.prem-send-btn {
  padding: 11px;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
  box-shadow: 0 4px 16px rgba(245,158,11,.3);
}
.prem-send-btn:hover   { opacity: .9; }
.prem-send-btn:active  { transform: scale(.97); }

.prem-inbox-header {
  padding: 12px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

#prem-inbox {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
}

.prem-feed {
  max-height: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 16px;
}

.prem-feed-center {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prem-msg {
  background: linear-gradient(135deg, rgba(245,158,11,.08), rgba(239,68,68,.06));
  border: 1px solid rgba(245,158,11,.25);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.prem-msg-av {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  background-size: cover; background-position: center;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.prem-msg-body { flex: 1; }
.prem-msg-sender { font-size: 12px; font-weight: 600; color: #f59e0b; margin-bottom: 3px; }
.prem-msg-text   { font-size: 13px; color: var(--text); line-height: 1.4; }
.prem-msg-time   { font-size: 10px; color: var(--text-muted); margin-top: 4px; }
.prem-empty { text-align: center; padding: 20px; color: var(--text-muted); font-size: 13px; }

/* ─── Edit profile form ─── */
.edit-profile-form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.edit-profile-form.hidden { display: none; }

/* ─── Photo lightbox ─── */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  object-fit: none;
}
.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { background: rgba(255,255,255,.3); }
.clickable-photo { cursor: zoom-in; }

/* ─── Clickable profiles ─── */
.clickable-profile { cursor: pointer; }
.clickable-profile:hover { opacity: .8; }

/* ─── King & Queen block ─── */
.royals-block {
  padding: 16px;
}
.royals-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  margin-bottom: 14px;
  letter-spacing: .5px;
}
.royals-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}
.royal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 140px;
}
.royal-crown {
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 0 6px gold);
}
.royal-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  background-size: cover;
  background-position: center;
  border: 3px solid gold;
  box-shadow: 0 0 12px rgba(255,215,0,.4);
}
.royal-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.royal-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}
.royal-score {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}
.royals-vs {
  font-size: 28px;
  opacity: .6;
  flex-shrink: 0;
}

/* ─── Vote center button ─── */
.vote-center-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  text-align: center;
  line-height: 1.2;
  box-shadow: 0 8px 32px var(--accent-glow);
  transition: transform .2s, box-shadow .2s, filter .2s;
  position: sticky;
  top: 24px;
  min-height: 200px;
  align-self: flex-start;
  width: 100%;
}
.vote-center-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px var(--accent-glow);
}

/* ─── Profile modal ─── */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.profile-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  animation: pop .2s ease;
  position: relative;
  margin: auto;
}

/* ─── Language bar ─── */
.lang-bar {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.lang-bar-inline {
  background: none;
  border: none;
  padding: 0;
}
.lang-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.lang-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ─── Mobile nav ─── */
.mobile-nav {
  display: none;
}
.mobile-tab-content {
  display: none;
}
.desktop-hidden {
  display: none;
}

@media (max-width: 768px) {
  /* Hide desktop layout, show mobile */
  .home-layout        { display: none !important; }
  .desktop-hidden     { display: block; }
  .mobile-tab-content { display: block; }
  .mobile-tab-content.hidden { display: none !important; }

  /* Header */
  .dash-header {
    padding: 0 12px;
    height: 52px;
  }
  .dash-logo { font-size: 13px; }
  .lang-bar-inline { gap: 4px; }
  .lang-btn { padding: 4px 8px; font-size: 11px; }
  #msg-btn { display: none; }

  /* Main content */
  .dash-main {
    padding: 12px 12px 80px;
    overflow-y: auto;
  }

  /* Auth page */
  .lang-bar { padding: 6px; }
  .wrapper  { padding: 16px; align-items: flex-start; padding-top: 12px; }
  .card     { border-radius: 16px; }
  .form     { padding: 20px; }
  .row      { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .profile-card { flex-direction: column; text-align: center; }
  .profile-meta { justify-content: center; }

  /* Mobile bottom nav */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 62px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 200;
  }
  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color .15s;
  }
  .mobile-nav-btn span:first-child { font-size: 22px; }
  .mobile-nav-btn.active { color: var(--accent); }
  .mnav-badge {
    position: absolute;
    top: 6px; right: calc(50% - 18px);
    background: var(--accent);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 50px;
    min-width: 16px;
    text-align: center;
  }
}

/* ─── Phone landscape ─── */
@media (max-height: 500px) and (max-width: 900px) {
  /* Dashboard — дозволити скрол */
  .dashboard {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
  }
  .dash-main {
    overflow-y: visible;
    padding-bottom: 70px;
  }
  /* Мобільна навігація — менша висота */
  .mobile-nav {
    height: 48px;
  }
  .mobile-nav-btn span:first-child { font-size: 18px; }

  /* Профільний модал — вирівняти зверху */
  .profile-modal-overlay {
    align-items: flex-start;
    padding: 12px;
  }
  .profile-modal {
    padding: 20px;
  }
}
