/* ── Reset & Base ─────────────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a1a;
  --surface: #12122a;
  --card: #161638;
  --card-hover: #1c1c45;
  --accent: #e94560;
  --accent2: #0f3460;
  --green: #00e676;
  --yellow: #ffd600;
  --cyan: #00e5ff;
  --purple: #b388ff;
  --text: #eaeaea;
  --muted: #8888aa;
  --radius: 18px;
  --glow: 0 0 20px rgba(233, 69, 96, 0.3);
}

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

/* ── Animated Background ─────────────────────────── */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 20%, rgba(233, 69, 96, 0.06) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(15, 52, 96, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(0, 229, 255, 0.03) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

body > * {
  position: relative;
  z-index: 1;
}

/* ── Animations ──────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-3deg); }
  75% { transform: rotate(3deg); }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

@keyframes confettiFall {
  0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.animate-in {
  animation: fadeInUp 0.5s ease both;
}

/* ── Header ──────────────────────────────────────── */
.header {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
  animation: fadeInUp 0.6s ease;
}

.header h1 {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent), var(--yellow), var(--cyan), var(--purple));
  background-size: 300% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 4s linear infinite;
  text-shadow: none;
  cursor: default;
}

.header h1:hover {
  animation: shimmer 1s linear infinite, pop 0.4s ease;
}

.header .subtitle {
  color: var(--muted);
  font-size: 1.15rem;
  margin-top: 0.4rem;
  font-weight: 400;
}

.header .tagline {
  color: var(--accent);
  margin-top: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* ── Progress Bar ────────────────────────────────── */
.progress-section {
  max-width: 900px;
  margin: 1.5rem auto 0.5rem;
  padding: 0 1rem;
  animation: fadeInUp 0.7s ease;
}

.progress-bar {
  background: var(--surface);
  border-radius: 50px;
  height: 32px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.05);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--yellow), var(--green));
  background-size: 200% 100%;
  border-radius: 50px;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s linear infinite;
  background-size: 200% 100%;
}

.progress-text {
  text-align: center;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Challenge Grid ──────────────────────────────── */
.challenges {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.8rem;
  max-width: 1400px;
  margin: 2rem auto;
  padding: 0 2.5rem 4rem;
}

.challenge-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem;
  border: 1px solid rgba(255,255,255,0.04);
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
  animation: fadeInUp 0.5s ease both;
  cursor: default;
}

.challenge-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0;
  transition: opacity 0.3s;
}

.challenge-card:hover {
  transform: translateY(-8px) scale(1.02);
  background: var(--card-hover);
  border-color: rgba(233, 69, 96, 0.25);
  box-shadow: 0 16px 48px rgba(0,0,0,0.4), var(--glow);
}

.challenge-card:hover::before {
  opacity: 1;
}

.challenge-card:nth-child(1) { animation-delay: 0.05s; }
.challenge-card:nth-child(2) { animation-delay: 0.1s; }
.challenge-card:nth-child(3) { animation-delay: 0.15s; }
.challenge-card:nth-child(4) { animation-delay: 0.2s; }
.challenge-card:nth-child(5) { animation-delay: 0.25s; }
.challenge-card:nth-child(6) { animation-delay: 0.3s; }

.challenge-card.solved {
  border-color: rgba(0, 230, 118, 0.3);
}

.challenge-card.solved::before {
  background: var(--green);
  opacity: 1;
}

.challenge-card.solved::after {
  content: "CRACKED! 🎉";
  position: absolute;
  top: 16px;
  right: -28px;
  background: var(--green);
  color: #000;
  padding: 4px 40px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 1px;
  transform: rotate(35deg);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-icon {
  font-size: 3rem;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.05);
  border-radius: 16px;
  flex-shrink: 0;
  transition: transform 0.3s ease;
}

