/* ============================================================
   FRUIT SLICE MASTER - Premium Styles
   ============================================================ */

:root {
  --bg-1: #1a0b2e;
  --bg-2: #2d1b4e;
  --bg-3: #3d2562;

  --pink: #ff4d8d;
  --orange: #ff8c42;
  --yellow: #ffd23f;
  --green: #4ade80;
  --cyan: #22d3ee;
  --purple: #a855f7;
  --red: #ef4444;

  --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(255, 77, 141, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(168, 85, 247, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at bottom left, rgba(34, 211, 238, 0.2) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
}

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

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  position: absolute;
  inset: calc(var(--safe-top) + 12px) 16px 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); }
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
.floatingEmojis {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floatingEmojis span {
  position: absolute;
  font-size: 38px;
  left: var(--x);
  bottom: -50px;
  opacity: 0;
  animation: floatUp 6s linear infinite;
  animation-delay: var(--delay);
}

@keyframes floatUp {
  0% { transform: translateY(0) rotate(0); opacity: 0; }
  10% { opacity: 0.8; }
  90% { opacity: 0.8; }
  100% { transform: translateY(-110vh) rotate(360deg); opacity: 0; }
}

.homeContent {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  height: 100%;
  overflow-y: auto;
  padding-bottom: 20px;
}

.homeContent::-webkit-scrollbar { display: none; }

.trophyBig {
  font-size: 72px;
  margin-top: 8px;
  filter: drop-shadow(0 10px 30px rgba(255, 210, 63, 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(--yellow) 50%, var(--orange) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 20px rgba(255, 140, 66, 0.6));
  letter-spacing: 1px;
}

.bigTitle span {
  background: linear-gradient(180deg, var(--pink) 0%, var(--purple) 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;
  letter-spacing: 0.3px;
}

/* Prize card */
.prizeCard {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(255, 210, 63, 0.18), rgba(255, 77, 141, 0.18));
  border: 2px solid rgba(255, 210, 63, 0.5);
  border-radius: 18px;
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  box-shadow: 0 8px 30px rgba(255, 140, 66, 0.25);
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

.prizeCard::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent 40%, rgba(255, 255, 255, 0.2) 50%, transparent 60%);
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% { transform: translate(-30%, -30%); }
  50% { transform: translate(30%, 30%); }
}

.prizeIcon {
  font-size: 38px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 12px rgba(255, 210, 63, 0.6));
}

.prizeText {
  flex: 1;
  position: relative;
  z-index: 1;
}

.prizeText strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--yellow);
  margin-bottom: 3px;
}

.prizeText span {
  font-size: 12px;
  color: var(--text-2);
  font-weight: 500;
}

.prizeArrow {
  font-size: 28px;
  color: var(--yellow);
  font-weight: 700;
}

/* Stats row */
.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;
  text-align: center;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.statIcon {
  font-size: 26px;
  margin-bottom: 4px;
}

.statVal {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--yellow);
  line-height: 1;
  margin-bottom: 4px;
}

.statLbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
}

/* Progress */
.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(--green), var(--yellow), var(--orange));
  border-radius: 100px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 14px rgba(255, 210, 63, 0.6);
}

.progressLabel {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-top: 8px;
  text-align: center;
}

/* ============================================================
   BIG BUTTONS
   ============================================================ */
.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;
}

.bigBtn:active {
  transform: scale(0.96);
}

.primaryBtn {
  background: linear-gradient(180deg, var(--green) 0%, #22c55e 100%);
  color: white;
  box-shadow:
    0 6px 0 #16a34a,
    0 14px 30px rgba(34, 197, 94, 0.4);
}

.primaryBtn:active {
  box-shadow:
    0 2px 0 #16a34a,
    0 8px 20px rgba(34, 197, 94, 0.4);
  transform: translateY(4px);
}

.resetBtn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
  border: 1.5px solid var(--card-border);
  font-size: 14px;
  padding: 12px 24px;
}

.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%; }
}

/* ============================================================
   FOOTER LINKS
   ============================================================ */
.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 a:hover { color: var(--text-1); }

.footerLinks span { margin: 0 6px; opacity: 0.5; }

.footerLinks.small { font-size: 10px; padding-top: 8px; }

/* ============================================================
   LEVEL SELECT SCREEN
   ============================================================ */
.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;
  color: var(--text-1);
  letter-spacing: 1px;
}

