/* =========================================
   PUZZLE ARCHIVE — DESIGN SYSTEM
   Accessibility-focused with high contrast
   ========================================= */

:root {
  /* Background colors - slightly lighter for better contrast */
  --color-bg: #0d0d12;
  --color-bg-card: #151520;
  --color-bg-card-hover: #1c1c2a;
  --color-surface: #1e1e2c;

  /* Border colors - more visible */
  --color-border: #3a3a4d;
  --color-border-hover: #5a5a70;

  /* Text colors - MAXIMUM CONTRAST for accessibility */
  --color-text: #ffffff;           /* Primary text - pure white */
  --color-text-muted: #e0dde8;     /* Secondary text - very light, high contrast */
  --color-text-dim: #c5c1d0;       /* Tertiary text - still very readable */

  /* Gold accent - brighter for visibility */
  --color-gold: #e4c05c;
  --color-gold-bright: #f5d56a;
  --color-gold-dim: #b8973f;
  --color-gold-glow: rgba(228, 192, 92, 0.2);

  /* Accent colors */
  --color-accent: #8b7cf7;
  --color-accent-glow: rgba(139, 124, 247, 0.15);

  /* Feedback colors - brighter */
  --color-success: #5eea9a;
  --color-success-glow: rgba(94, 234, 154, 0.2);
  --color-error: #ff8a8a;
  --color-error-glow: rgba(255, 138, 138, 0.2);

  /* Fonts */
  --font-logo: 'Barriecito', cursive;
  --font-display: 'Cinzel', serif;
  --font-body: 'Crimson Text', serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing - larger for easier interaction */
  --spacing-xs: 0.5rem;
  --spacing-sm: 0.75rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Focus ring for accessibility */
  --focus-ring: 0 0 0 3px var(--color-gold-glow), 0 0 0 5px var(--color-gold);
}

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

html {
  scroll-behavior: smooth;
  /* Respect user's font size preferences */
  font-size: 100%;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.9;          /* Increased line height for readability */
  font-size: 1.35rem;        /* Large base font size (21.6px minimum) */
  overflow-x: hidden;
  /* Improve text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Safe area for notched devices */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Noise texture overlay - reduced opacity for cleaner look */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.02'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* =========================================
   ACCESSIBILITY — Focus States
   ========================================= */

/* Visible focus states for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Skip link for screen readers */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-gold);
  color: var(--color-bg);
  padding: 1rem 2rem;
  z-index: 10000;
  font-weight: 600;
  border-radius: 4px;
  text-decoration: none;
}

.skip-link:focus {
  top: 10px;
}

/* =========================================
   HEADER
   ========================================= */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(13, 13, 18, 0.95);
  border-bottom: 2px solid var(--color-border);
  transition: all 0.3s ease;
}

.site-header.scrolled {
  padding: 0.9rem 2rem;
}

.header-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--color-text);
  padding: 0.25rem;
  border-radius: 4px;
}

.header-brand:hover {
  color: var(--color-gold-bright);
}

.header-brand-text {
  font-family: var(--font-logo);
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-back {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  text-decoration: none;
  color: var(--color-text);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.85rem 1.5rem;
  border: 2px solid var(--color-gold-dim);
  border-radius: 4px;
  background: rgba(228, 192, 92, 0.1);
  transition: all 0.3s ease;
}

.header-back:hover {
  color: var(--color-bg);
  border-color: var(--color-gold);
  background: var(--color-gold);
}

.header-back svg {
  width: 16px;
  height: 16px;
}

/* =========================================
   HERO
   ========================================= */

.hero {
  padding: 10rem 2rem 5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, var(--color-gold-glow) 0%, transparent 70%);
  pointer-events: none;
}

.hero-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  opacity: 0;
  animation: fadeUp 0.8s ease forwards 0.2s;
}

.hero-ornament-line {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--color-gold-dim));
}

.hero-ornament-line:last-child {
  background: linear-gradient(90deg, var(--color-gold-dim), transparent);
}

.hero-ornament svg {
  width: 20px;
  height: 20px;
  color: var(--color-gold);
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.25;
  margin-bottom: 0.75rem;
  opacity: 0;
  animation: fadeUp 0.8s ease forwards 0.35s;
}

.hero h1 span {
  display: block;
  font-size: 0.4em;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-gold-bright);
  margin-bottom: 1rem;
  font-weight: 600;
}

.hero-intro {
  max-width: 700px;
  margin: 2rem auto 0;
  color: var(--color-text-muted);
  font-size: 1.25rem;
  line-height: 1.9;
  opacity: 0;
  animation: fadeUp 0.8s ease forwards 0.5s;
}

