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

:root {
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --green: #10b981;
  --green-dark: #059669;
  --red: #ef4444;
  --red-dark: #dc2626;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --surface-3: #475569;
  --border: #475569;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
}

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

/* ── Top bar ── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.5rem;
  background: #0b1220;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}
.back-link:hover { color: var(--text); }

.top-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.rule-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* ── Header ── */
.game-header {
  text-align: center;
  padding: 2.5rem 1.5rem 1.5rem;
  max-width: 760px;
  margin: 0 auto;
}

.game-title {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 800;
  background: linear-gradient(135deg, #f8fafc 0%, var(--primary-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
}

.game-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.65;
  max-width: 560px;
  margin: 0 auto;
}

/* ── Main ── */
.game-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ── Password section ── */
.password-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.password-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.password-input {
  width: 100%;
  background: #0b1220;
  border: 2px solid var(--border);
  border-radius: 0.625rem;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
  word-break: break-all;
  transition: border-color 0.2s;
}

.password-input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.password-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.meta-item strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── Rules list ── */
.rules-section {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rules-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.rule-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--surface-3);
  border-radius: 0.625rem;
  padding: 0.85rem 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  transition: all 0.25s ease;
  animation: slideUp 0.35s ease;
}

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

.rule-item.passed {
  border-left-color: var(--green);
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.08) 0%, var(--surface) 60%);
}

.rule-item.failed {
  border-left-color: var(--red);
}

.rule-item.current {
  border-left-color: var(--primary-light);
  box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.3);
}

.rule-status {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.rule-item.passed .rule-status {
  background: var(--green);
  color: white;
}

.rule-item.failed .rule-status {
  background: var(--red);
  color: white;
}

.rule-item.current .rule-status {
  background: var(--primary);
  color: white;
}

.rule-content {
  flex: 1;
  min-width: 0;
}

.rule-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.15rem;
}

.rule-text {
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.55;
  word-break: break-word;
}

.rule-text code {
  background: #0b1220;
  padding: 0.1rem 0.35rem;
  border-radius: 0.3rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.82rem;
  color: var(--gold-light);
}

/* ── Victory banner ── */
.victory-banner {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  padding: 1rem;
}

.victory-banner.active {
  display: flex;
}

.victory-card {
  background: var(--surface);
  border: 1px solid var(--gold);
  border-radius: 1.25rem;
  padding: 2.5rem 2rem;
  max-width: 500px;
  width: 100%;
  text-align: center;
  animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

.victory-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.victory-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 0.75rem;
}

.victory-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.65;
}

.victory-password {
  display: inline-block;
  background: #0b1220;
  padding: 0.5rem 0.85rem;
  border-radius: 0.5rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 0.78rem;
  color: var(--gold-light);
  max-width: 100%;
  overflow-x: auto;
  word-break: break-all;
  margin: 0.5rem 0 1.25rem;
}

.victory-btn {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border: none;
  color: #1e293b;
  padding: 0.75rem 2rem;
  border-radius: 0.625rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.2s;
  width: 100%;
}

.victory-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.4);
}

/* ── Captcha modal ── */
.captcha-modal {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 150;
  animation: slideInRight 0.3s ease;
}

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

.captcha-modal.active {
  display: block;
}

.captcha-card {
  background: var(--surface);
  border: 1px solid var(--primary-light);
  border-radius: 0.875rem;
  padding: 1rem 1.25rem;
  max-width: 260px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.captcha-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary-light);
  margin-bottom: 0.4rem;
}

.captcha-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
  line-height: 1.4;
}

.captcha-question {
  background: #0b1220;
  padding: 0.6rem 0.85rem;
  border-radius: 0.5rem;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gold-light);
  text-align: center;
  margin-bottom: 0.5rem;
}

.captcha-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 0.4rem;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
  width: 100%;
}

.captcha-btn:hover {
  color: var(--text);
  border-color: var(--primary-light);
}

/* ── Mobile ── */
@media (max-width: 600px) {
  .top-bar { padding: 0.5rem 1rem; }
  .top-title { display: none; }
  .game-header { padding: 1.75rem 1rem 1rem; }
  .password-meta { gap: 0.75rem; font-size: 0.72rem; }
  .captcha-modal {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }
  .captcha-card { max-width: none; }
}
