/* PlayHub — design system + home page */

:root {
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Rubik', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg0: #070a14;
  --bg1: #0c1122;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.09);
  --surface-solid: #131a30;
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef1fb;
  --text-dim: #98a1bd;
  --accent: #7c5cff;
  --accent-2: #00d4ff;
  --grad: linear-gradient(135deg, #7c5cff, #00d4ff);
  --danger: #ff5470;
  --ok: #2dd4a7;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  --glow-1: rgba(124, 92, 255, 0.16);
  --glow-2: rgba(0, 212, 255, 0.1);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg0: #eef1fa;
  --bg1: #e2e8f6;
  --surface: rgba(255, 255, 255, 0.75);
  --surface-2: rgba(255, 255, 255, 1);
  --surface-solid: #ffffff;
  --border: rgba(25, 35, 70, 0.1);
  --text: #151b30;
  --text-dim: #5c6580;
  --accent: #6a48ff;
  --accent-2: #0090c8;
  --grad: linear-gradient(135deg, #6a48ff, #00a6e8);
  --danger: #e2314f;
  --ok: #0da678;
  --shadow: 0 10px 28px rgba(30, 40, 90, 0.12);
  --glow-1: rgba(124, 92, 255, 0.14);
  --glow-2: rgba(0, 180, 255, 0.12);
}

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

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

body {
  font-family: var(--font);
  background: var(--bg0);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  animation: pageIn 0.35s ease both;
}

@keyframes pageIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ambient background glow */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(700px 500px at 85% -5%, var(--glow-1), transparent 65%),
    radial-gradient(700px 500px at 10% 110%, var(--glow-2), transparent 65%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
}

button { font-family: inherit; color: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

::selection { background: var(--accent); color: #fff; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg0) 72%, transparent);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-lead { display: flex; align-items: center; gap: 10px; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: 0.2px;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124, 92, 255, 0.35);
}

.brand-name {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.iconbtn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: color 0.15s, background 0.15s, transform 0.12s;
}

.iconbtn:hover { color: var(--text); background: var(--surface-2); }
.iconbtn:active { transform: scale(0.93); }
.iconbtn.is-off { color: var(--danger); }

/* narrow phones: a tighter header, so a game page never scrolls sideways */
@media (max-width: 420px) {
  .topbar-inner { padding: 8px 10px; gap: 6px; }
  .topbar-lead, .topbar-actions { gap: 5px; }
  .iconbtn, .acct-btn { width: 36px; height: 36px; }
  .brand { font-size: 17px; gap: 7px; }
  .brand-logo { width: 32px; height: 32px; }
}

.langbtn { font-weight: 700; font-size: 13px; }

html[dir="rtl"] .icon-back svg { transform: scaleX(-1); }

/* ---------- home ---------- */
.home {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

.hero {
  text-align: center;
  padding: 52px 0 30px;
}

.hero-title {
  font-size: clamp(42px, 8vw, 68px);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

.hero-title span {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-sub {
  margin-top: 10px;
  font-size: clamp(15px, 2.5vw, 19px);
  color: var(--text-dim);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 26px;
}

.chip {
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}

.chip:hover { color: var(--text); background: var(--surface-2); }

.chip.active {
  background: var(--grad);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(124, 92, 255, 0.35);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s;
  animation: cardIn 0.45s ease both;
  animation-delay: calc(var(--i) * 45ms);
  position: relative;
  overflow: hidden;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--g1) 45%, var(--border));
}

.card:hover::after { opacity: 0.06; }
.card:active { transform: translateY(-2px) scale(0.99); }

.card.hidden { display: none; }

.card-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--g1), var(--g2));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--g1) 40%, transparent);
  transition: transform 0.18s;
}

.card:hover .card-icon { transform: scale(1.08) rotate(-4deg); }

.card-name { font-size: 18px; font-weight: 700; }

.card-desc {
  font-size: 13.5px;
  color: var(--text-dim);
  margin-top: 3px;
  min-height: 2.6em;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.best-badge {
  font-size: 12px;
  font-weight: 700;
  color: color-mix(in srgb, var(--g1) 75%, var(--text));
}

.footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 13.5px;
  padding-top: 44px;
}