.hero-legend {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--color-border);
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  opacity: 0;
  animation: fadeUp 0.8s ease forwards 0.65s;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.1rem;
  color: var(--color-text);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  padding: 0.6rem 1.1rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.25s ease;
}

.legend-item:hover {
  background: var(--color-bg-card-hover);
  border-color: var(--color-gold-dim);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.legend-item:hover .legend-stars {
  text-shadow: 0 0 8px var(--color-gold-glow);
}

.legend-stars {
  color: var(--color-gold-bright);
  font-size: 1rem;
  letter-spacing: 0.08em;
}

/* =========================================
   DIFFICULTY SECTIONS
   ========================================= */

.archive-section {
  padding: 2.5rem 2rem 4rem;
  max-width: 1100px;
  margin: 0 auto;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--color-border);
}

.section-difficulty {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
  white-space: nowrap;
}

.section-stars {
  color: var(--color-gold-bright);
  font-size: 1.4rem;
  letter-spacing: 0.08em;
}

.section-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--color-border), transparent);
}

.section-count {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--color-text);
  letter-spacing: 0.02em;
  padding: 0.5rem 1rem;
  white-space: nowrap;
  background: var(--color-bg-card);
  border-radius: 4px;
}

/* =========================================
   PUZZLE CARDS
   ========================================= */

.puzzle-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.puzzle-card {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.75rem;
  padding: 1.75rem 2rem;
  background: var(--color-bg-card);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  transition: all 0.35s ease;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
}

.puzzle-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  background: var(--color-gold);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.puzzle-card:hover,
.puzzle-card:focus {
  background: var(--color-bg-card-hover);
  border-color: var(--color-gold-dim);
  transform: translateX(4px);
}

.puzzle-card:hover::before,
.puzzle-card:focus::before {
  opacity: 1;
}

.puzzle-card:hover .puzzle-arrow,
.puzzle-card:focus .puzzle-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--color-gold-bright);
}

.puzzle-card:hover .puzzle-title,
.puzzle-card:focus .puzzle-title {
  color: var(--color-gold-bright);
}

.puzzle-number {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border-radius: 50%;
  letter-spacing: 0;
}

.puzzle-content {
  min-width: 0;
}

.puzzle-title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: nowrap;
}

.puzzle-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: color 0.35s ease;
}

.puzzle-stars {
  color: var(--color-gold-bright);
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.75rem;
  background: rgba(228, 192, 92, 0.15);
  border-radius: 4px;
  border: 1px solid var(--color-gold-dim);
  flex-shrink: 0;
  white-space: nowrap;
}

.puzzle-desc {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1.8;
}

.puzzle-arrow {
  opacity: 0.5;
  transform: translateX(-4px);
  transition: all 0.35s ease;
  color: var(--color-text-muted);
  flex-shrink: 0;
  background: var(--color-surface);
  padding: 0.75rem;
  border-radius: 50%;
}

.puzzle-arrow svg {
  width: 24px;
  height: 24px;
}

/* =========================================
   PUZZLE PAGE SPECIFIC STYLES
   ========================================= */

.puzzle-hero {
  padding: 8rem 2rem 3rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.puzzle-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--color-gold-glow) 0%, transparent 70%);
  pointer-events: none;
}

.puzzle-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards 0.1s;
}

.puzzle-meta-item {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  padding: 0.7rem 1.4rem;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-bg-card);
}

.puzzle-meta-stars {
  color: var(--color-gold-bright);
  border-color: var(--color-gold);
  background: rgba(228, 192, 92, 0.2);
}

.puzzle-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-bottom: 1.75rem;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards 0.2s;
}

.puzzle-hero-intro {
  max-width: 750px;
  margin: 0 auto;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  line-height: 1.9;
  opacity: 0;
  animation: fadeUp 0.6s ease forwards 0.3s;
}

/* Puzzle Content Area */
.puzzle-main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem;
}

.puzzle-image-container {
  margin-bottom: 3rem;
  text-align: center;
}

.puzzle-image {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.puzzle-image-caption {
  margin-top: 1rem;
  font-size: 1rem;
  color: var(--color-text-muted);
}

/* Multiple images grid */
.puzzle-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.puzzle-images-grid .puzzle-image-container {
  margin-bottom: 0;
}

/* =========================================
   ANSWER SUBMISSION
   ========================================= */

.answer-section {
  background: var(--color-bg-card);
  border: 2px solid var(--color-gold-dim);
  border-radius: 8px;
  padding: 2.5rem;
  margin: 3rem 0;
  text-align: center;
}

.answer-section h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 1.75rem;
  color: var(--color-text);
}

