/* Reset and base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #ffffff;
  --bg-secondary: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --success: #10b981;
  --error: #ef4444;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-secondary);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
}

.container.wide {
  max-width: 1400px;
  padding: 1rem 2rem;
}

/* Typography */
h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Header */
header {
  margin-bottom: 2rem;
}

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Forms */
.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  flex: 1;
  min-width: 200px;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="url"] {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 0.375rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-secondary);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.btn-large {
  padding: 0.875rem 2rem;
  font-size: 1rem;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-muted);
}

td code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: var(--bg-secondary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.secret {
  color: var(--text-muted);
}

.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* Code blocks */
.code-block {
  background: #1f2937;
  border-radius: 0.5rem;
  overflow: hidden;
}

.code-block pre {
  padding: 1rem;
  overflow-x: auto;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e5e7eb;
  line-height: 1.7;
}

/* Challenge page */
.challenge-header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.challenge-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.challenge-header .subtitle {
  font-size: 0.85rem;
}

.challenge-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.75rem;
  background: var(--bg);
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: 1px solid var(--border);
}

.progress-container {
  flex: 1;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  width: 0%;
  transition: width 0.3s;
}

.timer {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  min-width: 60px;
  text-align: center;
  background: var(--bg-secondary);
  padding: 0.25rem 0.75rem;
  border-radius: 0.375rem;
  border: 2px solid var(--border);
}

.timer.warning {
  color: var(--error);
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
  animation: pulse 1s infinite;
}

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

.instructions {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.instructions p {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0;
}

.instructions .warning {
  color: var(--error);
  font-weight: 600;
  margin-left: 0.5rem;
}

/* Challenge grid - compact layout for all 30 visible */
.challenges-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.challenge-item {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem;
  transition: border-color 0.15s;
}

.challenge-item:focus-within {
  border-color: var(--accent);
}

.challenge-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
}

.challenge-number {
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.challenge-strings {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
}

.string-part {
  background: #1f2937;
  color: #f9fafb;
  padding: 2px 4px;
  border-radius: 2px;
  font-size: 0.7rem;
  font-weight: 500;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

.plus {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
}

.challenge-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.375rem 0.5rem;
  border: 2px solid var(--accent);
  border-radius: 0.25rem;
  background: #eff6ff;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.challenge-input:focus {
  outline: none;
  border-color: #1d4ed8;
  background: #fff;
}

.challenge-input::placeholder {
  color: var(--accent);
  opacity: 0.5;
}

.challenge-input.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.challenge-input.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

#submitBtn {
  width: 100%;
}

/* Success/Failure pages */
.success-page,
.failure-page {
  text-align: center;
  padding: 3rem;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: var(--success);
  color: white;
  font-size: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.failure-icon {
  width: 80px;
  height: 80px;
  background: var(--error);
  color: white;
  font-size: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.redirect-url {
  margin-top: 1rem;
  color: var(--text-muted);
}

.redirect-url code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-secondary);
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .form-inline {
    flex-direction: column;
  }

  .form-group {
    width: 100%;
  }

  .challenge-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .challenge-input {
    width: 100%;
  }

  table {
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.5rem;
  }
}

/* Copy button */
.copy-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.copy-field code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-copy:hover {
  background: var(--border);
  color: var(--text);
}

.btn-copy.copied {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

/* Login page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon {
  width: 80px;
  height: 80px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--accent);
}

.login-header h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form .form-group {
  width: 100%;
}

input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-full {
  width: 100%;
}

.login-hint {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-hint code {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
}

/* Welcome page */
.welcome-container {
  max-width: 800px;
  margin: 0 auto;
}

.welcome-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-top: 1rem;
}

.welcome-header h1 {
  font-size: 2.25rem;
  margin-bottom: 0.5rem;
}

.welcome-header .tagline {
  font-size: 1.25rem;
  color: var(--text-muted);
}

.welcome-header .tagline em {
  color: var(--accent);
  font-style: normal;
  font-weight: 600;
}

.welcome-intro {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

.welcome-intro p {
  font-size: 1.05rem;
  color: var(--text);
  line-height: 1.7;
}

.welcome-steps {
  margin-bottom: 2rem;
}

.welcome-steps h2 {
  margin-bottom: 1.5rem;
}

.step {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.25rem;
}

.step-number {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.step-content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.375rem;
}

.step-content p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0;
}

.step-content code {
  font-family: var(--font-mono);
  background: var(--bg-secondary);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
}

.welcome-how {
  margin-bottom: 2rem;
}

.welcome-how h2 {
  margin-bottom: 1rem;
}

.challenge-demo {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.demo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.demo-strings {
  display: flex;
  gap: 0.5rem;
}

.demo-real {
  background: #1f2937;
  color: #f9fafb;
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.demo-decoy {
  background: #374151;
  color: #9ca3af;
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-decoration: line-through;
  opacity: 0.6;
}

.demo-arrow {
  font-size: 1.5rem;
  color: var(--text-muted);
}

.demo-answer {
  background: var(--success);
  color: white;
  padding: 0.375rem 0.75rem;
  border-radius: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.feature-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.feature-list li {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-size: 0.9rem;
}

.feature-list li strong {
  color: var(--accent);
}

.welcome-register {
  margin-bottom: 2rem;
}

.welcome-register h2 {
  margin-bottom: 1rem;
}

.welcome-footer {
  text-align: center;
  padding: 1rem 0;
}

.welcome-footer .muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.welcome-footer a {
  color: var(--accent);
  text-decoration: none;
}

.welcome-footer a:hover {
  text-decoration: underline;
}

/* Dashboard header with logout */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.dashboard-header-left h1 {
  margin-bottom: 0.25rem;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: color 0.15s;
}

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

/* Site cards */
.site-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.site-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
}

.site-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.site-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.site-field {
  margin-bottom: 0.75rem;
}

.site-field:last-child {
  margin-bottom: 0;
}

.site-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  margin-bottom: 0.25rem;
}

.site-field-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
}

.site-field-value code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  background: none;
  padding: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-field-value code.secret {
  color: var(--text-muted);
}

.site-field-value .btn-copy {
  flex-shrink: 0;
}

.site-field-value .btn-edit {
  flex-shrink: 0;
}

.btn-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-edit:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.edit-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.edit-form input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