/* ---------- shared buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: 12px;
  font-size: 14.5px;
  font-weight: 700;
  transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}

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

.btn-primary {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.35);
}

.btn-primary:hover { box-shadow: 0 8px 26px rgba(124, 92, 255, 0.5); }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover { background: var(--surface-2); }

/* ---------- extra themes (all free) ---------- */
html[data-theme="gold"] {
  color-scheme: dark;
  --bg0: #14100a;
  --bg1: #1c1508;
  --surface: rgba(255, 214, 130, 0.06);
  --surface-2: rgba(255, 214, 130, 0.12);
  --surface-solid: #241b0e;
  --border: rgba(255, 214, 130, 0.16);
  --text: #f8efd8;
  --text-dim: #b3a684;
  --accent: #f5c518;
  --accent-2: #ff9d2e;
  --grad: linear-gradient(135deg, #f5c518, #ff9d2e);
  --danger: #ff5470;
  --ok: #2dd4a7;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  --glow-1: rgba(245, 197, 24, 0.14);
  --glow-2: rgba(255, 157, 46, 0.1);
}

html[data-theme="neon"] {
  color-scheme: dark;
  --bg0: #060014;
  --bg1: #10032a;
  --surface: rgba(255, 0, 229, 0.055);
  --surface-2: rgba(0, 255, 213, 0.09);
  --surface-solid: #170b33;
  --border: rgba(255, 0, 229, 0.22);
  --text: #f2eaff;
  --text-dim: #a08fd0;
  --accent: #ff00e5;
  --accent-2: #00ffd5;
  --grad: linear-gradient(135deg, #ff00e5, #00ffd5);
  --danger: #ff2d55;
  --ok: #00ffa3;
  --shadow: 0 12px 34px rgba(255, 0, 229, 0.18);
  --glow-1: rgba(255, 0, 229, 0.16);
  --glow-2: rgba(0, 255, 213, 0.12);
}

html[data-theme="retro"] {
  color-scheme: dark;
  --bg0: #201a33;
  --bg1: #2d2244;
  --surface: rgba(255, 236, 210, 0.06);
  --surface-2: rgba(255, 236, 210, 0.11);
  --surface-solid: #342a4e;
  --border: rgba(255, 236, 210, 0.16);
  --text: #ffeedd;
  --text-dim: #b6a5a0;
  --accent: #ff6b6b;
  --accent-2: #feca57;
  --grad: linear-gradient(135deg, #ff6b6b, #feca57);
  --danger: #ff4757;
  --ok: #1dd1a1;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --glow-1: rgba(255, 107, 107, 0.14);
  --glow-2: rgba(254, 202, 87, 0.12);
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: color-mix(in srgb, var(--bg0) 62%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: pageIn 0.18s ease both;
}

.modal-backdrop.closing { opacity: 0; transition: opacity 0.15s; }

.modal-card {
  position: relative;
  width: min(420px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
  text-align: center;
  animation: overlayPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.modal-x {
  position: absolute;
  top: 12px;
  inset-inline-start: 12px;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 14px;
}

.modal-x:hover { color: var(--text); }

.modal-icon { font-size: 42px; line-height: 1.2; margin-bottom: 8px; }
.modal-title { font-size: 21px; font-weight: 800; margin-bottom: 6px; }
.modal-sub { color: var(--text-dim); font-size: 14px; margin: 6px 0; line-height: 1.55; }

/* ---------- auth ---------- */
.auth-tabs {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  padding: 8px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
}

.auth-tab.active { background: var(--grad); color: #fff; }

.auth-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  background: #fff;
  color: #1f2937;
  font-weight: 700;
  font-size: 14.5px;
  border: 1px solid var(--border);
  transition: transform 0.12s, box-shadow 0.15s;
}

.auth-google:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18); }
.auth-google:active { transform: scale(0.98); }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 12.5px;
  margin: 14px 0;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-input {
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: var(--text-dim); }

.auth-submit { width: 100%; margin-top: 2px; }

.auth-forgot {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: underline;
}

.auth-forgot:hover { color: var(--text); }

.auth-error {
  min-height: 1.4em;
  margin-top: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--danger);
}

.auth-error.ok { color: var(--ok); }

.auth-field-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.auth-field-row .auth-input { margin-bottom: 0; }

/* ---------- account button & menu ---------- */
.acct-wrap { position: relative; }

.acct-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: transform 0.12s, border-color 0.15s;
}

.acct-btn:hover { border-color: var(--accent); color: var(--text); }
.acct-btn:active { transform: scale(0.93); }

.acct-avatar { width: 100%; height: 100%; object-fit: cover; }

.acct-initial {
  font-weight: 800;
  font-size: 16px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.acct-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 230px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 100;
  animation: menuIn 0.15s ease both;
  text-align: start;
}

@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px); }
}

