/* ============================================================
   DRIFT RACER - Premium Styles
   ============================================================ */

:root {
  --bg-1: #0a0820;
  --bg-2: #1a0a2e;

  --pink: #ec4899;
  --orange: #f97316;
  --yellow: #facc15;
  --green: #4ade80;
  --cyan: #22d3ee;
  --purple: #a855f7;
  --red: #ef4444;
  --blue: #3b82f6;

  --text-1: #ffffff;
  --text-2: #fecaca;
  --text-3: #fca5a5;

  --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(239, 68, 68, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at bottom, rgba(168, 85, 247, 0.25) 0%, transparent 55%),
    linear-gradient(180deg, #1a0510, #0a0408);
}

#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); } }

/* HOME */
.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; }

.floatingCars { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.floatingCars span { position: absolute; font-size: 38px; left: var(--x); bottom: -50px; opacity: 0; animation: carDrive 8s linear infinite; animation-delay: var(--delay); filter: drop-shadow(0 4px 12px rgba(239, 68, 68, 0.5)); }
@keyframes carDrive { 0% { transform: translateY(0); opacity: 0; } 10% { opacity: 0.4; } 90% { opacity: 0.4; } 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(239, 68, 68, 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(40px, 11vw, 60px); line-height: 1; margin: 8px 0 4px; background: linear-gradient(180deg, #fff 0%, var(--red) 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 4px 20px rgba(239, 68, 68, 0.6)); letter-spacing: 1px; }
.bigTitle span { background: linear-gradient(180deg, var(--orange) 0%, var(--yellow) 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; max-width: 320px; }

.prizeCard { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; background: linear-gradient(135deg, rgba(239, 68, 68, 0.18), rgba(168, 85, 247, 0.18)); border: 2px solid rgba(239, 68, 68, 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(239, 68, 68, 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(239, 68, 68, 0.6)); position: relative; z-index: 1; }
.prizeText { flex: 1; position: relative; z-index: 1; }
.prizeText strong { display: block; font-size: 16px; font-weight: 700; color: var(--red); margin-bottom: 3px; }
.prizeText span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.prizeArrow { font-size: 28px; color: var(--red); font-weight: 700; }

.statsRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin-bottom: 20px; }
.statBox { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 16px; padding: 12px 8px; 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(--red); line-height: 1; margin-bottom: 4px; }
.statLbl { font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }

/* Car selector */
.carSelector { width: 100%; margin-bottom: 20px; }
.carLabel { font-size: 12px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-3); margin-bottom: 10px; }
.carGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.carBtn { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 14px; padding: 10px 4px; font-family: var(--font-body); color: var(--text-1); cursor: pointer; transition: all 0.2s ease; }
.carBtn.active { background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(249, 115, 22, 0.25)); border-color: var(--red); box-shadow: 0 0 16px rgba(239, 68, 68, 0.4); }
.carIcon { width: 28px; height: 40px; margin: 0 auto 4px; border-radius: 6px; box-shadow: inset -3px -3px 6px rgba(0,0,0,0.3), 0 4px 8px rgba(0,0,0,0.3); }
.carName { font-weight: 700; font-size: 11px; }

/* 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; }
.primaryBtn { background: linear-gradient(180deg, var(--red), #991b1b); color: white; box-shadow: 0 6px 0 #7f1d1d, 0 14px 30px rgba(239, 68, 68, 0.4); }
.primaryBtn:active { box-shadow: 0 2px 0 #7f1d1d, 0 8px 20px rgba(239, 68, 68, 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; }

/* GAME SCREEN */
.gameTopBar { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; 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); }
.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: 22px; color: var(--red); text-shadow: 0 0 12px rgba(239, 68, 68, 0.5); }

.topInfo { display: flex; gap: 8px; margin-bottom: 10px; flex-shrink: 0; justify-content: center; flex-wrap: wrap; }
.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(--red); font-family: var(--font-display); font-size: 13px; margin-left: 4px; }

.gameArea { flex: 1; position: relative; border-radius: 24px; overflow: hidden; background: linear-gradient(180deg, #1a1a2e 0%, #0a0a14 100%); border: 2px solid var(--card-border); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); min-height: 0; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.comboPopup { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%) scale(0.5); font-family: var(--font-display); font-size: 30px; 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); }

.aimHint { position: absolute; bottom: 22%; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.6); color: rgba(255, 255, 255, 0.85); padding: 8px 16px; border-radius: 100px; font-size: 13px; font-weight: 600; pointer-events: none; z-index: 2; animation: hintPulse 1.5s ease-in-out infinite; white-space: nowrap; }
.aimHint.hidden { display: none; }
@keyframes hintPulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 0.9; } }

/* POPUPS */
.popup { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(8px); -webkit-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, 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); 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(--red)); -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; }

.bigEmoji { font-size: 70px; margin-bottom: 8px; filter: drop-shadow(0 8px 20px rgba(239, 68, 68, 0.5)); }

.rewardRow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.rewardBox { background: var(--card-bg); border: 1.5px solid var(--card-border); border-radius: 14px; padding: 12px 6px; }
.rewardIcon { font-size: 26px; margin-bottom: 4px; }
.rewardVal { font-family: var(--font-display); font-size: 20px; color: var(--red); margin-bottom: 2px; }
.rewardLbl { font-size: 9px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-3); }

.newBestBadge { background: linear-gradient(90deg, 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 18px; font-family: var(--font-display); font-size: 12px; letter-spacing: 1.5px; color: var(--yellow); margin-bottom: 14px; animation: badgePulse 1.5s infinite; }
.newBestBadge.hidden { display: none; }
@keyframes badgePulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

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

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

.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; }
.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(--red); }
#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(--red), #991b1b); color: white; font-family: var(--font-display); font-size: 18px; padding: 12px 28px; border-radius: 100px; box-shadow: 0 10px 30px rgba(239, 68, 68, 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); }

@media (max-height: 750px) {
  .homeContent { padding-top: 30px; }
  .trophyBig { font-size: 56px; }
  .bigTitle { font-size: 36px; }
  .subTitle { font-size: 13px; margin-bottom: 14px; }
  .prizeCard { padding: 10px 14px; margin-bottom: 12px; }
  .prizeIcon { font-size: 30px; }
  .prizeText strong { font-size: 14px; }
  .prizeText span { font-size: 11px; }
  .statsRow { margin-bottom: 14px; }
  .statBox { padding: 10px 6px; }
  .statIcon { font-size: 22px; }
  .statVal { font-size: 16px; }
  .carSelector { margin-bottom: 14px; }
  .bigBtn { padding: 14px 20px; font-size: 16px; margin-bottom: 8px; }
}

@media (max-height: 620px) {
  .homeContent { padding-top: 24px; }
  .trophyBig { font-size: 44px; }
  .bigTitle { font-size: 30px; }
  .subTitle { margin-bottom: 10px; }
  .prizeCard { margin-bottom: 10px; }
  .statsRow { margin-bottom: 10px; }
  .carSelector { margin-bottom: 10px; }
}
