:root {
  --bg: #070a16;
  --bg-soft: #0c1124;
  --card: #111a33;
  --card-2: #141d3a;
  --border: rgba(124, 138, 255, 0.16);
  --border-strong: rgba(124, 138, 255, 0.35);
  --text: #e8ecff;
  --muted: #96a0c8;
  --accent: #6c7cff;
  --accent-2: #a855f7;
  --accent-3: #22d3ee;
  --good: #34d399;
  --bad: #fb7185;
  --warn: #fbbf24;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --grad: linear-gradient(135deg, #6c7cff 0%, #a855f7 50%, #22d3ee 100%);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(108, 124, 255, 0.18), transparent 60%),
    radial-gradient(900px 480px at 0% 0%, rgba(168, 85, 247, 0.16), transparent 55%),
    radial-gradient(1000px 600px at 50% 120%, rgba(34, 211, 238, 0.10), transparent 60%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; }

.accent { color: var(--accent-3); }
.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: rgba(7, 10, 22, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; letter-spacing: 0.3px; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; background: var(--grad); color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 6px 18px rgba(108, 124, 255, 0.5);
}
.nav { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btn {
  background: transparent; color: var(--muted); border: 1px solid transparent;
  padding: 8px 14px; border-radius: 999px; cursor: pointer; font-size: 14px; transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); border-color: var(--border); }
.nav-btn.is-active { color: #fff; background: linear-gradient(135deg, rgba(108,124,255,.25), rgba(168,85,247,.25)); border-color: var(--border-strong); }

/* ---------- layout ---------- */
main { flex: 1; width: min(1080px, 100% - 32px); margin: 0 auto; padding: 40px 0 60px; }
.view { animation: fadeUp 0.45s ease both; }

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

/* ---------- hero ---------- */
.hero { text-align: center; padding: 34px 0 8px; }
.eyebrow {
  display: inline-block; font-size: 13px; letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--accent-3); border: 1px solid var(--border); padding: 6px 14px; border-radius: 999px;
  background: rgba(34, 211, 238, 0.06);
}
.hero h1 { font-size: clamp(30px, 5.2vw, 52px); line-height: 1.12; margin: 22px 0 16px; font-weight: 800; }
.hero .sub { color: var(--muted); font-size: 17px; max-width: 640px; margin: 0 auto 30px; line-height: 1.6; }

.start-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.start-form input, #answer-input, #msg-name, #msg-text {
  background: rgba(17, 26, 51, 0.9); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 13px 16px; font-size: 15px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.start-form input { width: min(340px, 100%); }
.start-form input:focus, #answer-input:focus, #msg-name:focus, #msg-text:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(108, 124, 255, 0.22);
}
.hint-line { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- buttons ---------- */
.btn {
  border: none; cursor: pointer; border-radius: 12px; padding: 12px 20px; font-size: 15px; font-weight: 600;
  transition: transform 0.15s, box-shadow 0.2s, filter 0.2s; color: #fff;
}
.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-primary { background: var(--grad); box-shadow: 0 10px 26px rgba(108, 124, 255, 0.4); }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-primary:disabled { filter: grayscale(0.5); cursor: not-allowed; transform: none; }
.btn-ghost {
  background: rgba(17, 26, 51, 0.7); border: 1px solid var(--border); color: var(--text);
}
.btn-ghost:hover { border-color: var(--border-strong); }
.error { color: var(--bad); font-size: 14px; margin-top: 10px; }

/* ---------- stats ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 34px 0; }
.stat {
  background: linear-gradient(160deg, var(--card), var(--bg-soft)); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; text-align: center;
}
.stat-num { display: block; font-size: 26px; font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; display: block; }

/* ---------- features ---------- */
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.feature {
  background: rgba(17, 26, 51, 0.65); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px;
}
.feature h3 { margin: 0 0 8px; font-size: 17px; }
.feature p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 14.5px; }

/* ---------- game ---------- */
.game-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.player-badge { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.player-avatar {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 800;
}
.game-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: rgba(17, 26, 51, 0.8); border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--muted); }
.chip b { color: var(--text); }

.progress-wrap { margin: 24px 0 26px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.progress-meta span:first-child { color: var(--text); font-weight: 600; }
.progress-track { height: 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: var(--grad); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.3, 1); }

.question-card {
  background: linear-gradient(165deg, var(--card-2), var(--bg-soft));
  border: 1px solid var(--border-strong); border-radius: 20px; padding: clamp(24px, 5vw, 44px);
  text-align: center; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.question-card::before {
  content: ""; position: absolute; inset: 0 auto auto 0; width: 100%; height: 3px; background: var(--grad);
}
.type-badge {
  display: inline-block; font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent-3); border: 1px solid var(--border); border-radius: 999px; padding: 5px 13px; margin-bottom: 18px;
}
.question { font-size: clamp(24px, 4vw, 38px); font-weight: 800; margin: 0 0 26px; letter-spacing: 0.4px; }

