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

:root {
  --bg:            #0f0c00;
  --surface:       rgba(255,220,0,0.06);
  --surface-hover: rgba(255,220,0,0.11);
  --border:        rgba(255,220,0,0.15);
  --accent:        #f59e0b;    /* amber */
  --accent-bright: #fbbf24;   /* yellow */
  --accent-dark:   #d97706;
  --accent-glow:   #fde68a;
  --correct:       #22c55e;
  --incorrect:     #f87171;
  --text:          #fef3c7;
  --text-muted:    #92764a;
  --text-dim:      #c9a96a;
  --font-ui:       'Nunito', sans-serif;
  --font-word:     'Lexend', sans-serif;
  --radius:        18px;
  --radius-sm:     12px;
  --transition:    0.22s ease;
}

html, body {
  height: 100%; overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-touch-callout: none; /* suppress iOS long-press image/link menus */
  -webkit-user-select: none;
  user-select: none;
}
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}

/* ===== AMBIENT ORBS ===== */
.bg-orbs { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.orb { position: absolute; border-radius: 50%; filter: blur(110px); opacity: 0.2; animation: orbFloat 9s ease-in-out infinite; }
.orb-1 { width: 650px; height: 650px; background: radial-gradient(circle, #f59e0b, transparent); top: -220px; left: -120px; }
.orb-2 { width: 550px; height: 550px; background: radial-gradient(circle, #d97706, transparent); bottom: -180px; right: -120px; animation-delay: -4s; }
.orb-3 { width: 420px; height: 420px; background: radial-gradient(circle, #fbbf24, transparent); top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -7s; opacity: 0.08; }
@keyframes orbFloat { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-28px) scale(1.04); } }

/* ===== SCREENS ===== */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  z-index: 1; opacity: 0; pointer-events: none;
  transform: translateY(22px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.screen.active { opacity: 1; pointer-events: all; transform: translateY(0); }

/* ===== FULLSCREEN BUTTON ===== */
.fullscreen-btn {
  position: absolute; top: 18px; right: 18px;
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 50px;
  padding: 9px 15px; color: var(--text-muted);
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
  transition: all var(--transition); font-family: var(--font-ui); z-index: 10;
}
.fullscreen-btn:hover { color: var(--text); border-color: rgba(251,191,36,0.6); background: var(--surface-hover); }

/* ===== MENU SCREEN ===== */
.menu-container {
  width: 100%; max-width: 860px;
  padding: 20px 28px;
  display: flex; flex-direction: column; gap: 22px;
}
.logo-area { text-align: center; }
.logo-icon {
  font-size: 5.5rem; display: block; margin-bottom: 8px;
  animation: iconPulse 2.5s ease-in-out infinite;
  filter: drop-shadow(0 0 28px rgba(251,191,36,0.6));
}
@keyframes iconPulse {
  0%,100% { transform: scale(1) rotate(0deg); }
  50%      { transform: scale(1.1) rotate(-5deg); }
}
.logo-text {
  font-family: var(--font-word);
  font-size: 3.6rem; font-weight: 800;
  background: linear-gradient(135deg, #fbbf24, #f59e0b, #fde68a);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  letter-spacing: -1.5px;
}
.logo-sub { color: var(--text-muted); font-size: 1.05rem; margin-top: 6px; font-weight: 700; }

.section-block { display: flex; flex-direction: column; gap: 10px; }
.section-label {
  font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text-muted);
}

/* Set grid */
.set-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.set-btn {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 18px 10px;
  cursor: pointer; display: flex; flex-direction: column; align-items: center;
  gap: 6px; transition: all var(--transition); color: var(--text-dim);
  font-family: var(--font-ui);
}
.set-btn:hover { background: var(--surface-hover); border-color: rgba(251,191,36,0.5); transform: translateY(-3px); }
.set-btn.active {
  background: rgba(245,158,11,0.18); border-color: var(--accent);
  color: var(--text); box-shadow: 0 0 24px rgba(245,158,11,0.28);
}
.set-icon { font-size: 1.9rem; }
.set-name { font-size: 0.88rem; font-weight: 800; text-align: center; line-height: 1.2; }
.set-desc { font-size: 0.68rem; color: var(--text-muted); text-align: center; }

/* Start button */
.start-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 20px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  border: none; border-radius: var(--radius);
  color: #0f0c00; font-size: 1.25rem; font-weight: 900;
  cursor: pointer; transition: all var(--transition);
  box-shadow: 0 8px 32px rgba(245,158,11,0.45);
  font-family: var(--font-ui);
}
.start-btn:hover { transform: translateY(-3px); box-shadow: 0 14px 42px rgba(245,158,11,0.6); }
.start-btn:active { transform: translateY(-1px); }

/* ===== GAME TOPBAR — full-width strip ===== */
.game-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(15,12,0,0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar-left  { display: flex; gap: 8px; }
.topbar-right { display: flex; justify-content: flex-end; }
.topbar-btn {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 50px;
  padding: 9px 16px; color: var(--text-muted); font-size: 0.82rem; font-weight: 800;
  cursor: pointer; transition: all var(--transition); font-family: var(--font-ui);
}
.topbar-btn:hover { color: var(--text); border-color: rgba(251,191,36,0.5); background: var(--surface-hover); }
.topbar-fs-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 50px;
  padding: 9px 15px; color: var(--text-muted);
  font-size: 0.78rem; font-weight: 700; cursor: pointer;
  transition: all var(--transition); font-family: var(--font-ui);
}
.topbar-fs-btn:hover { color: var(--text); border-color: rgba(251,191,36,0.6); background: var(--surface-hover); }

/* Score pill — centred in topbar */
.score-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(245,158,11,0.14); border: 1.5px solid rgba(251,191,36,0.4);
  border-radius: 50px; padding: 8px 20px;
  font-size: 1.05rem; font-weight: 800; color: var(--text);
  box-shadow: 0 0 16px rgba(245,158,11,0.15);
}
.score-label  { font-size: 1.2rem; }
.score-divider{ color: rgba(251,191,36,0.3); }

/* ===== GAME LAYOUT — vertical centred column ===== */
.game-layout {
  width: 100%; max-width: 700px;
  display: flex; flex-direction: column; align-items: center;
  gap: 20px;
  padding: 80px 24px 24px;
  overflow-y: auto; max-height: 100vh;
}
.picture-card {
  width: 240px; height: 240px;
  background: none;
  border: none;
  border-radius: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  box-shadow: none;
  animation: none;
  overflow: visible; padding: 0;
  transition: width  0.45s cubic-bezier(0.34,1.56,0.64,1),
              height 0.45s cubic-bezier(0.34,1.56,0.64,1);
}
/* Expanded state when answer is correct */
.picture-card.correct-reveal {
  width: 310px; height: 310px;
  filter: drop-shadow(0 0 22px rgba(34,197,94,0.6));
}
.picture-card.correct-reveal .word-image {
  width: 260px; height: 260px;
}

.word-image {
  width: 220px; height: 220px;
  object-fit: contain; border-radius: 12px;
  transition: width  0.45s cubic-bezier(0.34,1.56,0.64,1),
              height 0.45s cubic-bezier(0.34,1.56,0.64,1);
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.word-revealed {
  font-family: var(--font-word);
  font-size: 0;
  font-weight: 800; color: transparent;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  transition: font-size 0.4s ease 0.25s; /* delay so image expands first */
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.word-revealed.show { font-size: 2rem; }

/* Phoneme drop boxes */

.phoneme-frames { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.phoneme-box {
  width: 130px; height: 130px;
  border: 3px dashed rgba(251,191,36,0.4);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-word);
  font-size: 4.2rem; font-weight: 800;
  color: var(--text);
  background: var(--surface);
  transition: all 0.2s ease;
  position: relative;
  cursor: pointer;
  user-select: none;
}
.phoneme-box.multi-char { font-size: 4.2rem; }
.phoneme-box.drag-over {
  border-color: var(--accent-bright);
  background: rgba(251,191,36,0.2);
  box-shadow: 0 0 28px rgba(251,191,36,0.5);
  transform: scale(1.07);
}
.phoneme-box.filled {
  border-style: solid;
  border-color: rgba(251,191,36,0.7);
  background: rgba(245,158,11,0.12);
}
.phoneme-box.correct {
  border-color: var(--correct);
  background: rgba(34,197,94,0.15);
  box-shadow: 0 0 26px rgba(34,197,94,0.4);
  animation: boxCorrect 0.45s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes boxCorrect { 0%{transform:scale(1)} 50%{transform:scale(1.14)} 100%{transform:scale(1)} }
.phoneme-box.incorrect {
  border-color: var(--incorrect);
  background: rgba(248,113,113,0.12);
  animation: boxShake 0.3s ease;
}
@keyframes boxShake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }

.box-index { display: none; }

/* Feedback banner */
.feedback-banner {
  padding: 12px 32px;
  background: rgba(34,197,94,0.15); border: 1.5px solid var(--correct);
  border-radius: 50px;
  font-size: 1.35rem; font-weight: 800; color: var(--correct);
  animation: bannerIn 0.4s cubic-bezier(0.34,1.56,0.64,1);
  text-align: center;
}
.feedback-banner.wrong {
  background: rgba(248,113,113,0.12); border-color: var(--incorrect);
  color: var(--incorrect);
}
.feedback-banner.hidden { display: none; }
@keyframes bannerIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ===== SOUND BANK ===== */
.sound-bank {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
  min-height: 82px;
}

.sound-tile {
  width: 110px; height: 110px;
  background: linear-gradient(135deg, rgba(245,158,11,0.22), rgba(251,191,36,0.10));
  border: 2.5px solid rgba(245,158,11,0.6);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-word);
  font-size: 3.8rem; font-weight: 800;
  color: var(--text);
  cursor: grab;
  user-select: none;
  transition: all 0.18s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  touch-action: none;
}
.sound-tile.multi-char { font-size: 3.8rem; }
.sound-tile:hover {
  transform: translateY(-5px) scale(1.08);
  box-shadow: 0 10px 28px rgba(245,158,11,0.4), 0 0 0 3px rgba(251,191,36,0.25);
  border-color: var(--accent-bright);
}
.sound-tile.dragging { opacity: 0.3; cursor: grabbing; transform: scale(0.94); }
.sound-tile.used { display: none; }

/* Touch drag ghost */
.drag-ghost {
  position: fixed; pointer-events: none;
  width: 82px; height: 82px;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-word);
  font-size: 2.3rem; font-weight: 800;
  color: #0f0c00;
  box-shadow: 0 14px 40px rgba(245,158,11,0.65);
  z-index: 9999;
  transform: translate(-50%, -50%) scale(1.18) rotate(-4deg);
  opacity: 0.94;
}
.drag-ghost.multi-char { font-size: 1.5rem; }

/* ===== ACTION ROW ===== */
.action-row { display: flex; gap: 12px; }
.action-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 32px; border-radius: 50px;
  font-size: 1rem; font-weight: 800; cursor: pointer;
  transition: all var(--transition); border: 1.5px solid transparent;
  font-family: var(--font-ui);
}
.action-btn.primary {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  color: #0f0c00; box-shadow: 0 6px 22px rgba(245,158,11,0.45);
}
.action-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(245,158,11,0.6); }
.action-btn.secondary {
  background: var(--surface); border-color: var(--border); color: var(--text-dim);
}
.action-btn.secondary:hover { background: var(--surface-hover); border-color: rgba(251,191,36,0.5); color: var(--text); transform: translateY(-2px); }

/* ===== CONFETTI ===== */
@keyframes confettiFall {
  0%   { transform: translateY(-20px) rotate(0deg);   opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0; }
}

/* ===== RESULTS SCREEN ===== */
.results-container {
  width: 100%; max-width: 560px;
  padding: 32px 28px;
  display: flex; flex-direction: column; gap: 28px; align-items: center;
}
.results-header { text-align: center; }
.star-rating { display: flex; justify-content: center; align-items: center; gap: 14px; margin-bottom: 18px; }
.star {
  font-size: 5rem; display: inline-block;
  color: rgba(255,255,255,0.08);
  transform: scale(0.3); transition: color 0.2s; line-height: 1;
  filter: drop-shadow(0 0 0px transparent);
}
.star.empty  { transform: scale(1); color: rgba(255,255,255,0.1); }
.star.filled { color: #fbbf24; filter: drop-shadow(0 0 18px rgba(251,191,36,0.75)); animation: starPop 0.5s cubic-bezier(0.34,1.56,0.64,1) forwards; }
@keyframes starPop { from { transform: scale(0) rotate(-25deg); } to { transform: scale(1) rotate(0); } }

.results-title {
  font-size: 2.4rem; font-weight: 900;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  font-family: var(--font-word);
}
.results-sub { color: var(--text-muted); margin-top: 6px; font-size: 1rem; }

.results-score-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface); border: 1.5px solid rgba(251,191,36,0.3);
  border-radius: 24px; padding: 28px 60px;
  box-shadow: 0 0 36px rgba(245,158,11,0.15);
}
.big-score {
  font-family: var(--font-word); font-size: 5rem; font-weight: 800; line-height: 1;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.big-score-label { font-size: 1rem; font-weight: 700; color: var(--text-muted); }

.results-actions { display: flex; gap: 12px; width: 100%; }
.results-actions .action-btn { flex: 1; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== RESPONSIVE — Tablet & iPad ===== */

/* iPad / tablet portrait (768px–1024px) */
@media (max-width: 1024px) and (min-width: 601px) {
  .game-layout { max-width: 620px; gap: 16px; padding: 74px 20px 20px; }
  .picture-card { width: 160px; height: 160px; }
  .word-image { width: 130px; height: 130px; }
  .phoneme-box { width: 110px; height: 110px; font-size: 3.2rem; }
  .phoneme-box.multi-char { font-size: 3.2rem; }
  .sound-tile { width: 92px; height: 92px; font-size: 2.8rem; }
  .sound-tile.multi-char { font-size: 2.8rem; }
  .menu-container { max-width: 700px; }
}

/* iPad landscape / smaller tablets */
@media (max-height: 700px) and (min-width: 601px) {
  .game-layout { gap: 12px; padding: 70px 20px 12px; }
  .picture-card { width: 130px; height: 130px; }
  .word-image { width: 108px; height: 108px; }
  .phoneme-box { width: 96px; height: 96px; font-size: 2.8rem; }
  .phoneme-box.multi-char { font-size: 2.8rem; }
  .sound-tile { width: 86px; height: 86px; font-size: 2.4rem; }
  .sound-tile.multi-char { font-size: 2.4rem; }
  .action-btn { padding: 11px 24px; }
  .score-pill { padding: 6px 16px; font-size: 0.95rem; }
  .game-topbar { height: 56px; }
  .game-layout { padding-top: 64px; }
}

/* Phone (up to 600px) */
@media (max-width: 600px) {
  .game-layout { gap: 14px; padding: 70px 14px 14px; }
  .picture-card { width: 120px; height: 120px; }
  .word-image { width: 96px; height: 96px; }
  .set-grid { grid-template-columns: repeat(2,1fr); }
  .phoneme-box { width: 78px; height: 78px; font-size: 2.2rem; }
  .phoneme-box.multi-char { font-size: 2.2rem; }
  .sound-tile { width: 72px; height: 72px; font-size: 2rem; }
  .sound-tile.multi-char { font-size: 2rem; }
  .action-btn { padding: 12px 20px; font-size: 0.9rem; }
  .topbar-btn { padding: 7px 12px; font-size: 0.76rem; }
  .score-pill { padding: 6px 14px; font-size: 0.9rem; }
  .game-topbar { height: 54px; }
  .game-layout { padding-top: 62px; }
  .logo-text { font-size: 2.6rem; }
  .menu-container { padding: 16px; }
}