.answer-form {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 600px;
  margin: 0 auto;
}

.answer-input {
  flex: 1;
  min-width: 250px;
  padding: 1.1rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  color: var(--color-text);
  transition: all 0.3s ease;
}

.answer-input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 0 4px var(--color-gold-glow);
}

.answer-input::placeholder {
  color: var(--color-text-dim);
}

.answer-submit {
  padding: 1.1rem 2.5rem;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--color-gold);
  color: var(--color-bg);
  border: 2px solid var(--color-gold);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 150px;
}

.answer-submit:hover,
.answer-submit:focus {
  background: var(--color-gold-bright);
  border-color: var(--color-gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--color-gold-glow);
}

/* =========================================
   HINTS ACCORDION
   ========================================= */

.hints-section {
  margin: 3rem 0;
}

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

.hints-header h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text);
}

.hints-header-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--color-border), transparent);
}

.hint-item {
  margin-bottom: 1rem;
}

.hint-toggle {
  display: none;
}

.hint-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem;
  background: var(--color-bg-card);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text);
}

.hint-label:hover,
.hint-label:focus {
  background: var(--color-bg-card-hover);
  border-color: var(--color-gold-dim);
}

.hint-label::after {
  content: '+';
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--color-gold-bright);
  transition: transform 0.3s ease;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(228, 192, 92, 0.15);
  border-radius: 50%;
}

.hint-toggle:checked + .hint-label {
  border-color: var(--color-gold);
  background: var(--color-bg-card-hover);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

.hint-toggle:checked + .hint-label::after {
  transform: rotate(45deg);
  background: var(--color-gold);
  color: var(--color-bg);
}

.hint-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease;
  background: var(--color-surface);
  border: 2px solid var(--color-gold);
  border-top: none;
  border-bottom-left-radius: 6px;
  border-bottom-right-radius: 6px;
}

.hint-toggle:checked ~ .hint-content {
  max-height: 600px;
  padding: 1.75rem;
}

.hint-content p {
  color: var(--color-text);
  line-height: 1.9;
  font-size: 1.1rem;
}

/* =========================================
   MODAL POPUP
   ========================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 14, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  max-width: 750px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
  text-align: center;
  position: relative;
  transform: translateY(30px) scale(0.9);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.4s ease,
              box-shadow 0.4s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Success state glow */
.modal-overlay.active.success .modal {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 80px var(--color-success-glow),
              0 0 120px var(--color-success-glow);
  border-color: rgba(74, 222, 128, 0.3);
}

/* Error state glow */
.modal-overlay.active.error .modal {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 40px var(--color-error-glow);
  border-color: rgba(248, 113, 113, 0.3);
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateY(0) scale(1) translateX(0); }
  20% { transform: translateY(0) scale(1) translateX(-10px); }
  40% { transform: translateY(0) scale(1) translateX(10px); }
  60% { transform: translateY(0) scale(1) translateX(-10px); }
  80% { transform: translateY(0) scale(1) translateX(5px); }
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover,
.modal-close:focus {
  border-color: var(--color-gold);
  color: var(--color-gold-bright);
  background: var(--color-gold-glow);
  transform: rotate(90deg);
}

.modal-icon {
  font-size: 4rem;
  margin-bottom: 1.25rem;
  display: inline-block;
}

