/* TAP THE RIGHT COLOR - Premium Styles */
:root {
  --bg-1: #0a0820;
  --bg-2: #1a1206;
  --pink: #ec4899; --orange: #f97316; --yellow: #facc15; --green: #4ade80;
  --cyan: #22d3ee; --purple: #a855f7; --red: #ef4444; --blue: #3b82f6;
  --text-1: #ffffff; --text-2: #e9d5ff; --text-3: #a78bfa;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.18);
  --font-display: 'Bungee', 'Arial Black', sans-serif;
  --font-body: 'Fredoka', 'Segoe UI', sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: var(--font-body); background: var(--bg-1); color: var(--text-1);
  touch-action: none; overscroll-behavior: none;
  -webkit-font-smoothing: antialiased; position: fixed; inset: 0;
}

body {
  background:
    radial-gradient(ellipse at top, rgba(168, 85, 247, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(34, 211, 238, 0.25) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1), #1a0a2e);
}

#app { width: 100%; height: 100%; max-width: 540px; margin: 0 auto; padding: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 12px); position: relative; }

.screen { position: absolute; inset: calc(var(--safe-top) + 12px) 14px calc(var(--safe-bottom) + 12px); display: none; flex-direction: column; animation: fadeIn 0.35s ease; }
.screen.active { display: flex; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }

.backToHub { position: absolute; top: 0; left: 0; background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 100px; padding: 8px 14px; color: var(--text-1); text-decoration: none; font-size: 12px; font-weight: 700; z-index: 5; }

.floatingWords { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.floatingWords span { position: absolute; font-family: var(--font-display); font-size: 28px; color: var(--c); left: var(--x); bottom: -50px; opacity: 0; animation: wordFloat 8s linear infinite; animation-delay: var(--delay); filter: drop-shadow(0 4px 12px currentColor); }
@keyframes wordFloat { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: 0.5; } 90% { opacity: 0.5; } 100% { transform: translateY(-110vh); opacity: 0; } }

.homeContent { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; text-align: center; height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-top: 40px; padding-bottom: 20px; scrollbar-width: none; }
.homeContent::-webkit-scrollbar { display: none; }
.homeContent > * { flex-shrink: 0; width: 100%; }
.homeContent .trophyBig, .homeContent .bigTitle, .homeContent .subTitle { width: auto; }

.trophyBig { font-size: 70px; filter: drop-shadow(0 10px 30px rgba(168, 85, 247, 0.5)); animation: bounce 2.4s ease-in-out infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.bigTitle { font-family: var(--font-display); font-size: clamp(36px, 9vw, 52px); line-height: 1; margin: 8px 0 4px; background: linear-gradient(180deg, #fff 0%, var(--purple) 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 4px 20px rgba(168, 85, 247, 0.6)); letter-spacing: 1px; }
.bigTitle span { background: linear-gradient(180deg, var(--cyan) 0%, var(--pink) 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.subTitle { font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 20px; max-width: 320px; }

.warningCard { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; background: linear-gradient(135deg, rgba(250, 204, 21, 0.18), rgba(249, 115, 22, 0.18)); border: 2px solid rgba(250, 204, 21, 0.5); border-radius: 18px; box-shadow: 0 8px 30px rgba(250, 204, 21, 0.2); margin-bottom: 18px; text-align: left; }
.warnIcon { font-size: 34px; flex-shrink: 0; }
.warnText strong { display: block; font-size: 15px; color: var(--yellow); margin-bottom: 2px; }
.warnText span { font-size: 12px; color: var(--text-2); }
.warnText em { color: var(--yellow); font-style: normal; font-weight: 700; }

.statsRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-bottom: 16px; }
.statBox { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 16px; padding: 12px 8px; backdrop-filter: blur(10px); }
.statIcon { font-size: 26px; margin-bottom: 4px; }
.statVal { font-family: var(--font-display); font-size: 18px; color: var(--purple); line-height: 1; margin-bottom: 4px; }
.statLbl { font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }

.progressWrap { width: 100%; margin-bottom: 18px; }
.progressBar { height: 12px; background: rgba(0, 0, 0, 0.3); border-radius: 100px; overflow: hidden; border: 1.5px solid var(--card-border); }
.progressFill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--cyan), var(--purple), var(--pink)); border-radius: 100px; transition: width 0.6s; box-shadow: 0 0 14px rgba(168, 85, 247, 0.6); }
.progressLabel { font-size: 12px; font-weight: 600; color: var(--text-2); margin-top: 8px; text-align: center; }

.bigBtn { position: relative; width: 100%; border: none; border-radius: 100px; padding: 16px 24px; font-family: var(--font-body); font-size: 17px; font-weight: 700; letter-spacing: 0.5px; cursor: pointer; margin-bottom: 10px; overflow: hidden; transition: transform 0.1s ease; }
.primaryBtn { background: linear-gradient(180deg, var(--purple), #6b21a8); color: white; box-shadow: 0 6px 0 #4c1d95, 0 14px 30px rgba(168, 85, 247, 0.4); }
.primaryBtn:active { box-shadow: 0 2px 0 #4c1d95, 0 8px 20px rgba(168, 85, 247, 0.4); transform: translateY(4px); }
.ghostBtn { background: rgba(255, 255, 255, 0.08); color: var(--text-1); border: 1.5px solid var(--card-border); font-size: 15px; }
.btnShine { position: absolute; top: 0; left: -100%; width: 50%; height: 100%; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent); animation: btnShine 2.5s ease-in-out infinite; }
@keyframes btnShine { 0%, 100% { left: -100%; } 50% { left: 100%; } }

.footerLinks { margin-top: auto; padding-top: 14px; text-align: center; font-size: 11px; color: var(--text-3); }
.footerLinks a { color: var(--text-3); text-decoration: none; font-weight: 600; }
.footerLinks span { margin: 0 6px; opacity: 0.5; }

/* LEVEL SELECT */
.topBar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-shrink: 0; }
.topBar h2 { flex: 1; text-align: center; font-family: var(--font-display); font-size: 22px; }
.backBtn { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 100px; padding: 8px 14px; color: var(--text-1); font-weight: 600; font-size: 13px; cursor: pointer; font-family: var(--font-body); }
.bestChip { background: linear-gradient(135deg, rgba(250, 204, 21, 0.2), rgba(249, 115, 22, 0.2)); border: 1.5px solid rgba(250, 204, 21, 0.5); border-radius: 100px; padding: 8px 14px; font-weight: 700; font-size: 14px; color: var(--yellow); }
.levelGroups { flex: 1; overflow-y: auto; padding-bottom: 12px; }
.levelGroups::-webkit-scrollbar { width: 0; }
.levelGroup { margin-bottom: 18px; }
.groupHead { font-weight: 700; font-size: 14px; margin-bottom: 10px; padding-left: 4px; }
.groupHead span { color: var(--text-3); font-size: 11px; margin-left: 4px; }
.levelGrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.levelTile { aspect-ratio: 1; background: var(--card-bg); border: 2px solid var(--card-border); border-radius: 16px; font-family: var(--font-display); font-size: 18px; color: var(--text-1); cursor: pointer; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.levelTile:active { transform: scale(0.93); }
.levelTile.locked { opacity: 0.4; cursor: not-allowed; background: rgba(0, 0, 0, 0.3); }
.levelTile.locked::after { content: "🔒"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 22px; background: rgba(0, 0, 0, 0.4); border-radius: 14px; }
.levelTile.completed { background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(34, 211, 238, 0.25)); border-color: var(--purple); }
.levelTile .stars { font-size: 9px; color: var(--yellow); }

/* GAME SCREEN */
.gameTopBar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-shrink: 0; }
.iconBtn { width: 38px; height: 38px; border-radius: 50%; background: var(--card-bg); border: 1.5px solid var(--card-border); color: var(--text-1); font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.iconBtn:active { transform: scale(0.92); }
.lvlChip { background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(236, 72, 153, 0.25)); border: 1.5px solid rgba(168, 85, 247, 0.5); border-radius: 100px; padding: 8px 12px; font-family: var(--font-display); font-size: 14px; flex-shrink: 0; }
.scoreCard { flex: 1; background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 14px; padding: 6px 12px; text-align: center; }
.scoreLbl { font-size: 9px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-3); }
.scoreVal { font-family: var(--font-display); font-size: 16px; color: var(--text-1); }
.livesChip { background: rgba(239, 68, 68, 0.15); border: 1.5px solid rgba(239, 68, 68, 0.4); border-radius: 100px; padding: 8px 12px; font-size: 14px; letter-spacing: -2px; flex-shrink: 0; }

.topInfo { display: flex; gap: 8px; margin-bottom: 10px; justify-content: center; flex-wrap: wrap; flex-shrink: 0; }
.infoChip { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 100px; padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.infoChip strong { color: var(--purple); font-family: var(--font-display); font-size: 13px; margin: 0 4px; }
.infoChip.streak { background: linear-gradient(135deg, rgba(249, 115, 22, 0.3), rgba(239, 68, 68, 0.3)); border-color: var(--orange); animation: streakPulse 1s ease-in-out infinite; }
.infoChip.streak strong { color: var(--yellow); }
@keyframes streakPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.4); } 50% { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0); } }

