:root {
  --bg: #0b0f14;
  --panel: rgba(255,255,255,0.06);
  --panel-border: rgba(255,255,255,0.12);
  --text: #e6edf3;
  --muted: #9aa4af;
  --accent: #3ddcff;
  --accent-soft: rgba(61,220,255,0.15);
  --radius: 18px;
  --glow: 0 0 25px rgba(61,220,255,0.25);
}

/* GLOBAL */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: radial-gradient(circle at top, #111827 0%, var(--bg) 45%);
  color: var(--text);
  line-height: 1.65;
  scroll-behavior: smooth;
}

/* HEADER */
header {
  position: relative;
  padding: 3rem 1.5rem 2rem;
  text-align: center;
  background: linear-gradient(rgba(11,15,20,0.4), rgba(11,15,20,0.7)), url('/header-bg.png') center/cover no-repeat;
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

@media (pointer: coarse) {
  header { background-attachment: scroll; }
}

/* Logo */
#siteLogo {
  height: 60px;
  width: auto;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(61,220,255,0.25);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
}

#siteLogo:hover {
  transform: scale(1.08) rotate(-2deg);
  box-shadow: 0 8px 25px rgba(61,220,255,0.35);
}

header h1 {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  justify-content: center;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  letter-spacing: .08em;
  margin: 0;
  cursor: pointer;
  transition: color 0.4s ease, transform 0.4s ease;
}

header h1:hover {
  color: var(--accent);
  transform: scale(1.03);
}

header p {
  max-width: 950px;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.4s ease;
}

header p:hover {
  color: var(--accent-soft);
}

a {
  color: lightblue;	
}

/* NAVIGATION */
nav {
  margin-top: 2rem;
  display: flex;
  justify-content: center;
  gap: 2.2rem;
  flex-wrap: wrap;
}

nav a {
  color: var(--text);
  text-decoration: none;
  opacity: 0.7;
  position: relative;
  cursor: pointer;
  transition: opacity 0.6s ease;
}

nav a::after {
  content: '';
  display: block;
  height: 2px;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s;
}

nav a:hover::after { width: 100%; }
nav a:hover { opacity: 1; }

/* NAV DROPDOWN (USES) */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  all: unset;
  color: var(--text);
  text-decoration: none;
  opacity: 0.7;
  cursor: pointer;
  position: relative;
  transition: opacity 0.6s ease;
  padding: 0.2rem 0;
}

.nav-dropdown-toggle::after {
  content: '';
  display: block;
  height: 2px;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s;
}

.nav-dropdown:hover .nav-dropdown-toggle::after,
.nav-dropdown-toggle:focus-visible::after { width: 100%; }

.nav-dropdown:hover .nav-dropdown-toggle,
.nav-dropdown-toggle:focus-visible { opacity: 1; }

.nav-caret { margin-left: 0.25rem; font-size: 0.9em; opacity: 0.9; }

.nav-dropdown .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 220px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 0.6rem 0.7rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  display: none;
  z-index: 1000;
}

/* Desktop hover + keyboard focus */
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  display: grid;
  gap: 0.35rem;
}

.nav-dropdown .dropdown-menu a {
  opacity: 0.9;
}

.nav-dropdown .dropdown-menu a::after { display: none; }

/* Mobile: keep dropdown in flow so it doesn't overflow */
@media (max-width: 700px) {
  .nav-dropdown { width: 100%; }

  .nav-dropdown .dropdown-menu {
    position: static;
    transform: none;
    left: auto;
    top: auto;
    min-width: unset;
    width: 100%;
    margin-top: 0.6rem;
  }
}


/* MAIN SECTIONS */
main {
  max-width: 1700px;
  margin: auto;
  padding: 2rem 1.5rem 5rem;
}

section {
  margin-top: 4rem;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

section.visible {
  opacity: 1;
  transform: translateY(0);
}

h2 {
  font-size: 1.8rem;
  letter-spacing: .04em;
  margin-bottom: .8rem;
}

.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 2.4rem;
}

.panel p.section-desc {
  color: var(--muted);
  margin-bottom: 1.5rem;
  font-size: 1rem;
}

/* GRIDS & BUTTONS */
.grid { display: grid; gap: 1.2rem; }

.alpha-grid, .num-grid, .game {
  grid-template-columns: repeat(auto-fit, minmax(120px,1fr));
}

button.cell {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.2rem;
  cursor: pointer;
  color: var(--text);
  transition: 0.3s, transform 0.3s, box-shadow 0.3s;
  opacity: 0;
  transform: translateY(20px);
  position: relative; /* REQUIRED for speaker icon */
}

button.cell.show {
  opacity: 1;
  transform: translateY(0);
}

button.cell span {
  display: block;
  font-size: .85rem;
  color: var(--muted);
}

button.cell:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(61,220,255,0.35);
  transform: translateY(-4px);
}

/* 🔊 SPEAKER ICON (NEW) */
button.cell .speaker {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 0.9rem;
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

button.cell:hover .speaker {
  opacity: 0.9;
  transform: scale(1.15);
}

/* GAME CARDS */
.game button {
  width: 100%;
  aspect-ratio: 1/1;
  border: none;
  background: none;
  perspective: 800px;
  padding: 0;
  opacity: 0;
  transform: translateY(20px);
}

.game button.show {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s, transform 0.5s;
}

.game .card {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

.game .card .front,
.game .card .back {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-weight: 600;
  font-size: 1.2rem;
}

.game .card .back {
  transform: rotateY(180deg);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.game button.flipped .card { transform: rotateY(180deg); }
.game button.matched .card { transform: rotateY(180deg); animation: glowPulse 1s infinite alternate; }

@keyframes glowPulse {
  0% { box-shadow: 0 0 15px var(--accent); }
  100% { box-shadow: 0 0 30px var(--accent); }
}

/* GAME CONTROLS */
#difficultySelect, #newRoundBtn {
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .9rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

#difficultySelect:hover, #newRoundBtn:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(61,220,255,0.25);
  background: linear-gradient(180deg, rgba(61,220,255,0.05), rgba(61,220,255,0.02));
}

#newRoundBtn {
  background: linear-gradient(135deg, var(--accent), #2bb8d6);
  color: #000;
  margin-left: 1rem;
  flex-shrink: 0;
}

#newRoundBtn:hover {
  background: linear-gradient(135deg, var(--accent-soft), #3ddcff);
  color: #000;
}

/* CONVERTER */
.converter input {
  width: 100%;
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 1.1rem;
  color: var(--text);
}

.converter input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--glow);
}

