/* ==========================================================================
   THEME: HYPER CASUAL JUICY 2D (Splash Screen + High Contrast Audio UI)
   ========================================================================== */

:root {
  --bg-gradient: radial-gradient(circle at 50% 20%, #2e3a59 0%, #151a26 100%);
  
  --c-red-top: #ff4757;
  --c-red-bot: #eb2f06;
  --c-red-shadow: #b71540;

  --c-green-top: #2ed573;
  --c-green-bot: #20bf6b;
  --c-green-shadow: #079992;

  --c-cyan-top: #00d2d3;
  --c-cyan-bot: #0fbcf9;
  --c-cyan-shadow: #0652dd;

  --c-yellow-top: #fbc531;
  --c-yellow-bot: #e1b12c;
  --c-yellow-shadow: #b38808;

  --font-logo: 'Bungee', cursive, sans-serif;
  --font-body: 'Fredoka', cursive, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  font-family: var(--font-body);
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  background: #0b0e14;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-container {
  width: 100%;
  max-width: 420px;
  height: 100%;
  max-height: 100dvh;
  background: var(--bg-gradient);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
  overflow: hidden !important;
}

/* 3-Second Animated Splash Screen */
.splash-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #2e3a59 0%, #111520 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80%;
}

.splash-logo {
  transform: scale(1.2);
  margin-bottom: 20px;
}