.gameArea { flex: 1; position: relative; border-radius: 24px; overflow: hidden; background: linear-gradient(180deg, #1a1535 0%, #0a0820 100%); border: 2px solid var(--card-border); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; }

.targetWord {
  font-family: var(--font-display);
  font-size: clamp(48px, 14vw, 80px);
  letter-spacing: 3px;
  text-align: center;
  filter: drop-shadow(0 0 20px currentColor);
  animation: wordAppear 0.3s ease-out;
}

@keyframes wordAppear {
  0% { opacity: 0; transform: scale(0.5); }
  100% { opacity: 1; transform: scale(1); }
}

.targetWord.correct { animation: wordCorrect 0.4s ease-out; }
.targetWord.wrong { animation: wordWrong 0.4s ease-out; }

@keyframes wordCorrect {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); filter: drop-shadow(0 0 40px #4ade80); }
  100% { transform: scale(1); }
}

@keyframes wordWrong {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-15px); }
  40% { transform: translateX(15px); }
  60% { transform: translateX(-10px); }
  80% { transform: translateX(10px); }
}

.timerBar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: rgba(0, 0, 0, 0.4);
}

.timerFill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow), var(--red));
  transition: width 0.1s linear;
  box-shadow: 0 0 10px currentColor;
}

.comboPopup { position: absolute; top: 15%; left: 50%; transform: translate(-50%, -50%) scale(0.5); font-family: var(--font-display); font-size: 28px; color: var(--yellow); text-shadow: 0 0 20px rgba(250, 204, 21, 0.9), 0 4px 12px rgba(0,0,0,0.5); opacity: 0; pointer-events: none; z-index: 3; transition: all 0.5s cubic-bezier(0.22, 1.4, 0.36, 1); }
.comboPopup.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.answerGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  flex-shrink: 0;
  height: 180px;
}

