/* style.css — global styles, nav, home page, shared components */
:root {
  --bg: #0f1226;
  --bg-soft: #161a3a;
  --surface: #1d2148;
  --surface-2: #262b5c;
  --primary: #7c5cff;
  --primary-2: #4fd1ff;
  --accent: #ffb347;
  --success: #35d68a;
  --danger: #ff5c7a;
  --text: #f4f5ff;
  --text-dim: #a9adcf;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: 'Segoe UI', Tahoma, 'Leelawadee UI', Arial, sans-serif;
}

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

html, body {
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: radial-gradient(circle at top, var(--bg-soft), var(--bg) 65%);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15, 18, 38, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  row-gap: 8px;
}

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

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-textstack {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--primary-2);
}

.brand-title span {
  color: var(--accent);
}

.brand-subtitle {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text);
  white-space: nowrap;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
}

.nav-toggle span {
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

.nav-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.nav-menu a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-menu a:hover,
.nav-menu a.active {
  background: var(--surface-2);
  color: var(--text);
}

.nav-menu a.nav-cta {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #0f1226;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 26px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

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

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  color: #0f1226;
  box-shadow: 0 8px 20px rgba(124, 92, 255, 0.35);
}

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

.btn-outline {
  background: transparent;
  border: 2px solid var(--surface-2);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
}

.btn-danger {
  background: linear-gradient(90deg, #ff5c7a, #ff8a5c);
  color: #1a0b10;
}

/* ---------- Home hero ---------- */
.hero {
  text-align: center;
  padding: 70px 20px 40px;
}

.hero-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary-2);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(36px, 7vw, 64px);
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 14px;
}

.hero h1 .accent {
  background: linear-gradient(90deg, var(--primary-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  color: var(--text-dim);
  font-size: clamp(15px, 2.4vw, 18px);
  max-width: 560px;
  margin: 0 auto 30px;
}

#school-name {
  color: var(--primary-2);
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 15px;
  margin-bottom: 4px;
}

.score-card {
  max-width: 480px;
  margin: 0 auto 40px;
  background: var(--surface);
  border: 1px solid rgba(124, 92, 255, 0.3);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.score-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}

.score-card-season {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--primary-2);
  background: rgba(124, 92, 255, 0.15);
  padding: 4px 10px;
  border-radius: 999px;
}

.score-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.score-card-stat {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
}

.scs-value {
  display: block;
  font-size: 20px;
  font-weight: 900;
  color: var(--accent);
}

.scs-label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Mode cards ---------- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  padding: 20px 0 60px;
}

.mode-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.mode-card .icon {
  font-size: 34px;
}

.mode-card h3 {
  font-size: 22px;
}

.mode-card p {
  color: var(--text-dim);
  font-size: 14px;
  flex-grow: 1;
}

/* ---------- Section titles ---------- */
/* ---------- Shimmer heading effect ---------- */
.shimmer-text {
  background: linear-gradient(
    100deg,
    var(--text) 30%,
    var(--primary-2) 45%,
    var(--accent) 50%,
    var(--primary-2) 55%,
    var(--text) 70%
  );
  background-size: 250% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer-sweep-kf 4.5s linear infinite;
}

@keyframes shimmer-sweep-kf {
  to { background-position: -250% center; }
}

@media (prefers-reduced-motion: reduce) {
  .shimmer-text {
    animation: none;
    background: none;
    -webkit-text-fill-color: currentColor;
    color: var(--text);
  }
}

.section-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
}

.section-sub {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 30px;
  font-size: 14px;
}

/* ---------- Features strip ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  padding-bottom: 60px;
}

.feature-item {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 20px;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.feature-item .icon {
  font-size: 26px;
  margin-bottom: 8px;
}

.feature-item h4 {
  font-size: 15px;
  margin-bottom: 4px;
}

.feature-item p {
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------- Auth gate (login-first home screen) ---------- */
.auth-gate-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.auth-gate-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--surface-2);
  border-top-color: var(--primary);
  animation: gate-spin 0.7s linear infinite;
}

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

.gate-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}

.gate-logo-img {
  width: 76px;
  height: 76px;
  margin: 0 auto 12px;
  display: block;
  border-radius: 16px;
}

.gate-logo {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--text);
}