.splash-loader-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  overflow: hidden;
  margin-top: 30px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.splash-loader-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(to right, #00d2d3, #2ed573);
  animation: loadSplash 2.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes loadSplash {
  0% { width: 0%; }
  50% { width: 65%; }
  100% { width: 100%; }
}

.splash-loading-text {
  font-family: var(--font-logo);
  font-size: 0.85rem;
  color: #00d2d3;
  margin-top: 10px;
  letter-spacing: 1px;
}

.bg-pattern {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 200%;
  background-image: 
    radial-gradient(circle at 12px 12px, rgba(255, 255, 255, 0.07) 3px, transparent 0),
    radial-gradient(circle at 35px 35px, rgba(255, 255, 255, 0.04) 5px, transparent 0);
  background-size: 50px 50px;
  animation: driftPattern 22s linear infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes driftPattern {
  from { transform: translate(0, 0); }
  to { transform: translate(-50px, -50px); }
}

.hide { display: none !important; }

.screen {
  flex: 1;
  width: 100%;
  height: calc(100% - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 18px;
  box-sizing: border-box;
  z-index: 2;
  overflow: hidden;
  animation: bounceIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounceIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.section-title {
  font-family: var(--font-logo);
  font-size: 1.3rem;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 3px 0 #000;
  margin-bottom: 8px;
}

.shop-sub-info {
  font-size: 0.8rem;
  color: #a4b0be;
  margin-bottom: 12px;
  text-align: center;
}

/* ==================== TOP NAVIGATION ==================== */
#top-bar {
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.25);
  z-index: 10;
  flex-shrink: 0;
}

.top-left, .top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-stat {
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.15);
  padding: 4px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.star-glow { color: #fbc531; filter: drop-shadow(0 0 5px #fbc531); }
.attempts-box { color: #ff4757; }
.timer-box { color: #ff9f43; }

.btn-bubble {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 1.15rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  border: none;
  transition: transform 0.1s ease;
}

.btn-bubble:active { transform: translateY(3px); }

.btn-top-white {
  background: linear-gradient(to bottom, #ffffff, #dfe4ea);
  box-shadow: 0 4px 0 #a4b0be;
  color: #2f3542;
}

.btn-top-blue {
  background: linear-gradient(to bottom, #1e90ff, #0984e3);
  box-shadow: 0 4px 0 #0652dd;
  color: #ffffff;
}

.btn-gray {
  background: linear-gradient(to bottom, #747d8c, #57606f);
  box-shadow: 0 4px 0 #2f3542;
  color: #fff;
}

/* ==================== 1. MAIN MENU ==================== */
#screen-main-menu {
  justify-content: space-evenly;
  padding: 10px 18px 25px;
}

.brand-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-box {
  position: relative;
  width: 76px;
  height: 76px;
  margin-bottom: 8px;
}

.logo-card-back {
  position: absolute;
  width: 55px;
  height: 65px;
  background: linear-gradient(135deg, #ff9f43, #ee5253);
  border: 3px solid #ffffff;
  border-radius: 14px;
  transform: rotate(-14deg);
  box-shadow: 0 5px 12px rgba(0,0,0,0.3);
}

.logo-card-front {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 55px;
  height: 65px;
  background: linear-gradient(135deg, #00d2d3, #0984e3);
  border: 3px solid #ffffff;
  border-radius: 14px;
  transform: rotate(10deg);
  display: flex;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 1.6rem;
  box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

.game-logo-text {
  font-family: var(--font-logo);
  font-size: 2.1rem;
  color: #ffffff;
  letter-spacing: 2px;
  text-shadow: 0 4px 0 #111622, 0 8px 15px rgba(0,0,0,0.5);
}

.logo-pop { color: #00d2d3; text-shadow: 0 4px 0 #0652dd; }

.tagline {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #a4b0be;
  margin-top: 2px;
}

.menu-grid-2x2 {
  width: 100%;
  max-width: 270px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 0 auto;
}

.btn-tile {
  height: 95px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  color: #fff;
  cursor: pointer;
  border: none;
  outline: none;
  position: relative;
  transition: transform 0.1s ease;
}

.btn-tile:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.3) !important;
}

.btn-tile::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  height: 35%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.4), rgba(255,255,255,0.05));
  border-radius: 10px;
  pointer-events: none;
}

.btn-tile i { font-size: 1.5rem; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.25)); }
.btn-tile span {
  font-family: var(--font-logo);
  font-size: 0.85rem;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(0,0,0,0.3);
}

.tile-red {
  background: linear-gradient(to bottom, var(--c-red-top), var(--c-red-bot));
  box-shadow: 0 4px 0 var(--c-red-shadow), 0 6px 10px rgba(0,0,0,0.25);
}
.tile-green {
  background: linear-gradient(to bottom, var(--c-green-top), var(--c-green-bot));
  box-shadow: 0 4px 0 var(--c-green-shadow), 0 6px 10px rgba(0,0,0,0.25);
}
.tile-cyan {
  background: linear-gradient(to bottom, var(--c-cyan-top), var(--c-cyan-bot));
  box-shadow: 0 4px 0 var(--c-cyan-shadow), 0 6px 10px rgba(0,0,0,0.25);
}
.tile-yellow {
  background: linear-gradient(to bottom, var(--c-yellow-top), var(--c-yellow-bot));
  box-shadow: 0 4px 0 var(--c-yellow-shadow), 0 6px 10px rgba(0,0,0,0.25);
}
.tile-yellow span, .tile-yellow i {
  color: #4b3600;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

/* ==================== 2. LEVEL SELECT ==================== */
#screen-level-select, #screen-mode-select, #screen-shop, #screen-themes {
  overflow-y: auto;
}

.levels-wrapper {
  width: 100%;
  max-width: 360px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 0 auto;
  padding-bottom: 20px;
}

.btn-level {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease;
}

.btn-level:active { transform: translateY(3px); }

.btn-level .lvl-num {
  font-family: var(--font-logo);
  font-size: 1.6rem;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.btn-level.playable {
  background: linear-gradient(to bottom, #1e90ff, #0984e3);
  box-shadow: 0 5px 0 #0652dd, 0 6px 10px rgba(0,0,0,0.3);
}

.btn-level.passed {
  background: linear-gradient(to bottom, #ff5e7e, #e84393);
  box-shadow: 0 5px 0 #b31e6f, 0 6px 10px rgba(0,0,0,0.3);
}

.btn-level.locked {
  background: linear-gradient(to bottom, #4b5563, #374151);
  box-shadow: 0 5px 0 #1f2937;
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-level .lock-icon { font-size: 1.4rem; color: #9ca3af; }

.btn-level .level-stars {
  font-size: 0.65rem;
  color: #fbc531;
  margin-top: 4px;
  display: flex;
  gap: 2px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.5));
}

.btn-level .level-stars .fa-regular {
  color: rgba(255,255,255,0.3);
}

/* ==================== 3. MODES, SHOP, THEMES ==================== */
.modes-list, .themes-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mode-card, .theme-card {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  padding: 10px 12px;
  border-radius: 16px;
  gap: 10px;
}

.mode-icon, .theme-preview {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.4rem;
  color: #fff;
  flex-shrink: 0;
}

.icon-blue { background: linear-gradient(135deg, #00d2d3, #0984e3); }
.icon-orange { background: linear-gradient(135deg, #ff9f43, #ee5253); }
.icon-purple { background: linear-gradient(135deg, #9c88ff, #8c7ae6); }

.bg-casual { background: linear-gradient(135deg, #ff6b81, #ffa502); }

.mode-info h3, .theme-details h3 { font-family: var(--font-logo); font-size: 1rem; color: #fff; }
.mode-info p, .theme-details p { font-size: 0.78rem; color: #dcdde1; }
.txt-green { color: #4cd137; font-weight: 800; }
.txt-red { color: #ff5e7e; font-weight: 800; }

.unlock-timer-badge {
  display: inline-block;
  background: #fbc531;
  color: #332600;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 6px;
  margin-top: 3px;
}

/* Sprites Unlock Grid */
.sprites-shop-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding-bottom: 20px;
}

.sprite-shop-item {
  aspect-ratio: 1/1;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.sprite-shop-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sprite-shop-item.locked-sprite img {
  filter: grayscale(1) blur(2px) brightness(0.4);
}

.sprite-shop-item .lock-overlay {
  position: absolute;
  color: #fbc531;
  font-size: 1.3rem;
  filter: drop-shadow(0 2px 4px #000);
}

.btn-mini {
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-family: var(--font-logo);
  border: none;
  cursor: pointer;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.btn-mini.btn-green { background: #2ed573; box-shadow: 0 3px 0 #079992; color: #fff; }
.btn-mini.btn-yellow { background: #fbc531; box-shadow: 0 3px 0 #b38808; color: #4b3600; font-weight: 900; }
.btn-mini.btn-gray { background: #747d8c; box-shadow: 0 3px 0 #2f3542; color: #fff; }

.btn-mini-wide {
  width: auto;
  padding: 8px 24px;
  height: 44px;
}

/* ==================== 4. 201x201 CARDS & FULL QUESTION MARK ==================== */
#screen-game {
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#board-container {
  width: 100%;
  max-width: 380px;
  height: 80%;
  max-height: 520px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.cards-grid {
  width: 100%;
  height: 100%;
  display: grid;
  gap: 10px;
  perspective: 1000px;
  align-content: center;
  justify-content: center;
}

.card {
  width: 100%;
  aspect-ratio: 1/1;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card.is-flipped {
  transform: rotateY(180deg);
}

.card.is-matched {
  transform: rotateY(180deg) scale(0.95) !important;
  pointer-events: none;
  cursor: default;
}

.card.is-matched .card-face-front {
  border: 3px solid #2ed573;
  box-shadow: 0 0 14px rgba(46, 213, 115, 0.8);
}

.card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.card-face-front {
  background: #ffffff;
  border: 3px solid #dfe4ea;
  transform: rotateY(180deg);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
  padding: 4px;
}

.card-sprite {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
  pointer-events: none;
}

.card-face-back {
  background: linear-gradient(135deg, #ff6b81, #ff4757);
  border: 3px solid #ff7979;
  box-shadow: 0 5px 0 #b71540;
  padding: 0;
}

.card-back-icon {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* ==================== MODALS & AUDIO LIST FIX ==================== */
.modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-card {
  width: 90%;
  max-width: 380px;
  background: #1f2738;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  padding: 18px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.8);
  color: #fff;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h2 { font-family: var(--font-logo); font-size: 1.3rem; }

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.divider {
  border: 0;
  height: 1px;
  background: rgba(255,255,255,0.15);
  margin: 10px 0;
}

.music-track-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.track-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
}

.track-item.active {
  border: 2px solid #2ed573;
  background: rgba(46, 213, 115, 0.15);
}

.track-name {
  color: #fff;
  font-size: 0.9rem;
}

/* Win / Fail Popups */
.win-popup, .fail-popup { text-align: center; }
.win-popup h2 { font-family: var(--font-logo); font-size: 1.8rem; color: #fbc531; }
.fail-title { font-family: var(--font-logo); font-size: 1.8rem; color: #ff4757; }
.fail-msg { font-size: 1rem; color: #dcdde1; margin-bottom: 14px; font-weight: 700; }

.star-rating {
  font-size: 2.2rem;
  color: #fbc531;
  margin: 10px 0;
}
.star-rating .star:not(.active) { color: #57606f; }

.end-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.stat-pill {
  background: rgba(0,0,0,0.4);
  padding: 6px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 800;
}

.modal-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.btn-revive {
  background: linear-gradient(to bottom, #fbc531, #e1b12c);
  box-shadow: 0 4px 0 #b38808;
  color: #4b3600;
  border-radius: 14px;
  padding: 10px 18px;
  font-family: var(--font-logo);
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
}
/* Card Shift Wobble for Mode 3 */
@keyframes cardWobble {
  0% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(0.92) rotate(-6deg); }
  50% { transform: scale(1.05) rotate(6deg); }
  75% { transform: scale(0.95) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.card-shuffle-wobble {
  animation: cardWobble 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Confetti Particle Burst */
.confetti-particle {
  position: fixed;
  width: 10px;
  height: 10px;
  top: 50%;
  left: 50%;
  border-radius: 2px;
  pointer-events: none;
  z-index: 999999;
  animation: confettiFly 1.2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes confettiFly {
  0% {
    transform: translate(0, 0) scale(1) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(0) rotate(720deg);
    opacity: 0;
  }
}
#cards-grid {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.card-pattern-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
}