.answerBtn {
  border: none;
  border-radius: 18px;
  cursor: pointer;
  font-family: var(--font-display);
  color: white;
  font-size: 0;
  position: relative;
  overflow: hidden;
  transition: transform 0.1s ease;
  box-shadow: inset -4px -4px 8px rgba(0,0,0,0.3), inset 4px 4px 8px rgba(255,255,255,0.2), 0 6px 18px rgba(0,0,0,0.4);
}

.answerBtn:active { transform: scale(0.94); }

.answerBtn.flashCorrect {
  animation: btnCorrect 0.4s ease-out;
}

.answerBtn.flashWrong {
  animation: btnWrong 0.4s ease-out;
}

@keyframes btnCorrect {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); box-shadow: 0 0 40px white, inset -4px -4px 8px rgba(0,0,0,0.3); }
}

@keyframes btnWrong {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.9); opacity: 0.6; }
}

/* POPUPS */
.popup { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(8px); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.popup.show { display: flex; }
.popupCard { width: 100%; max-width: 360px; background: linear-gradient(180deg, #1a0a2e 0%, var(--bg-1) 100%); border: 2px solid var(--card-border); border-radius: 28px; padding: 28px 24px; text-align: center; position: relative; animation: popupIn 0.45s cubic-bezier(0.22, 1.4, 0.36, 1); max-height: 90vh; overflow-y: auto; }
@keyframes popupIn { 0% { opacity: 0; transform: scale(0.7) translateY(20px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
.popupCard h2 { font-family: var(--font-display); font-size: 26px; margin-bottom: 12px; background: linear-gradient(180deg, #fff, var(--purple)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.popupCard p { font-size: 14px; color: var(--text-2); margin-bottom: 18px; line-height: 1.4; }
.confetti { font-size: 64px; margin-bottom: 8px; animation: spin 2s ease infinite; }
@keyframes spin { 0%, 100% { transform: scale(1) rotate(0); } 50% { transform: scale(1.15) rotate(15deg); } }
.bigEmoji { font-size: 70px; margin-bottom: 8px; filter: drop-shadow(0 8px 20px rgba(168, 85, 247, 0.4)); }
.starsRow { font-size: 38px; margin-bottom: 16px; letter-spacing: 4px; filter: drop-shadow(0 4px 12px rgba(250, 204, 21, 0.5)); }
.rewardRow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.rewardBox { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 18px; padding: 14px 8px; }
.rewardIcon { font-size: 32px; margin-bottom: 4px; }
.rewardVal { font-family: var(--font-display); font-size: 20px; color: var(--purple); }
.rewardLbl { font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }
.popupCard.modal { text-align: left; }
.popupCard.modal h2 { text-align: center; }
.modalBody { font-size: 13px; line-height: 1.6; color: var(--text-2); margin-bottom: 18px; max-height: 50vh; overflow-y: auto; }
.modalBody h4 { color: var(--text-1); margin: 12px 0 6px; font-size: 14px; }
.adCard { width: 100%; max-width: 360px; background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%); border: 2px solid var(--card-border); border-radius: 24px; padding: 22px; text-align: center; }
.adLabel { font-size: 10px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-3); margin-bottom: 14px; }
.adContent { background: #000; border-radius: 14px; padding: 40px 20px; margin-bottom: 14px; }
.adEmoji { font-size: 50px; margin-bottom: 10px; }
.adText { font-size: 14px; color: var(--text-2); margin-bottom: 8px; }
.adTimer { font-family: var(--font-display); font-size: 22px; color: var(--purple); }
#adSkip:disabled { opacity: 0.6; cursor: not-allowed; }

.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.5); background: linear-gradient(135deg, var(--purple), #6b21a8); color: white; font-family: var(--font-display); font-size: 18px; padding: 12px 28px; border-radius: 100px; box-shadow: 0 10px 30px rgba(168, 85, 247, 0.4); z-index: 200; opacity: 0; pointer-events: none; transition: all 0.3s; }
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.toast.bad { background: linear-gradient(135deg, var(--red), #991b1b); }

@media (max-height: 750px) {
  .homeContent { padding-top: 30px; }
  .trophyBig { font-size: 56px; }
  .bigTitle { font-size: 34px; }
  .subTitle { margin-bottom: 12px; font-size: 13px; }
  .warningCard { padding: 10px 14px; margin-bottom: 12px; }
  .warnIcon { font-size: 28px; }
  .statsRow { margin-bottom: 12px; }
  .progressWrap { margin-bottom: 12px; }
  .answerGrid { height: 150px; }
}
