/* ============================================================
   PlayDoor Gaming — Front Public
   Mobile-first, plein écran, immersif
   ============================================================ */

:root {
  /* Couleurs par défaut (surchargées par le commerce via JS) */
  --c-primary:   #FF6B2B;
  --c-secondary: #1A1A2E;
  --c-text:      #FFFFFF;

  /* Fixes */
  --bg:          #0d0e14;
  --card:        #16182a;
  --border:      rgba(255,255,255,.09);
  --muted:       rgba(255,255,255,.45);
  --radius:      16px;
  --radius-lg:   24px;
  --font:        'Plus Jakarta Sans', sans-serif;
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0 }

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: #fff;
  -webkit-font-smoothing: antialiased;
}

/* ── LOADER ─────────────────────────────────────────────────── */
#pd-loader {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px;
}
.pd-loader__logo {
  font-size: 48px;
  animation: bounce .8s infinite alternate;
}
.pd-loader__bar {
  width: 160px; height: 4px;
  background: rgba(255,255,255,.1);
  border-radius: 100px; overflow: hidden;
}
.pd-loader__bar span {
  display: block; height: 100%;
  background: var(--c-primary);
  border-radius: 100px;
  animation: loadbar 1.4s ease-in-out infinite;
}
@keyframes loadbar {
  0%   { width:0%; margin-left:0 }
  50%  { width:70%; margin-left:15% }
  100% { width:0%; margin-left:100% }
}
@keyframes bounce {
  from { transform: translateY(0) }
  to   { transform: translateY(-12px) }
}

/* ── LAYOUT PRINCIPAL ────────────────────────────────────────── */
.pd-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── HEADER COMMERCE ─────────────────────────────────────────── */
.pd-header {
  width: 100%; max-width: 480px;
  padding: 20px 20px 0;
  display: flex; align-items: center; gap: 12px;
}
.pd-header__logo {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--c-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,.4);
  overflow: hidden;
}
.pd-header__logo img { width:100%; height:100%; object-fit:cover }
.pd-header__name {
  font-size: 15px; font-weight: 800; color: #fff;
  line-height: 1.2;
}
.pd-header__cat {
  font-size: 12px; color: var(--muted); margin-top: 2px;
}
.pd-header__badge {
  margin-left: auto;
  background: rgba(255,255,255,.1);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px 12px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  white-space: nowrap;
}

/* ── CARTE LOT ────────────────────────────────────────────────── */
.pd-lot-card {
  width: 100%; max-width: 480px;
  margin: 16px 20px;
  background: linear-gradient(135deg, var(--c-primary), var(--c-secondary));
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative; overflow: hidden;
}
.pd-lot-card::before {
  content: '🎁';
  position: absolute; right: -8px; top: -8px;
  font-size: 80px; opacity: .15;
  transform: rotate(15deg);
}
.pd-lot-card__label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: rgba(255,255,255,.7); margin-bottom: 6px;
}
.pd-lot-card__title {
  font-size: 22px; font-weight: 800; color: #fff;
  line-height: 1.2; margin-bottom: 4px;
}
.pd-lot-card__desc {
  font-size: 13px; color: rgba(255,255,255,.75);
}

/* ── ZONE JEU ─────────────────────────────────────────────────── */
.pd-game-zone {
  width: 100%; max-width: 480px;
  padding: 0 20px;
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
}

.pd-game-canvas-wrap {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
  cursor: pointer;
  touch-action: none;
}

/* ── BOUTON JOUER ─────────────────────────────────────────────── */
.pd-play-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; max-width: 380px;
  margin: 20px auto 0;
  padding: 18px;
  border-radius: 18px;
  background: var(--c-primary);
  color: #fff;
  font-size: 18px; font-weight: 800;
  font-family: var(--font);
  border: none; cursor: pointer;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
  transition: transform .15s, box-shadow .15s;
  position: relative; overflow: hidden;
}
.pd-play-btn::after {
  content: '';
  position: absolute; inset: 0;
  background: rgba(255,255,255,.12);
  opacity: 0; transition: opacity .15s;
}
.pd-play-btn:hover::after { opacity: 1 }
.pd-play-btn:active { transform: scale(.97) }
.pd-play-btn:disabled {
  opacity: .5; cursor: not-allowed; transform: none;
}
.pd-play-btn .spin {
  display: inline-block;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── RÉSULTAT ─────────────────────────────────────────────────── */
.pd-result {
  display: none;
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.85);
  align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.pd-result.show { display: flex }

.pd-result__box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  width: 100%; max-width: 400px;
  text-align: center;
  animation: popIn .35s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { transform: scale(.8); opacity: 0 }
  to   { transform: scale(1);  opacity: 1 }
}

.pd-result__emoji {
  font-size: 64px; margin-bottom: 12px;
  display: block;
  animation: tada .6s ease .3s both;
}
@keyframes tada {
  0%   { transform: scale(1) }
  10%  { transform: scale(.95) rotate(-3deg) }
  30%  { transform: scale(1.15) rotate(3deg) }
  50%  { transform: scale(1.1) rotate(-2deg) }
  70%  { transform: scale(1.05) rotate(1deg) }
  100% { transform: scale(1) }
}