.modal-icon.success {
  color: var(--color-success);
  animation: successPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-icon.error {
  color: var(--color-error);
  animation: errorPop 0.4s ease forwards;
}

@keyframes successPop {
  0% {
    transform: scale(0) rotate(-180deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.3) rotate(10deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes errorPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Confetti particles for success */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  border-radius: 8px;
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  opacity: 0;
}

.modal-overlay.active.success .confetti {
  animation: confettiFall 1.5s ease-out forwards;
}

.confetti:nth-child(1) { left: 10%; background: var(--color-gold); animation-delay: 0s; }
.confetti:nth-child(2) { left: 20%; background: var(--color-success); animation-delay: 0.1s; border-radius: 50%; }
.confetti:nth-child(3) { left: 30%; background: var(--color-accent); animation-delay: 0.05s; }
.confetti:nth-child(4) { left: 40%; background: var(--color-gold); animation-delay: 0.15s; border-radius: 50%; }
.confetti:nth-child(5) { left: 50%; background: var(--color-success); animation-delay: 0.08s; }
.confetti:nth-child(6) { left: 60%; background: var(--color-accent); animation-delay: 0.12s; border-radius: 50%; }
.confetti:nth-child(7) { left: 70%; background: var(--color-gold); animation-delay: 0.03s; }
.confetti:nth-child(8) { left: 80%; background: var(--color-success); animation-delay: 0.18s; border-radius: 50%; }
.confetti:nth-child(9) { left: 90%; background: var(--color-accent); animation-delay: 0.07s; }
.confetti:nth-child(10) { left: 15%; background: var(--color-gold); animation-delay: 0.2s; border-radius: 50%; }
.confetti:nth-child(11) { left: 45%; background: var(--color-success); animation-delay: 0.11s; }
.confetti:nth-child(12) { left: 75%; background: var(--color-accent); animation-delay: 0.16s; border-radius: 50%; }

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg) scale(0);
    opacity: 1;
  }
  20% {
    opacity: 1;
    transform: translateY(20px) rotate(180deg) scale(1);
  }
  100% {
    transform: translateY(300px) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 1.25rem;
  color: var(--color-text);
}

.modal-message {
  color: var(--color-text);
  line-height: 1.9;
  margin-bottom: 1.5rem;
  font-size: 1.15rem;
}

.modal-image {
  display: block;
  max-width: 100%;
  max-height: 500px;
  width: auto;
  height: auto;
  margin-left: auto;
  margin-right: auto;
  object-fit: contain;
  border-radius: 4px;
  margin-bottom: 1rem;
  border: 1px solid var(--color-border);
}

.modal-extra {
  color: var(--color-text-muted);
  font-size: 1.15rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--color-border);
  margin-top: 1.25rem;
  line-height: 1.8;
}

/* =========================================
   IMAGE LIGHTBOX
   ========================================= */

.image-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.image-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  touch-action: pinch-zoom;
  user-select: none;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  z-index: 10001;
}

