/* ============================================================
   DROP MERGE — Design premium 2026
   Palette : #0A0E1A/#131829 fond · #7B3FF2 violet · #00D4FF cyan
   Typo : Inter (Google Fonts, chargé via index.html)
   ============================================================ */

/* === TOKENS === */
:root {
  --bg-deep:      #0A0E1A;
  --bg-card:      #161B2E;
  --bg-card-2:    #1E2438;
  --accent:       #7B3FF2;
  --accent-light: #9B6BF4;
  --cyan:         #00D4FF;
  --text-primary: #FFFFFF;
  --text-secondary: #8B92A8;
  --text-muted:   #4B5563;
  --danger:       #FF3B3B;
  --gold:         #FFD700;

  --radius-sm:  10px;
  --radius-md:  16px;
  --radius-lg:  24px;
  --radius-xl:  32px;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--text-primary);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  /* Bloque le scroll et le bounce iOS */
  position: fixed;
  overscroll-behavior: none;
}

/* === CONTENEUR GLOBAL === */
#app {
  position: fixed;
  inset: 0;
  /* Respecter les encoches iPhone (safe area) */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* === CANVAS === */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  touch-action: none;
}

/* ============================================================
   HUD EN JEU
   ============================================================ */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  z-index: 20;
  pointer-events: none;
}

#hud.hidden { display: none; }

/* === Bloc NEXT === */
#next-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}

#next-wrapper {
  width: 52px;
  height: 52px;
  background: rgba(123, 63, 242, 0.10);
  border: 1px solid rgba(123, 63, 242, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#nextCanvas {
  display: block;
}

/* === Bloc SCORE === */
#score-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  pointer-events: none;
}

/* === Label commun HUD === */
.hud-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-light);
  text-transform: uppercase;
}

/* === Score gradient text === */
.score-gradient {
  background: linear-gradient(135deg, #9B6BF4 0%, #00D4FF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-variant-numeric: tabular-nums;
}

#score-value {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* === Bouton pause === */
#btn-pause {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  background: rgba(123, 63, 242, 0.12);
  border: 1px solid rgba(123, 63, 242, 0.30);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#btn-pause:active {
  background: rgba(123, 63, 242, 0.30);
  color: #fff;
}

/* ============================================================
   ÉCRANS OVERLAY
   ============================================================ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: rgba(8, 11, 20, 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.screen.hidden { display: none; }

.screen-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 340px;
  background: linear-gradient(160deg, #1A1F35 0%, #141826 100%);
  border: 1px solid rgba(123, 63, 242, 0.25);
  border-radius: var(--radius-xl);
  padding: 32px 24px 28px;
  box-shadow:
    0 0 0 1px rgba(0, 212, 255, 0.04) inset,
    0 32px 80px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(123, 63, 242, 0.12);
}

/* === Accueil : layout vertical centré === */
.home-inner {
  gap: 20px;
}

/* === Logo === */
.logo-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.game-title {
  font-size: 68px;
  font-weight: 900;
  line-height: 0.92;
  text-align: center;
  letter-spacing: -0.04em;
  background: linear-gradient(135deg, #A78BFA 0%, #7B3FF2 40%, #00D4FF 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(123, 63, 242, 0.50));
}

.game-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  text-align: center;
}

/* === Carte highscore accueil === */
.hs-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(123, 63, 242, 0.08);
  border: 1px solid rgba(123, 63, 242, 0.20);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  width: 100%;
}

.hs-icon {
  font-size: 28px;
  line-height: 1;
}

.hs-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hs-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