.converter button {
  margin-top: 1rem;
  background: linear-gradient(135deg, var(--accent), #2bb8d6);
  border: none;
  padding: .9rem 2rem;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
}

.converter-help {
  max-width: 680px;
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 1rem;
}

#spellResult {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: start;
  margin-top: 1rem;
}

.word-block {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-border);
}

.spell-card {
  display: inline-block;
  text-align: center;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0;
}

.spell-card.show { opacity: 1; transform: translateY(0); }

.spell-card .letter {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  font-weight: 600;
}

.spell-card .phonetic {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  margin-top: 3px;
}

.spell-card .letter.dash {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.2rem;
  margin: 0 6px;
}

/* TOGGLE BUTTONS */
.toggle {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.toggle button {
  padding: .6rem 1.4rem;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  background: var(--panel);
  color: var(--text);
  transition: .3s;
}

.toggle button.active {
  background: var(--accent);
  color: #000;
}

.toggle button:hover {
  background: var(--accent-soft);
  color: var(--text);
}

#scoreDisplay {
  margin-top: 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

/* FAQ */
.faq-item { margin-bottom: 1rem; cursor: pointer; }

.faq-item h3 {
  margin: 0;
  padding: .7rem;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  transition: background 0.3s;
}

.faq-item h3:hover {
  background: rgba(61,220,255,0.15);
}

.faq-item p {
  margin: 0;
  padding: .7rem;
  display: none;
  border-left: 3px solid var(--accent);
}

/* FOOTER */
footer {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 2.5rem;
  text-align: center;
  color: var(--muted);
}

/* MOBILE MENU */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 45px;
  margin-left: auto;
  margin-right: auto;
}

.menu-toggle span {
  display: block;
  width: 28px;
  height: 2px;
  background: var(--text);
  margin: 6px auto;
}

@media (max-width: 768px) {
  nav {
    position: fixed;
    inset: 0;
    background: rgba(11,15,20,0.95);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    display: none;
    z-index: 1000;
  }

  nav.open { display: flex; }

  nav a {
    font-size: 1.5rem;
    margin: 1rem 0;
  }

  .menu-toggle {
    display: block;
    z-index: 1100;
  }

  #siteLogo { height: 50px; }

  header h1 {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* BACK TO TOP */
#backToTop {
  position: fixed;
  bottom: 40px;
  right: 40px;
  width: 50px;
  height: 50px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 1000;
}

#backToTop.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#backToTop:hover {
  background: var(--accent-soft);
}

#downloadPDF {
  margin-top: 1.5rem;
  padding: 1rem 2rem;
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #2bb8d6);
  color: #000;
  box-shadow: var(--glow);
  transition: all 0.3s ease;
}

#downloadPDF:hover {
  background: linear-gradient(135deg, var(--accent-soft), #3ddcff);
  box-shadow: 0 8px 25px rgba(61,220,255,0.35);
  transform: translateY(-2px);
}

#downloadPDF:active {
  transform: translateY(0);
  box-shadow: var(--glow);
}

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #111;
  color: #fff;
  padding: 15px 20px;
  display: none;
  z-index: 9999;
  font-size: 14px;
}

.cookie-banner.is-visible { display: block; }

.cookie-banner p {
  margin: 0 0 10px 0;
}

.cookie-banner a {
  color: #4da3ff;
  text-decoration: underline;
}

.cookie-buttons {
  display: flex;
  gap: 10px;
}

.cookie-buttons button {
  padding: 8px 14px;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

#cookie-accept {
  background: #4da3ff;
  color: #000;
}

#cookie-reject {
  background: #444;
  color: #fff;
}


/* META */
.updated{
  margin: -0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}


/* =================================================
   COOKIE PREFERENCES MODAL
   ================================================= */
.cookie-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  background: rgba(0,0,0,0.55);
  z-index: 10000;
}

.cookie-modal.is-visible { display: flex; }

.cookie-modal-content {
  width: min(560px, 100%);
  background: #111;
  color: #fff;
  border-radius: 14px;
  padding: 18px 18px 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
}

.cookie-modal-content h2 { margin: 0 0 6px 0; }
.cookie-modal-content p { margin: 0 0 14px 0; opacity: 0.9; }

.cookie-pref-row{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.10);
}
.cookie-pref-row:first-of-type{ border-top: 0; }

.cookie-pref-label{ font-weight: 600; }

.cookie-modal-actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.10);
  margin-top: 6px;
}

.cookie-modal-actions button{
  padding: 8px 14px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  border-radius: 10px;
}

#saveCookiePrefs{ background: #4da3ff; color: #000; }
#closeCookiePrefs{ background: #444; color: #fff; }

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #444;
  transition: .2s;
  border-radius: 999px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
.switch input:checked + .slider { background-color: #4da3ff; }
.switch input:checked + .slider:before { transform: translateX(20px); }

@media (min-width: 768px){
  .cookie-modal{ align-items: center; }
}