.lightbox-close:hover,
.lightbox-close:focus {
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

/* Hint for clickable images */
.puzzle-image {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.puzzle-image:hover {
  transform: scale(1.01);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* =========================================
   FOOTER
   ========================================= */

.site-footer {
  margin-top: 4rem;
  padding: 3.5rem 2rem;
  border-top: 2px solid var(--color-border);
  text-align: center;
  background: var(--color-bg-card);
}

.footer-cta {
  margin-bottom: 2.5rem;
}

.footer-cta p {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-text);
  letter-spacing: 0.04em;
  margin-bottom: 1.5rem;
}

.footer-cta a {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-bg);
  background: var(--color-gold);
  padding: 1rem 2.5rem;
  border: 2px solid var(--color-gold);
  border-radius: 6px;
  transition: all 0.3s ease;
  font-weight: 700;
}

.footer-cta a:hover,
.footer-cta a:focus {
  background: var(--color-gold-bright);
  border-color: var(--color-gold-bright);
  transform: translateY(-2px);
  box-shadow: 0 6px 25px var(--color-gold-glow);
}

.footer-cta a svg {
  width: 18px;
  height: 18px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  padding: 0.85rem 1.4rem;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 50px;
  transition: all 0.3s ease;
}

.footer-links a:hover,
.footer-links a:focus {
  color: var(--color-gold-bright);
  border-color: var(--color-gold);
  background: rgba(228, 192, 92, 0.08);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(228, 192, 92, 0.15);
}

.footer-links a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.footer-links a:hover svg,
.footer-links a:focus svg {
  opacity: 1;
}

.footer-bottom {
  font-size: 1.05rem;
  color: var(--color-text);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  margin-top: 1.5rem;
}

/* =========================================
   ANIMATIONS
   ========================================= */

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

.puzzle-card {
  opacity: 0;
  animation: fadeUp 0.5s ease forwards;
}

.archive-section:nth-of-type(1) .puzzle-card:nth-child(1) { animation-delay: 0.1s; }
.archive-section:nth-of-type(1) .puzzle-card:nth-child(2) { animation-delay: 0.15s; }
.archive-section:nth-of-type(1) .puzzle-card:nth-child(3) { animation-delay: 0.2s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(1) { animation-delay: 0.1s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(2) { animation-delay: 0.15s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(3) { animation-delay: 0.2s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(4) { animation-delay: 0.25s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(5) { animation-delay: 0.3s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(6) { animation-delay: 0.35s; }
.archive-section:nth-of-type(2) .puzzle-card:nth-child(7) { animation-delay: 0.4s; }
.archive-section:nth-of-type(3) .puzzle-card:nth-child(1) { animation-delay: 0.1s; }
.archive-section:nth-of-type(3) .puzzle-card:nth-child(2) { animation-delay: 0.15s; }
.archive-section:nth-of-type(4) .puzzle-card:nth-child(1) { animation-delay: 0.1s; }
.archive-section:nth-of-type(4) .puzzle-card:nth-child(2) { animation-delay: 0.15s; }
.archive-section:nth-of-type(4) .puzzle-card:nth-child(3) { animation-delay: 0.2s; }

/* =========================================
   RESPONSIVE
   ========================================= */

@media (max-width: 768px) {
  body {
    font-size: 1.1rem;
  }

  .hero {
    padding: 8rem 1.5rem 3rem;
  }

  .puzzle-hero {
    padding: 7rem 1.5rem 2rem;
  }

  .archive-section {
    padding: 1.75rem 1.25rem 3rem;
  }

  .puzzle-main {
    padding: 1.5rem;
  }

  .puzzle-card {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1.5rem;
  }

  .puzzle-number {
    display: none;
  }

  .puzzle-arrow {
    display: none;
  }

  .puzzle-title {
    font-size: 1.25rem;
  }

  .puzzle-desc {
    font-size: 1.05rem;
  }

  .hero-legend {
    display: grid;
    grid-template-columns: repeat(2, auto);
    justify-content: center;
    gap: 0.5rem 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
  }

  .legend-item {
    font-size: 0.9rem;
    padding: 0.4rem 0.7rem;
    gap: 0.4rem;
  }

  .legend-item .legend-stars {
    font-size: 0.8rem;
  }

  .header-brand-text {
    font-size: 1.5rem;
    letter-spacing: 0.02em;
  }

  .header-back {
    font-size: 1rem;
    padding: 0.7rem 1.1rem;
  }

  .section-difficulty {
    font-size: 1rem;
  }

  .footer-links {
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
  }

  .footer-links a {
    font-size: 1rem;
    padding: 0.9rem 1.5rem;
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }

  .answer-section {
    padding: 1.75rem 1.25rem;
  }

  .answer-section h2 {
    font-size: 1.2rem;
  }

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

  .answer-input {
    min-width: auto;
    font-size: 1.15rem;
    padding: 1rem 1.25rem;
  }

  .answer-submit {
    padding: 1rem 2rem;
    font-size: 1.05rem;
  }

  .hint-label {
    font-size: 1.1rem;
    padding: 1.1rem 1.25rem;
  }

  .hint-content p {
    font-size: 1.1rem;
  }

  .modal {
    padding: 2rem 1.5rem;
  }

  .modal-title {
    font-size: 1.5rem;
  }

  .modal-message {
    font-size: 1.1rem;
  }

  .puzzle-images-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 1.05rem;
  }

  .site-header {
    padding: 0.9rem 1rem;
  }

  .header-brand-text {
    font-size: 1.3rem;
  }

  /* Hide "Back to Archive" text on very small screens, show only icon */
  .header-back span {
    display: none;
  }

  .header-back {
    padding: 0.75rem;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }

  .header-back svg {
    width: 20px;
    height: 20px;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .hero-intro {
    font-size: 1.1rem;
  }

  .hero-legend {
    gap: 0.4rem 0.6rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
  }

  .legend-item {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
  }

  .puzzle-hero {
    padding: 6.5rem 1rem 1.5rem;
  }

  .puzzle-hero h1 {
    font-size: 1.6rem;
  }

  .puzzle-hero-intro {
    font-size: 1.05rem;
  }

  .puzzle-meta {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .puzzle-meta-item {
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
  }

  .section-header {
    gap: 0.75rem;
  }

  .section-difficulty {
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
  }

  .section-count {
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
  }

  .modal {
    margin: 1rem;
    padding: 1.5rem 1rem;
    max-height: 85vh;
  }

  .modal-icon {
    font-size: 3rem;
  }

  .modal-title {
    font-size: 1.3rem;
  }

  .modal-message {
    font-size: 1rem;
  }

  .modal-image {
    max-height: 200px;
  }

  .footer-cta p {
    font-size: 1rem;
  }

  .footer-cta a {
    font-size: 0.95rem;
    padding: 0.9rem 1.5rem;
  }

  .puzzle-image-caption {
    font-size: 0.95rem;
  }

  /* Ensure touch targets are at least 44px */
  .hint-label {
    min-height: 44px;
  }

  .answer-submit {
    min-height: 48px;
  }
}