.pd-result__title {
  font-size: 24px; font-weight: 800; margin-bottom: 8px;
}
.pd-result__title.win  { color: #22C55E }
.pd-result__title.lose { color: var(--muted) }
.pd-result__sub {
  font-size: 14px; color: var(--muted); margin-bottom: 20px; line-height: 1.5;
}

/* Code gagnant */
.pd-win-code {
  background: rgba(255,255,255,.06);
  border: 2px dashed var(--c-primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}
.pd-win-code__label {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .7px; margin-bottom: 6px;
}
.pd-win-code__value {
  font-size: 15px; font-weight: 800;
  color: var(--c-primary); font-family: monospace;
  letter-spacing: .5px; word-break: break-all;
}
.pd-win-code__copy {
  margin-top: 8px;
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-family: var(--font);
  padding: 4px 10px; border-radius: 100px; cursor: pointer;
  transition: all .15s;
}
.pd-win-code__copy:hover { border-color: var(--c-primary); color: var(--c-primary) }

/* Boutons résultat */
.pd-result-btns {
  display: flex; flex-direction: column; gap: 10px;
}
.pd-btn-r {
  width: 100%; padding: 14px;
  border-radius: 14px;
  font-size: 15px; font-weight: 700;
  font-family: var(--font);
  border: none; cursor: pointer;
  transition: transform .1s, opacity .1s;
}
.pd-btn-r:active { transform: scale(.97) }
.pd-btn-r.primary { background: var(--c-primary); color: #fff }
.pd-btn-r.outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--muted);
}

/* ── CONFETTIS ────────────────────────────────────────────────── */
.confetti-piece {
  position: fixed;
  width: 10px; height: 10px;
  top: -20px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  pointer-events: none; z-index: 300;
}
@keyframes confettiFall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* ── MODAL AUTH ────────────────────────────────────────────────── */
.pd-auth-modal {
  display: none;
  position: fixed; inset: 0; z-index: 250;
  background: rgba(0,0,0,.88);
  align-items: flex-end; justify-content: center;
  padding: 0;
  backdrop-filter: blur(6px);
}
.pd-auth-modal.show { display: flex }

.pd-auth-box {
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: 28px 24px 36px;
  width: 100%; max-width: 480px;
  animation: slideUp .3s ease;
}
@keyframes slideUp {
  from { transform: translateY(100%) }
  to   { transform: translateY(0) }
}
.pd-auth-box__handle {
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 100px;
  margin: 0 auto 20px;
}
.pd-auth-box__title {
  font-size: 18px; font-weight: 800; margin-bottom: 6px; text-align: center;
}
.pd-auth-box__sub {
  font-size: 13px; color: var(--muted); text-align: center; margin-bottom: 20px;
}

/* Tabs auth */
.pd-auth-tabs {
  display: flex; margin-bottom: 20px;
  background: rgba(255,255,255,.05); border-radius: 12px; padding: 4px;
}
.pd-auth-tab {
  flex: 1; padding: 8px; border-radius: 9px; border: none;
  background: transparent; color: var(--muted);
  font-size: 13px; font-weight: 700; font-family: var(--font);
  cursor: pointer; transition: all .15s;
}
.pd-auth-tab.active { background: var(--c-primary); color: #fff }

.pd-auth-input {
  width: 100%; padding: 13px 14px;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--border);
  border-radius: 12px; color: #fff;
  font-size: 14px; font-family: var(--font);
  margin-bottom: 10px; transition: border-color .15s;
}
.pd-auth-input:focus { outline: none; border-color: var(--c-primary) }
.pd-auth-input::placeholder { color: var(--muted) }

.pd-auth-btn {
  width: 100%; padding: 15px;
  background: var(--c-primary); color: #fff;
  border: none; border-radius: 14px;
  font-size: 16px; font-weight: 800; font-family: var(--font);
  cursor: pointer; margin-top: 6px;
  transition: opacity .15s;
}
.pd-auth-btn:hover { opacity: .9 }
.pd-auth-btn:disabled { opacity: .5; cursor: not-allowed }

.pd-auth-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 10px; padding: 10px 14px;
  font-size: 13px; color: #EF4444;
  margin-bottom: 12px; display: none;
}
.pd-auth-error.show { display: block }

/* ── QUOTA ÉPUISÉ ─────────────────────────────────────────────── */
.pd-empty-state {
  text-align: center; padding: 40px 20px;
  max-width: 380px; margin: 0 auto;
}
.pd-empty-state__icon { font-size: 56px; margin-bottom: 16px }
.pd-empty-state__title {
  font-size: 20px; font-weight: 800; margin-bottom: 8px;
}
.pd-empty-state__sub {
  font-size: 14px; color: var(--muted); line-height: 1.6;
}

/* ── INFO BAS DE PAGE ─────────────────────────────────────────── */
.pd-footer {
  width: 100%; max-width: 480px;
  padding: 16px 20px 32px;
  text-align: center;
}
.pd-footer a {
  font-size: 12px; color: var(--muted);
  text-decoration: none;
}
.pd-footer a:hover { color: #fff }

/* ── RESPONSIVE ─────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .pd-screen { padding: 20px 0 }
  .pd-auth-box { border-radius: 28px }
  .pd-auth-modal { align-items: center }
}

/* ── UTILS ───────────────────────────────────────────────────────── */
.hidden { display: none !important }