.gate-logo .accent {
  background: linear-gradient(90deg, var(--primary-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gate-school {
  color: var(--primary-2);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  margin-top: 4px;
}

.gate-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 6px 0 22px;
}

.gate-card .field {
  text-align: left;
}

/* ---------- Auth forms ---------- */
.auth-wrap {
  max-width: 420px;
  margin: 60px auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 34px;
  box-shadow: var(--shadow);
}

.auth-wrap h2 {
  font-size: 26px;
  margin-bottom: 6px;
  text-align: center;
}

.auth-wrap .auth-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 24px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input,
.field select {
  width: 100%;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-2);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px; /* 16px+ stops iOS Safari auto-zooming the page on focus */
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
}

.auth-note {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(124, 92, 255, 0.12);
  color: var(--primary-2);
  font-size: 12.5px;
  text-align: center;
}

.auth-switch {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-dim);
}

.auth-switch a {
  color: var(--primary-2);
  font-weight: 700;
}

.auth-note-error {
  background: rgba(255, 92, 122, 0.14);
  color: var(--danger);
}

/* ---------- Admin ---------- */
.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.season-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-toolbar input {
  flex: 1;
  min-width: 220px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-2);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 16px;
}

.admin-toolbar input:focus {
  outline: none;
  border-color: var(--primary);
}

.admin-count {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.admin-count strong {
  color: var(--text);
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

.admin-row.banned {
  border-color: rgba(255, 92, 122, 0.4);
  background: rgba(255, 92, 122, 0.06);
}

.admin-name {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.5px;
}

.tag-admin {
  background: rgba(124, 92, 255, 0.2);
  color: var(--primary-2);
}

.tag-banned {
  background: rgba(255, 92, 122, 0.2);
  color: var(--danger);
}

.admin-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 0;
}

/* ---------- Leaderboard ---------- */
.leaderboard-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding-bottom: 60px;
}

.leaderboard-filters {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.leaderboard-filters select,
.leaderboard-filters input {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-2);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
}

.leaderboard-filters input {
  min-width: 200px;
}

.leaderboard-filters input:focus {
  outline: none;
  border-color: var(--primary);
}

.live-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: live-dot-pulse-kf 1.6s ease-in-out infinite;
}

@keyframes live-dot-pulse-kf {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(53, 214, 138, 0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(53, 214, 138, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot { animation: none; }
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.15s ease;
}

.leaderboard-list.leaderboard-fading {
  opacity: 0;
}

.rank-row {
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.rank-row:hover {
  transform: translateY(-2px) translateX(2px);
  border-color: rgba(124, 92, 255, 0.35);
}

.rank-row.rank-enter {
  animation: rank-enter-kf 0.45s ease both;
}

@keyframes rank-enter-kf {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.rank-row .rank {
  font-weight: 900;
  font-size: 18px;
  color: var(--text-dim);
  text-align: center;
}

.rank-row.top-1 .rank { color: #ffd447; }
.rank-row.top-2 .rank { color: #d6d6e6; }
.rank-row.top-3 .rank { color: #e0a06b; }

.rank-row.top-1 {
  border-color: rgba(255, 212, 71, 0.5);
  box-shadow: 0 0 0 1px rgba(255, 212, 71, 0.2);
  animation: rank-enter-kf 0.45s ease both, top1-glow-kf 2.4s ease-in-out 0.5s infinite;
}

@keyframes top1-glow-kf {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255, 212, 71, 0.2); }
  50% { box-shadow: 0 0 0 1px rgba(255, 212, 71, 0.45), 0 0 16px rgba(255, 212, 71, 0.25); }
}

@media (prefers-reduced-motion: reduce) {
  .rank-row.rank-enter,
  .rank-row.top-1 {
    animation: none;
  }
}

.rank-name {
  font-weight: 700;
  font-size: 15px;
}

.rank-class {
  font-size: 12px;
  color: var(--text-dim);
}

.rank-score {
  font-weight: 800;
  font-size: 17px;
  color: var(--primary-2);
}

/* ---------- Modal (admin profile viewer) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 20, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 200;
}

.modal-box {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface-2);
}

.profile-modal-subhead {
  font-size: 14px;
  color: var(--primary-2);
  margin-bottom: 10px;
}

/* ---------- Badges & history ---------- */
.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.badge-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-soft);
  border: 1px solid rgba(255, 212, 71, 0.3);
  border-radius: 999px;
  padding: 6px 16px 6px 6px;
  font-size: 13px;
  font-weight: 700;
}

.badge-icon {
  font-size: 18px;
}

.badge-icon-img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: block;
  flex-shrink: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.history-score {
  font-size: 20px;
  font-weight: 900;
  color: var(--primary-2);
  min-width: 70px;
}

.history-meta {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.6;
}

.history-date {
  font-size: 11px;
  opacity: 0.8;
}

.leaderboard-note {
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 20px;
}