/* === Titres écrans === */
.screen-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.gameover-title {
  background: linear-gradient(135deg, #FA5252, #E64980);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* === Cartes stats === */
.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 14px 24px;
  width: 100%;
}

.stat-card.compact {
  padding: 10px 24px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-secondary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.final-score {
  font-size: 52px;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
}

/* === Badge NEW RECORD === */
#new-record-badge {
  background: linear-gradient(135deg, #FAB005, #FFD700);
  color: #1a0e00;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 8px 18px;
  border-radius: 100px;
  box-shadow:
    0 0 24px rgba(250, 176, 5, 0.55),
    0 4px 12px rgba(0,0,0,0.3);
  animation: badge-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

#new-record-badge.hidden { display: none; }

@keyframes badge-pop {
  0%   { transform: scale(0.4); opacity: 0; }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================================================
   BOUTONS
   ============================================================ */

/* Bouton principal plein gradient */
.btn-primary {
  width: 100%;
  padding: 0 24px;
  height: 58px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #9B59D0 0%, #7B3FF2 55%, #5730C0 100%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, box-shadow 0.15s;
}

/* Variante avec glow violet */
.btn-glow {
  box-shadow:
    0 0 24px rgba(123, 63, 242, 0.50),
    0 8px 24px rgba(0, 0, 0, 0.35);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 10px rgba(123, 63, 242, 0.25);
}

/* Bouton outline violet */
.btn-outline {
  width: 100%;
  padding: 0 24px;
  height: 52px;
  background: transparent;
  border: 1.5px solid rgba(123, 63, 242, 0.55);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-light);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, border-color 0.15s;
}

.btn-outline:active {
  background: rgba(123, 63, 242, 0.12);
}

/* Bouton ghost (texte seul) */
.btn-ghost {
  width: 100%;
  padding: 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.btn-ghost:active { color: var(--text-secondary); }

.hint-text {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ============================================================
   ÉCRAN CONTINUE
   ============================================================ */
.continue-emoji {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(255,200,100,0.4));
}

.screen-desc {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.65;
}

.screen-desc strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* Barre de timer */
.timer-track {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  overflow: hidden;
}

#continue-timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #7B3FF2, #00D4FF);
  border-radius: 3px;
  transform-origin: left center;
  animation: timer-shrink 5s linear forwards;
}

@keyframes timer-shrink {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ============================================================
   TOAST
   ============================================================ */
#toast {
  position: fixed;
  bottom: max(28px, env(safe-area-inset-bottom, 28px));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(123, 63, 242, 0.92);
  color: #fff;
  padding: 11px 22px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  z-index: 100;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 24px rgba(123, 63, 242, 0.45);
  white-space: nowrap;
  animation: toast-appear 0.25s ease;
}

#toast.hidden { display: none; }

@keyframes toast-appear {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   UTILITAIRES
   ============================================================ */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
}

/* ============================================================
   HUD — boutons regroupés (mute + pause)
   ============================================================ */
.hud-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}

.hud-icon-btn {
  width: 44px;
  height: 44px;
  background: rgba(123, 63, 242, 0.12);
  border: 1px solid rgba(123, 63, 242, 0.30) !important;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 18px;
}

.hud-icon-btn:active {
  background: rgba(123, 63, 242, 0.30);
  color: #fff;
}

/* ============================================================
   STATS ROW (écran accueil)
   ============================================================ */
.stats-row {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  width: 100%;
  letter-spacing: 0.01em;
}

/* ============================================================
   DÉFI DU JOUR
   ============================================================ */
.daily-card {
  width: 100%;
  background: rgba(255, 215, 0, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.22);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.daily-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.daily-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-transform: uppercase;
}

.daily-star {
  font-size: 18px;
  filter: grayscale(1);
  transition: filter 0.3s;
}

.daily-star.done {
  filter: grayscale(0) drop-shadow(0 0 6px rgba(255,215,0,0.7));
}

.daily-desc {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ============================================================
   TUTORIEL
   ============================================================ */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(8, 11, 20, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tutorial-overlay.hidden { display: none; }

.tutorial-card {
  background: linear-gradient(160deg, #1A1F35 0%, #141826 100%);
  border: 1px solid rgba(123, 63, 242, 0.35);
  border-radius: var(--radius-xl);
  padding: 36px 28px 28px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  box-shadow:
    0 0 60px rgba(123, 63, 242, 0.20),
    0 32px 80px rgba(0,0,0,0.5);
}

.tutorial-anim {
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-hand {
  font-size: 48px;
  display: inline-block;
  animation: hand-slide 1.6s ease-in-out infinite;
}

@keyframes hand-slide {
  0%   { transform: translateX(-28px); }
  50%  { transform: translateX(28px); }
  100% { transform: translateX(-28px); }
}

.tutorial-hand.drop-anim {
  animation: hand-drop 1.2s ease-in-out infinite;
}

@keyframes hand-drop {
  0%   { transform: translateY(0); }
  50%  { transform: translateY(24px); }
  100% { transform: translateY(0); }
}

.tutorial-hand.merge-anim {
  animation: hand-pulse 0.8s ease-in-out infinite;
}

@keyframes hand-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.25); }
}

.tutorial-msg {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.01em;
  line-height: 1.3;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-dots {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tuto-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(123, 63, 242, 0.25);
  transition: background 0.3s, transform 0.3s;
}

.tuto-dot.active {
  background: var(--accent);
  transform: scale(1.3);
}

/* ============================================================
   GLOW PULSANT — balle 2048
   ============================================================ */
@keyframes glow-2048 {
  0%, 100% { box-shadow: 0 0 24px 6px rgba(255,215,0,0.55); }
  50%       { box-shadow: 0 0 48px 14px rgba(255,215,0,0.85); }
}