.challenge-card:hover .card-icon {
  animation: wiggle 0.5s ease;
  transform: scale(1.1);
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.card-category {
  display: inline-block;
  background: var(--accent2);
  color: var(--cyan);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 3px 10px;
  border-radius: 50px;
  width: fit-content;
}

.card-difficulty {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.7rem;
  color: var(--muted);
}

.card-difficulty .star {
  color: var(--yellow);
  font-size: 0.65rem;
}

.card-points {
  font-size: 0.75rem;
  color: var(--yellow);
  font-weight: 700;
  margin-left: auto;
}

.challenge-card h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.challenge-card p {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 1.2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, var(--accent), #c0392b);
  color: #fff;
  border: none;
  padding: 11px 26px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.25s ease;
  letter-spacing: 0.3px;
}

.btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 8px 24px rgba(233, 69, 96, 0.45);
}

.btn:active {
  transform: translateY(0) scale(0.97);
}

.btn-small {
  padding: 9px 20px;
  font-size: 0.82rem;
}

.btn-submit {
  background: linear-gradient(135deg, var(--green), #00c853);
  color: #000;
}

.btn-submit:hover {
  box-shadow: 0 6px 20px rgba(0, 230, 118, 0.4);
}

/* ── Challenge Pages ─────────────────────────────── */
.challenge-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  animation: fadeInUp 0.5s ease;
}

.challenge-page h1 {
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
}

.challenge-page .difficulty-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  color: var(--yellow);
  font-weight: 600;
  margin-bottom: 1.2rem;
}

.challenge-page .description {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 1.5rem;
}

.section-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255,255,255,0.04);
}

.section-box h3 {
  font-size: 1.05rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hint-box {
  background: var(--surface);
  border-left: 4px solid var(--yellow);
  padding: 1.1rem 1.3rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
  line-height: 1.6;
}

.hint-box strong {
  color: var(--yellow);
}

.hint-toggle {
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.hint-toggle summary {
  padding: 1rem 1.3rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--yellow);
  font-size: 0.92rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.hint-toggle summary:hover {
  background: rgba(255,255,255,0.02);
}

.hint-toggle summary::before {
  content: ">";
  font-family: monospace;
  transition: transform 0.2s;
  display: inline-block;
}

.hint-toggle[open] summary::before {
  transform: rotate(90deg);
}

.hint-toggle .hint-content {
  padding: 0 1.3rem 1.2rem;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

.code-block {
  background: #08081a;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
  font-family: "Cascadia Code", "Fira Code", "JetBrains Mono", monospace;
  font-size: 0.95rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  line-height: 1.7;
  color: var(--cyan);
  position: relative;
}

.code-block.highlighted {
  border-color: var(--accent);
  box-shadow: 0 0 15px rgba(233, 69, 96, 0.15);
}

/* ── Flag Input ──────────────────────────────────── */
.flag-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-top: 2rem;
  border: 1px solid rgba(255,255,255,0.04);
}

.flag-section h3 {
  font-size: 1rem;
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flag-form {
  display: flex;
  gap: 0.5rem;
}

.flag-input {
  flex: 1;
  padding: 13px 20px;
  border-radius: 50px;
  border: 2px solid rgba(255,255,255,0.08);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: "Cascadia Code", "Fira Code", monospace;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.flag-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(233, 69, 96, 0.2);
}

.flag-input::placeholder {
  color: #555;
  font-family: "Segoe UI", system-ui, sans-serif;
}

.flag-result {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
  display: none;
  animation: fadeInUp 0.3s ease;
}

.flag-result.correct {
  background: rgba(0, 230, 118, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 230, 118, 0.2);
  display: block;
}

.flag-result.wrong {
  background: rgba(233, 69, 96, 0.1);
  color: var(--accent);
  border: 1px solid rgba(233, 69, 96, 0.2);
  display: block;
}

/* ── Caesar Alphabet Table ───────────────────────── */
.alphabet-table {
  display: grid;
  grid-template-columns: auto repeat(26, 1fr);
  gap: 0;
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.72rem;
  margin: 1rem 0;
  overflow-x: auto;
}

.alphabet-table .row-label {
  padding: 6px 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.alphabet-table .row-label.encrypted { color: var(--accent); }
.alphabet-table .row-label.decoded { color: var(--green); }

.alphabet-table .cell {
  padding: 6px 0;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s;
}

.alphabet-table .cell.top {
  color: var(--accent);
  background: rgba(233, 69, 96, 0.06);
}

.alphabet-table .cell.bottom {
  color: var(--green);
  background: rgba(0, 230, 118, 0.06);
}

.alphabet-table .cell:hover {
  background: rgba(255,255,255,0.08);
}

/* ── Workspace (decode area) ─────────────────────── */
.decode-workspace {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 1rem 0;
}

.decode-char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.decode-char .original {
  font-family: "Cascadia Code", monospace;
  font-size: 1rem;
  color: var(--accent);
  font-weight: 700;
  padding: 4px 2px;
}

.decode-char input {
  width: 28px;
  height: 32px;
  text-align: center;
  background: var(--bg);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--green);
  font-family: "Cascadia Code", monospace;
  font-size: 0.95rem;
  font-weight: 700;
  outline: none;
  text-transform: uppercase;
  transition: border-color 0.2s;
}

.decode-char input:focus {
  border-color: var(--cyan);
}

.decode-char input.correct-letter {
  border-color: var(--green);
  background: rgba(0, 230, 118, 0.08);
}

.decode-char .spacer {
  width: 16px;
}

/* ── Utilities ───────────────────────────────────── */
.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  padding: 6px 14px;
  border-radius: 50px;
  transition: all 0.2s;
}

.back-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}

.mb-1 { margin-bottom: 1rem; }

code {
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.88em;
}

a { color: var(--cyan); }

/* ── Confetti Container ──────────────────────────── */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 999;
}