.acct-menu-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.acct-menu-name { font-weight: 800; font-size: 15px; }
.acct-menu-sub { font-size: 12px; color: var(--text-dim); word-break: break-all; }

.acct-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-align: start;
}

.acct-item:hover { background: var(--surface-2); }
.acct-item-ic { font-size: 16px; }

.acct-themes { padding: 8px 12px 4px; border-top: 1px solid var(--border); margin-top: 6px; }
.acct-themes-label { font-size: 11.5px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 7px; }
.acct-themes-row { display: flex; gap: 8px; padding-bottom: 6px; }

.theme-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--border);
  transition: transform 0.12s, border-color 0.15s;
}

.theme-swatch:hover { transform: scale(1.12); }
.theme-swatch.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent); }

.sw-dark { background: linear-gradient(135deg, #0c1122, #7c5cff); }
.sw-light { background: linear-gradient(135deg, #eef1fa, #b9c6f5); }
.sw-gold { background: linear-gradient(135deg, #1c1508, #f5c518); }
.sw-neon { background: linear-gradient(135deg, #10032a, #ff00e5); }
.sw-retro { background: linear-gradient(135deg, #2d2244, #ff6b6b); }

/* ---------- leaderboard ---------- */
.lb-body { margin-top: 6px; }

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  background: var(--surface);
  font-size: 14px;
  text-align: start;
}

.lb-row.me { border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }

.lb-rank { width: 30px; font-weight: 800; flex-shrink: 0; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-me { color: var(--text-dim); font-size: 12px; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lb-note { margin-top: 10px; }

.lb-spin {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 14px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 500; overflow: hidden; }

.confetti-bit {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confFall linear both;
}

@keyframes confFall {
  to { transform: translateY(105vh) rotate(720deg); }
}

.btn:disabled { opacity: 0.65; cursor: default; }

/* ---------- profile page ---------- */
.profilepg {
  max-width: 900px;
  margin: 0 auto;
  padding: 30px 18px 50px;
}

.store-h2 { font-size: 20px; font-weight: 800; margin: 26px 0 12px; }

.prof-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 14px;
}

.prof-id { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }

.prof-avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  background: var(--grad);
  flex-shrink: 0;
}

.prof-avatar img { width: 100%; height: 100%; object-fit: cover; }

.prof-info { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; }
.prof-name-row { display: flex; gap: 8px; }
.prof-name-row .auth-input { margin-bottom: 0; flex: 1; max-width: 260px; }
.prof-email { color: var(--text-dim); font-size: 13.5px; }

.prof-stats { display: flex; gap: 12px; justify-content: space-around; flex-wrap: wrap; }
.prof-stat { text-align: center; }
.prof-stat-v { display: block; font-size: 26px; font-weight: 800; }
.prof-stat-l { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }

.prof-score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14.5px;
}

.prof-score-row:last-child { border-bottom: none; }

.prof-score-ic {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  flex-shrink: 0;
}

.prof-score-name { flex: 1; font-weight: 600; }
.prof-score-v { font-weight: 800; font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