#answer-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
#answer-input { width: min(280px, 100%); text-align: center; font-size: 22px; font-weight: 700; padding: 12px 16px; }

.hint-row { margin-top: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hint-toggle { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; text-decoration: underline dotted; }
.hint-toggle:hover { color: var(--text); }
.hint-text { color: var(--accent-3); font-size: 14px; }

.milestones { margin-top: 22px; }
.m-title { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.milestone-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.milestone {
  background: rgba(17, 26, 51, 0.7); border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; font-size: 12.5px; color: var(--muted);
}
.milestone.done { border-color: rgba(52, 211, 153, 0.5); color: var(--good); }
.milestone.current { border-color: var(--accent); color: #fff; }

#btn-to-rank { display: block; margin: 26px auto 0; }

/* ---------- rank ---------- */
.view-title { text-align: center; font-size: clamp(26px, 4vw, 38px); margin: 10px 0 6px; font-weight: 800; }
.view-sub { text-align: center; color: var(--muted); margin: 0 0 30px; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin: 0 auto 34px; max-width: 620px; }
.podium-card {
  flex: 1; border-radius: 16px 16px 0 0; border: 1px solid var(--border-strong); text-align: center;
  padding: 18px 8px 16px; background: linear-gradient(180deg, var(--card-2), var(--bg-soft));
}
.podium-card.first { background: linear-gradient(180deg, rgba(251, 191, 36, 0.16), rgba(251, 191, 36, 0.04)); border-color: rgba(251, 191, 36, 0.5); }
.podium-card.second { background: linear-gradient(180deg, rgba(148, 163, 184, 0.16), rgba(148, 163, 184, 0.04)); }
.podium-card.third { background: linear-gradient(180deg, rgba(216, 122, 70, 0.16), rgba(216, 122, 70, 0.04)); }
.podium-rank { font-size: 30px; font-weight: 800; }
.podium-name { font-weight: 700; font-size: 15px; margin: 6px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-meta { color: var(--muted); font-size: 12px; }
.podium-card.first { height: 130px; }
.podium-card.second { height: 100px; }
.podium-card.third { height: 82px; }

.rank-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(17, 26, 51, 0.6); }
.rank-table { width: 100%; border-collapse: collapse; min-width: 560px; }
.rank-table th { text-align: left; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); padding: 14px 16px; border-bottom: 1px solid var(--border); }
.rank-table td { padding: 13px 16px; border-bottom: 1px solid rgba(124, 138, 255, 0.08); font-size: 14.5px; }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table tr.me { background: linear-gradient(90deg, rgba(108, 124, 255, 0.22), rgba(168, 85, 247, 0.10)); }
.rank-table tr.me td { color: #fff; }
.rank-num { font-weight: 700; }
.rank-name { font-weight: 600; }
.my-rank { text-align: center; color: var(--accent-3); margin-top: 18px; font-weight: 600; }

/* ---------- wall ---------- */
.message-form { display: flex; flex-direction: column; gap: 10px; max-width: 640px; margin: 0 auto 30px; }
.message-form textarea, .message-form input { width: 100%; }
.message-form .btn { align-self: flex-start; }
#msg-name-field:empty { display: none; }

.message-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.msg-card {
  background: rgba(17, 26, 51, 0.7); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.msg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.msg-name { font-weight: 700; }
.msg-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.msg-body { color: var(--text); line-height: 1.55; font-size: 14.5px; word-break: break-word; margin: 0; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px;
  background: rgba(4, 6, 14, 0.82); backdrop-filter: blur(8px);
}
.modal {
  position: relative; max-width: 560px; width: 100%; background: linear-gradient(170deg, #1a2450, #0c1124);
  border: 1px solid var(--border-strong); border-radius: 22px; padding: 40px 32px; text-align: center;
  box-shadow: 0 0 60px rgba(108, 124, 255, 0.35); overflow: hidden; animation: pop 0.35s ease both;
}
.modal-glow {
  position: absolute; inset: -40% -20% auto -20%; height: 90%; z-index: -1;
  background: radial-gradient(closest-side, rgba(251, 191, 36, 0.35), rgba(168, 85, 247, 0.22), transparent);
  filter: blur(10px);
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.shake { animation: shake 0.4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.modal-kicker { color: var(--warn); font-size: 12px; letter-spacing: 3px; font-weight: 700; }
.modal h2 { font-size: 30px; margin: 12px 0 16px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.modal p { color: var(--text); line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 100;
  background: var(--card-2); border: 1px solid var(--border-strong); color: var(--text);
  padding: 12px 20px; border-radius: 999px; box-shadow: var(--shadow); font-size: 14px;
  animation: fadeUp 0.3s ease both;
}

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .site-header { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; justify-content: space-between; }
  .nav-btn { flex: 1; text-align: center; padding: 8px 6px; font-size: 13px; }
  .podium { gap: 8px; }
}