.confetti {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall 3s ease-in forwards;
}

/* ── Navbar ─────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.5rem;
  background: rgba(10, 10, 26, 0.95);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  animation: fadeInUp 0.3s ease;
}

.nav-left, .nav-center, .nav-right { display: flex; align-items: center; gap: 0.8rem; }
.nav-center { flex: 1; justify-content: center; }

.nav-brand {
  font-weight: 900;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.5px;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text); }

.nav-comp {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.nav-comp-live {
  background: #e94560;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 50px;
  letter-spacing: 1px;
  animation: pulse 2s infinite;
}

.nav-comp-name { color: var(--muted); }

.nav-comp-timer {
  font-family: "Cascadia Code", monospace;
  color: var(--cyan);
  font-size: 0.85rem;
  font-weight: 700;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.nav-rank { font-size: 1.1rem; }

.nav-points {
  color: var(--yellow);
  font-weight: 700;
  font-size: 0.75rem;
  background: rgba(255, 214, 0, 0.1);
  padding: 2px 8px;
  border-radius: 50px;
}

.nav-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.nav-logout:hover { color: var(--accent); border-color: var(--accent); }

/* ── Terminal Login ────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.terminal-container {
  width: 100%;
  max-width: 520px;
  animation: fadeInUp 0.5s ease;
}

.terminal {
  background: #0c0c1e;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transition: box-shadow 0.5s, border-color 0.5s;
}

.terminal.access-granted {
  border-color: var(--green);
  box-shadow: 0 0 40px rgba(0,230,118,0.3);
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1.2rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.terminal-dots { display: flex; gap: 6px; }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot.red { background: #ff5f57; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #28c840; }

.terminal-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.terminal-body {
  padding: 1.5rem;
}

.terminal-output {
  margin-bottom: 1.5rem;
}

.t-line {
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.82rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
}

.t-line.fade-in {
  animation: fadeInUp 0.4s ease both;
}

.t-prompt { color: var(--cyan); font-weight: 700; }
.t-green { color: var(--green); }
.t-yellow { color: var(--yellow); }

.auth-form.fade-in {
  animation: fadeInUp 0.4s ease both;
}

.form-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1.2rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}

.toggle-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 1px;
  font-family: "Cascadia Code", monospace;
}

.toggle-btn.active {
  background: var(--accent);
  color: #fff;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.input-row label {
  font-family: "Cascadia Code", monospace;
  font-size: 0.85rem;
  color: var(--cyan);
  white-space: nowrap;
  font-weight: 700;
}

.input-row input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--green);
  font-family: "Cascadia Code", monospace;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-row input:focus {
  border-color: var(--cyan);
}

.terminal-submit {
  width: 100%;
  margin-top: 0.8rem;
  font-family: "Cascadia Code", monospace;
  letter-spacing: 1px;
  justify-content: center;
}

.terminal-msg {
  margin-top: 1rem;
  font-family: "Cascadia Code", monospace;
  font-size: 0.82rem;
  min-height: 1.2em;
  text-align: center;
}

.terminal-msg.success { color: var(--green); }
.terminal-msg.error { color: var(--accent); }

/* ── Screen Flash ──────────────────────────────────── */
.screen-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 998;
  animation: flashFade 0.6s ease forwards;
}

