@import url('https://fonts.googleapis.com/css2?family=Andika:wght@400;700&family=Fraunces:wght@600;700&family=Space+Grotesk:wght@400;500;600&family=Teachers:wght@400;600;700&display=swap');

:root {
  color-scheme: light;
  --ink: #161312;
  --vowel: #d42121;
  --panel: rgba(255, 247, 237, 0.92);
  --card: rgba(255, 255, 255, 0.88);
  --accent: #ffb347;
  --accent-dark: #f06b2b;
  --shadow: 0 24px 60px rgba(25, 20, 18, 0.2);
  --reader-font: 'Space Grotesk', 'Trebuchet MS', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--reader-font);
  color: var(--ink);
  background: radial-gradient(circle at top, #fff7e9 0%, #f9d9b3 35%, #f6b989 100%);
  overflow-x: hidden;
}

.glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.6;
  z-index: 0;
}

.glow-one {
  width: 320px;
  height: 320px;
  background: #ff6a3d;
  top: -120px;
  right: -60px;
}

.glow-two {
  width: 420px;
  height: 420px;
  background: #ffd67a;
  bottom: -180px;
  left: -140px;
}

.grain {
  position: fixed;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="140" height="140" viewBox="0 0 140 140"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/></filter><rect width="140" height="140" filter="url(%23n)" opacity="0.08"/></svg>');
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px clamp(16px, 4vw, 48px);
  background: linear-gradient(90deg, rgba(255, 241, 224, 0.96), rgba(255, 225, 196, 0.92));
  border-bottom: 2px solid rgba(22, 19, 18, 0.08);
  backdrop-filter: blur(6px);
}

.back {
  text-decoration: none;
  font-weight: 600;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 10px 24px rgba(22, 19, 18, 0.15);
}

.title-wrap {
  max-width: 620px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  font-size: 0.8rem;
}

h1 {
  margin: 0;
  font-family: 'Fraunces', 'Georgia', serif;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
}

.subtitle {
  margin: 8px 0 0;
  font-size: 1rem;
  line-height: 1.5;
}

.toggle {
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent-dark);
  color: #fff;
  box-shadow: 0 10px 28px rgba(240, 107, 43, 0.35);
}

.font-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--card);
  box-shadow: 0 10px 24px rgba(22, 19, 18, 0.15);
  font-weight: 600;
}

.font-switch label {
  font-size: 0.85rem;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}

.font-switch select {
  border: 1px solid rgba(22, 19, 18, 0.2);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: inherit;
  font-weight: 600;
  background: #fff;
}

.panel {
  position: relative;
  z-index: 2;
  margin: 0 clamp(16px, 4vw, 48px);
  padding: 20px 20px 12px;
  background: var(--panel);
  border-radius: 24px;
  box-shadow: var(--shadow);
  transform: translateY(-18px);
}

.panel.collapsed {
  padding-bottom: 20px;
}

.panel.collapsed .letters,
.panel.collapsed .panel-row,
.panel.collapsed .status {
  display: none;
}

.panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.vowel {
  background: var(--vowel);
}

.legend-dot.consonant {
  background: var(--ink);
}

.quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.quick button {
  border: 1px solid rgba(22, 19, 18, 0.15);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
  font-weight: 600;
}

.letters {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(42px, 1fr));
  gap: 10px;
}

.letter {
  border: 2px solid rgba(22, 19, 18, 0.12);
  background: rgba(255, 255, 255, 0.6);
  padding: 10px 0;
  border-radius: 14px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border 0.2s ease;
}

.letter.active {
  background: var(--accent);
  border-color: rgba(22, 19, 18, 0.4);
  transform: translateY(-2px);
}

.status {
  margin-top: 12px;
  font-weight: 600;
}

.content {
  position: relative;
  z-index: 1;
  padding: 12px clamp(16px, 4vw, 48px) 80px;
}

.words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
}

.word-card {
  background: var(--card);
  border-radius: 26px;
  padding: 20px;
  min-height: 190px;
  box-shadow: var(--shadow);
  font-family: var(--reader-font);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  animation: float-in 0.6s ease both;
  cursor: pointer;
}

.word-card .emoji {
  font-size: 2.6rem;
}

.word-card .emoji {
  display: none;
}

.word-card.show-image .emoji {
  display: block;
}

.word-card:focus-visible {
  outline: 3px solid var(--accent-dark);
  outline-offset: 4px;
}

.word-card .word {
  font-family: inherit;
  font-size: 1.8rem;
  letter-spacing: 0.02em;
}

.word-card .hint {
  font-size: 0.85rem;
  opacity: 0.6;
}

.word-card .word span {
  color: var(--ink);
}

.word-card .word .vowel {
  color: var(--vowel);
}

.empty {
  padding: 28px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  font-weight: 600;
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 720px) {
  .top {
    position: relative;
  }

  .font-switch {
    width: 100%;
    justify-content: space-between;
  }

  .font-switch select {
    flex: 1;
  }

  .panel {
    transform: none;
    margin-top: 16px;
  }

  .toggle {
    width: 100%;
  }
}
