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

:root {
  --color-bg: #f5f7fa;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-muted: #6b7280;
  --color-primary: #0f3460;
  --color-primary-light: #16537e;
  --color-accent: #e8960c;
  --color-accent-light: #f5b731;
  --color-border: #e5e7eb;
  --color-success: #10b981;
  --color-error: #ef4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}


.hidden { display: none !important; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* === Navigation === */
#main-nav {
  background: var(--color-primary);
  color: #fff;
  padding: 0 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 64px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 0;
}

/* Base nav button */
.nav-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  font-size: 1rem;
  border-radius: var(--radius);
  transition: background 0.15s;
  text-decoration: none;
  display: flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  justify-content: center;
}

.nav-btn:hover,
.nav-btn:focus-visible { background: rgba(255,255,255,0.15); }

/* Labeled nav button: icon on top, text below */
.nav-btn--label {
  flex-direction: column;
  gap: 2px;
  padding: 0.3rem 0.6rem;
  min-width: 64px;
  min-height: 56px;
}

.nav-btn-icon {
  font-size: 1.4rem;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn-text {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.85;
  line-height: 1;
}

.nav-home-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.3rem 0.6rem;
  min-width: 64px;
  min-height: 56px;
  justify-content: center;
  border-radius: var(--radius);
  transition: background 0.15s;
  color: #fff;
  text-decoration: none;
}

.nav-home-logo:hover,
.nav-home-logo:focus-visible { background: rgba(255,255,255,0.15); }

.nav-home-logo img {
  height: 32px;
  width: 32px;
  object-fit: contain;
}

.nav-games-dropdown { position: relative; }

.dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  list-style: none;
  min-width: 180px;
  padding: 0.25rem 0;
  z-index: 200;
}

.dropdown-menu.open { display: block; }

.dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-text);
  text-decoration: none;
}

.dropdown-menu a:hover { background: var(--color-border); }
.dropdown-menu a.current { font-weight: 700; color: var(--color-accent); }

/* === Layout === */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
}

/* === Modal / Overlay === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover { color: var(--color-text); }

.modal h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.btn:focus-visible,
.btn-link:focus-visible,
.op-btn:focus-visible,
.bee-btn:focus-visible,
.nav-btn:focus-visible,
.modal-close:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

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

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

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

.btn-secondary:hover { background: var(--color-text-muted); color: #fff; }

/* === Game message toast === */
#game-message {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--color-error);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 300;
}

#game-message.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === Victory branding === */
.victory-branding {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  opacity: 0.55;
}

.victory-branding img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.victory-branding span {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* === Cross-game promotion (victory overlay) === */
.victory-try-another {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.victory-try-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
}

.victory-try-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.victory-try-btn:hover {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(232, 150, 12, 0.15);
}

.victory-try-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.victory-try-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
  text-align: left;
}

.victory-try-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.victory-try-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.victory-try-arrow {
  color: var(--color-accent);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.victory-all-done {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin: 0;
}

/* === Ad slots === */
.ad-slot {
  width: 100%;
  max-width: 320px;
  min-height: 90px;
  margin: 1rem auto;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* === Utility === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* === Shared: Mode bar (archive/practice) === */
.mode-bar {
  text-align: center;
  padding: 0.5rem 0;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.mode-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mode-archive { background: rgba(139, 92, 246, 0.15); color: #8b5cf6; }
.mode-practice { background: rgba(16, 185, 129, 0.15); color: #10b981; }

.mode-link {
  color: var(--color-primary-light);
  text-decoration: none;
  font-size: 0.85rem;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.mode-link:hover { text-decoration: underline; }

/* === Shared: Stats grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.stat-item .stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  display: block;
}

.stat-item .stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === Shared: Star distribution === */
.star-dist { margin-top: 0.75rem; }

.star-dist h3 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.star-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  font-size: 0.85rem;
}

.star-row .star-label { width: 2rem; text-align: right; }

.star-bar-track {
  flex: 1;
  height: 20px;
  background: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.star-bar {
  height: 100%;
  background: var(--color-accent);
  border-radius: 4px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.3rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  transition: width 0.3s ease;
}

/* === Shared: Help modal content === */
.help-content h3 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}

.help-content h3:first-child { margin-top: 0; }

.help-content p, .help-content ul {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.help-content ul {
  padding-left: 1.25rem;
  margin: 0.25rem 0;
}

/* === Shared: Archive modal === */
.archive-desc {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.archive-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.archive-picker label {
  font-size: 0.9rem;
  font-weight: 600;
}

.archive-date-input {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.archive-recent { margin-bottom: 1rem; }

.archive-recent h3 {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.archive-day {
  display: inline-block;
  padding: 0.3rem 0.5rem;
  margin: 0.15rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 0.8rem;
  text-decoration: none;
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.archive-day:hover {
  border-color: var(--color-accent);
  background: rgba(232, 150, 12, 0.08);
}

.archive-extra {
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

/* === Shared: Social share === */
.social-share {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.15s;
}

.social-btn:hover { opacity: 0.85; }
.social-twitter  { background: #1d9bf0; }
.social-whatsapp { background: #25d366; }
.social-facebook { background: #1877f2; }

/* === Shared: Victory extra links === */
.victory-extra {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.btn-link {
  color: var(--color-primary-light);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
}

.btn-link:hover { text-decoration: underline; }
.btn-link-sep { color: var(--color-text-muted); }

/* === Shared: Email capture === */
.email-capture {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.email-capture-text {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.email-capture-form {
  display: flex;
  gap: 0.4rem;
}

.email-capture-form input[type="email"] {
  flex: 1;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  background: var(--color-bg);
  color: var(--color-text);
}

.email-capture-form input[type="email"]:focus {
  outline: none;
  border-color: var(--color-accent);
}

.email-capture-thanks {
  font-size: 0.85rem;
  color: var(--color-success);
  font-weight: 600;
}

/* === Shared: Small button === */
.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

/* === Shared: Confetti === */
@keyframes confetti-fall {
  0%   { transform: translateY(-10px) rotate(0deg); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

.confetti-piece {
  position: fixed;
  width: 8px;
  height: 8px;
  top: -10px;
  z-index: 450;
  border-radius: 2px;
  animation: confetti-fall 2.5s ease-out forwards;
  pointer-events: none;
}

#confetti-container { pointer-events: none; }

/* === Shared: Toggle switch === */
.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: 12px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

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

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

.toggle-input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(232, 150, 12, 0.3);
}