@keyframes flashFade {
  0% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* ── First Blood Banner ────────────────────────────── */
.first-blood-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px) scale(0.9);
  background: linear-gradient(135deg, #e94560, #ff1744);
  color: #fff;
  padding: 1rem 2.5rem;
  border-radius: 16px;
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 2px;
  z-index: 1000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 12px 40px rgba(233, 69, 96, 0.5);
  text-align: center;
}

.first-blood-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.fb-icon { font-size: 1.5rem; }
.fb-sub { display: block; font-size: 0.8rem; font-weight: 500; margin-top: 0.3rem; letter-spacing: 0; opacity: 0.9; }

/* ── Rank Up Notification ──────────────────────────── */
.rank-up-notif {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 1001;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.rank-up-notif.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.rank-up-content {
  background: var(--surface);
  border: 2px solid var(--yellow);
  border-radius: 24px;
  padding: 2rem 3rem;
  text-align: center;
  box-shadow: 0 0 60px rgba(255, 214, 0, 0.3);
}

.rank-up-emoji { font-size: 4rem; margin-bottom: 0.5rem; }

.rank-up-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--yellow);
  letter-spacing: 3px;
  margin-bottom: 0.3rem;
}

.rank-up-title {
  font-size: 1.6rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--yellow), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ── Points Popup ──────────────────────────────────── */
.points-popup {
  position: absolute;
  top: -10px;
  right: 20px;
  color: var(--yellow);
  font-size: 1.4rem;
  font-weight: 900;
  opacity: 0;
  transform: translateY(0);
  transition: all 0.8s ease;
  pointer-events: none;
  z-index: 50;
  text-shadow: 0 0 10px rgba(255, 214, 0, 0.5);
}

.points-popup.show {
  opacity: 1;
  transform: translateY(-40px);
}

/* ── Input Shake ───────────────────────────────────── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.shake {
  animation: shake 0.4s ease !important;
}

/* ── No Competition Overlay ────────────────────────── */
.no-comp-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  z-index: 10;
}

.no-comp-box {
  text-align: center;
  padding: 2rem;
  max-width: 400px;
}

.no-comp-emoji { font-size: 3rem; margin-bottom: 1rem; animation: float 2s ease-in-out infinite; }

.no-comp-box h2 { font-size: 1.4rem; margin-bottom: 0.5rem; }

.no-comp-box p { color: var(--muted); font-size: 0.9rem; line-height: 1.6; }

/* ── Leaderboard Page ──────────────────────────────── */
.leaderboard-page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
  animation: fadeInUp 0.5s ease;
}

.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.lb-header h1 {
  font-size: 2rem;
  font-weight: 900;
}

.lb-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lb-controls select {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.lb-auto-refresh {
  color: var(--muted);
  font-size: 0.72rem;
}

.lb-status {
  padding: 0.6rem 1rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-align: center;
}
.lb-status.live { background: rgba(233, 69, 96, 0.1); color: var(--accent); border: 1px solid rgba(233,69,96,0.2); }
.lb-status.ended { background: rgba(0,229,255,0.05); color: var(--cyan); border: 1px solid rgba(0,229,255,0.1); }

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.04);
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.lb-table thead {
  background: var(--surface);
}

.lb-table th {
  padding: 0.8rem 1rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid rgba(255,255,255,0.06);
}

.lb-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.lb-row:hover { background: rgba(255,255,255,0.02); }

