:root {
  --color-bg: #0f0e17;
  --color-surface: #1a1a2e;
  --color-surface-2: #232347;
  --color-text: #fffffe;
  --color-text-muted: #a7a9be;
  --color-accent: #ff8906;
  --color-accent-hover: #e07800;
  --color-score-high: #4ade80;
  --color-score-mid: #facc15;
  --color-score-low: #f87171;
  --color-bar-bg: #2a2a4a;
  --font-display: 'Courier New', 'Menlo', monospace;
  --font-body: system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  width: 100%;
  max-width: 540px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-surface-2);
}

.header-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

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

.header-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  line-height: 1;
  transition: color var(--transition);
}

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

/* App container */
#app {
  flex: 1;
  width: 100%;
  max-width: 540px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: fadeIn 0.3s ease;
}

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

/* Idle screen */
.logo {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-accent);
}

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

.puzzle-info {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-family: var(--font-display);
}

.idle-links {
  display: flex;
  gap: 16px;
}

/* Buttons */
.btn {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 14px 40px;
  transition: all var(--transition);
}

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

.btn-primary:hover {
  background: var(--color-accent-hover);
  transform: translateY(-1px);
}

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

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

.btn-link {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal h3 {
  margin-bottom: 16px;
  font-size: 1.3rem;
}

/* Settings */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-surface-2);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--color-bar-bg);
  border-radius: 26px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: var(--color-text);
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--color-accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* How to play */
.how-content {
  line-height: 1.6;
  color: var(--color-text-muted);
}

.how-content h4 {
  color: var(--color-text);
  margin-top: 16px;
  margin-bottom: 8px;
}

.how-content p {
  margin-bottom: 8px;
}

.how-content ul {
  margin-left: 20px;
  margin-bottom: 8px;
}

/* Pre-rendered SEO content (shown before JS loads, replaced by app) */
.seo-content {
  text-align: left;
  max-width: 520px;
  line-height: 1.7;
  color: var(--color-text-muted);
}

.seo-content h1 {
  text-align: center;
  font-family: var(--font-display);
  color: var(--color-accent);
  font-size: 2rem;
  margin-bottom: 4px;
}

.seo-content h2 {
  font-size: 1.1rem;
  color: var(--color-text);
  margin-top: 24px;
  margin-bottom: 8px;
}

.seo-content h3 {
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 4px;
}

.seo-round {
  padding: 8px 0;
}

.seo-round p {
  font-size: 0.9rem;
}

.seo-nav {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  padding: 16px 0;
  border-top: 1px solid var(--color-surface-2);
  border-bottom: 1px solid var(--color-surface-2);
}

.seo-nav a {
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.seo-nav a:hover {
  text-decoration: underline;
}

.seo-content a {
  color: var(--color-accent);
}