.backBtn {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 100px;
  padding: 8px 14px;
  color: var(--text-1);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.backBtn:active { transform: scale(0.95); }

.coinChip {
  background: linear-gradient(135deg, rgba(255, 210, 63, 0.2), rgba(255, 140, 66, 0.2));
  border: 1.5px solid rgba(255, 210, 63, 0.5);
  border-radius: 100px;
  padding: 8px 14px;
  font-family: var(--font-body);
  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-family: var(--font-body);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-1);
  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;
  transition: transform 0.15s ease;
}

.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(74, 222, 128, 0.25), rgba(34, 211, 238, 0.25));
  border-color: var(--green);
}

.levelTile .stars {
  font-size: 9px;
  color: var(--yellow);
  letter-spacing: 0px;
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
.gameTopBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.lvlChip {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(255, 77, 141, 0.25));
  border: 1.5px solid rgba(168, 85, 247, 0.5);
  border-radius: 100px;
  padding: 8px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  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;
}

.gameArea {
  flex: 1;
  position: relative;
  border-radius: 24px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at top, rgba(34, 211, 238, 0.15), transparent 60%),
    linear-gradient(180deg, #0f172a 0%, #1e1b4b 100%);
  border: 2px solid var(--card-border);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.gameHud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
}

.targetCard {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  padding: 8px 14px;
}

.targetLbl {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-3);
}

.targetVal {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-1);
  letter-spacing: 0.5px;
}

.streakCard {
  background: linear-gradient(135deg, var(--orange), var(--red));
  border-radius: 14px;
  padding: 8px 14px;
  font-family: var(--font-display);
  font-size: 14px;
  color: white;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.5);
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

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

.quitBtn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid var(--card-border);
  border-radius: 100px;
  padding: 8px 14px;
  color: var(--text-1);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  z-index: 2;
}

/* ============================================================
   POPUPS
   ============================================================ */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: popupBg 0.25s ease;
}

.popup.show {
  display: flex;
}

@keyframes popupBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

.popupCard {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(180deg, var(--bg-2) 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);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  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;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, #fff, var(--yellow));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.popupCard h3 {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 8px;
}

.popupCard p {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 18px;
  line-height: 1.4;
}

.confetti {
  font-size: 64px;
  margin-bottom: 8px;
  animation: spin 2s ease infinite;
}

.bigEmoji {
  font-size: 70px;
  margin-bottom: 8px;
  filter: drop-shadow(0 8px 20px rgba(255, 210, 63, 0.4));
}

@keyframes spin {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.15) rotate(15deg); }
}

.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(--yellow);
  margin-bottom: 2px;
}

.rewardLbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
}

.bonusBox {
  background: linear-gradient(135deg, rgba(255, 210, 63, 0.2), rgba(255, 140, 66, 0.2));
  border: 1.5px solid rgba(255, 210, 63, 0.5);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 18px;
}

.bonusVal {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--yellow);
}

.bonusLbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-2);
  text-transform: uppercase;
}

.prizeBadge {
  display: inline-block;
  background: linear-gradient(135deg, var(--yellow), var(--orange));
  color: var(--bg-1);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 1.5px;
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 12px;
}

.prizeBadge.gold {
  background: linear-gradient(135deg, var(--yellow), var(--pink));
  animation: badgePulse 1.8s infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.prizeStatus {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 18px;
}

.prizeStatus strong { color: var(--yellow); }

.closeBtn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  color: var(--text-1);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popupCard.modal {
  text-align: left;
  max-height: 80vh;
}

.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;
  padding-right: 4px;
}

.modalBody h4 {
  color: var(--text-1);
  margin: 12px 0 6px;
  font-size: 14px;
}

/* ============================================================
   AD POPUP
   ============================================================ */
.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;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.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(--yellow);
}

#adSkip:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  background: linear-gradient(135deg, var(--green), #22c55e);
  color: white;
  font-family: var(--font-display);
  font-size: 20px;
  padding: 12px 28px;
  border-radius: 100px;
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast.bad {
  background: linear-gradient(135deg, var(--red), #dc2626);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-height: 700px) {
  .trophyBig { font-size: 56px; margin-top: 0; }
  .bigTitle { font-size: 34px; }
  .subTitle { margin-bottom: 12px; }
  .prizeCard { padding: 10px 14px; margin-bottom: 12px; }
  .prizeIcon { font-size: 32px; }
  .statsRow { margin-bottom: 12px; }
  .progressWrap { margin-bottom: 12px; }
}

@media (max-height: 600px) {
  .trophyBig { display: none; }
  .bigTitle { font-size: 28px; }
}