.lb-row:nth-child(1) { background: rgba(255, 215, 0, 0.04); }
.lb-row:nth-child(2) { background: rgba(192, 192, 192, 0.03); }
.lb-row:nth-child(3) { background: rgba(205, 127, 50, 0.03); }

.lb-pos { text-align: center; width: 50px; }
.medal { font-size: 1.2rem; }
.medal-num { color: var(--muted); font-weight: 700; }

.lb-user { white-space: nowrap; }
.lb-rank-emoji { margin-right: 0.4rem; }

.lb-points { font-weight: 800; color: var(--yellow); white-space: nowrap; }
.pts-label { font-size: 0.7rem; color: var(--muted); margin-left: 2px; }

.lb-fb { text-align: center; }
.lb-time { color: var(--muted); white-space: nowrap; }

.ch-header {
  font-size: 0.65rem !important;
  text-align: center !important;
  min-width: 80px;
}
.ch-pts { color: var(--yellow); font-size: 0.6rem; }

.ch-cell {
  text-align: center;
  font-size: 0.8rem;
}
.ch-cell.unsolved { color: rgba(255,255,255,0.15); }
.ch-cell.solved-cell { color: var(--green); font-weight: 600; }

.first-blood-badge { font-size: 0.75rem; }

.lb-empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem;
  font-size: 1rem;
}

/* ── Admin Page ────────────────────────────────────── */
.admin-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  animation: fadeInUp 0.5s ease;
}

.admin-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.admin-gate-box {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  max-width: 400px;
  border: 1px solid rgba(255,255,255,0.06);
}

.admin-gate-box h2 { margin-bottom: 0.5rem; }
.admin-gate-box p { color: var(--muted); margin-bottom: 1.2rem; font-size: 0.9rem; }

.admin-gate-form {
  display: flex;
  gap: 0.5rem;
}

.admin-gate-form input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.admin-gate-form input:focus { border-color: var(--accent); }

.admin-gate-msg { margin-top: 0.8rem; font-size: 0.85rem; min-height: 1.2em; }

.admin-dashboard h1 { font-size: 2rem; font-weight: 900; margin-bottom: 1.5rem; }

.admin-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(255,255,255,0.04);
}

.admin-section h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.admin-comp-status {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.comp-active-badge {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green);
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.comp-inactive-badge {
  color: var(--muted);
  font-size: 0.9rem;
}

.comp-elapsed {
  color: var(--muted);
  font-size: 0.8rem;
}

.admin-comp-controls { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.admin-start-form {
  display: flex;
  gap: 0.5rem;
  flex: 1;
}

.admin-start-form input {
  flex: 1;
  padding: 10px 16px;
  background: var(--bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

.admin-start-form input:focus { border-color: var(--green); }

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

.stat-card {
  background: var(--bg);
  border-radius: 14px;
  padding: 1.2rem;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.04);
}

.stat-num { font-size: 2rem; font-weight: 900; color: var(--cyan); }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; text-transform: uppercase; letter-spacing: 1px; }

.comp-history-item {
  padding: 1rem;
  border-radius: 12px;
  background: var(--bg);
  margin-bottom: 0.8rem;
  border: 1px solid rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.comp-history-item.active { border-color: rgba(0, 230, 118, 0.2); }

.comp-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.comp-lb-link {
  font-size: 0.82rem;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 700px) {
  .header h1 { font-size: 2.5rem; }
  .challenges { grid-template-columns: 1fr; padding: 0 1rem 3rem; }
  .challenge-page h1 { font-size: 1.6rem; }
  .alphabet-table { font-size: 0.6rem; }
  .flag-form { flex-direction: column; }
  .flag-form .btn { width: 100%; justify-content: center; }

  .navbar { flex-wrap: wrap; gap: 0.5rem; }
  .nav-center { order: 3; flex-basis: 100%; justify-content: center; }
  .nav-comp-name { display: none; }

  .lb-header { flex-direction: column; align-items: flex-start; }

  .first-blood-banner { font-size: 1rem; padding: 0.8rem 1.5rem; }
  .rank-up-content { padding: 1.5rem 2rem; }

  .admin-start-form { flex-direction: column; }
  .admin-gate-form { flex-direction: column; }
}
