<style>
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --ink: #0d0d0f; --paper: #f5f0e8; --muted: #a09a8c;
    --accent: #c97c3a; --border: rgba(160,154,140,0.25); --glass: rgba(13,13,15,0.82);
  }
  /* ── AUTH OVERLAY ── */
  #authOverlay {
    position: fixed; inset: 0; z-index: 9999;
    display: flex; align-items: center; justify-content: center;
    background: #03020D;
  }
  #authOverlay.hidden { display: none; }

  #authBox {
    display: flex; flex-direction: column; align-items: center;
    gap: 1.6rem; padding: 3rem 2.8rem 2.8rem;
    border: 0.5px solid rgba(201,124,58,0.25);
    background: rgba(13,10,28,0.85);
    backdrop-filter: blur(18px);
    max-width: 360px; width: 90%;
    position: relative; z-index: 1;
  }

  .auth-logo {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.9rem; font-weight: 300;
    letter-spacing: 0.06em; color: var(--paper);
    text-align: center;
  }
  .auth-logo em { color: var(--accent); font-style: italic; }

  .auth-subtitle {
    font-size: 0.62rem; color: var(--muted);
    letter-spacing: 0.14em; text-transform: uppercase;
    text-align: center; margin-top: -1rem;
  }

  .auth-field {
    width: 100%; position: relative;
  }
  .auth-field input {
    width: 100%; padding: 0.75rem 2.6rem 0.75rem 0.9rem;
    background: rgba(245,240,232,0.04);
    border: 0.5px solid var(--border);
    color: var(--paper);
    font-family: 'DM Mono', monospace;
    font-size: 0.8rem; letter-spacing: 0.12em;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
  }
  .auth-field input:focus { border-color: var(--accent); }
  .auth-field input::placeholder { color: rgba(160,154,140,0.4); letter-spacing: 0.08em; }

  /* Bouton œil pour afficher/masquer */
  .auth-eye {
    position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 0.9rem; padding: 0; line-height: 1;
    transition: color 0.2s;
  }
  .auth-eye:hover { color: var(--accent); }

  .auth-btn {
    width: 100%; padding: 0.75rem;
    background: rgba(201,124,58,0.12);
    border: 0.5px solid var(--accent);
    color: var(--accent);
    font-family: 'DM Mono', monospace;
    font-size: 0.7rem; letter-spacing: 0.14em; text-transform: uppercase;
    cursor: pointer; transition: background 0.2s;
  }
  .auth-btn:hover  { background: rgba(201,124,58,0.25); }
  .auth-btn:active { background: rgba(201,124,58,0.35); }
  .auth-btn:disabled { opacity: 0.5; cursor: default; }

  .auth-error {
    font-size: 0.62rem; color: #E05050;
    letter-spacing: 0.1em; text-align: center;
    min-height: 1rem;
    animation: authShake 0.35s ease;
  }
  @keyframes authShake {
    0%,100% { transform: translateX(0); }
    20%,60%  { transform: translateX(-6px); }
    40%,80%  { transform: translateX(6px); }
  }

  /* Spinner pendant le calcul bcrypt */
  .auth-spinner {
    width: 18px; height: 18px;
    border: 1.5px solid rgba(201,124,58,0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: none;
  }
  .auth-spinner.show { display: block; }
  @keyframes spin { to { transform: rotate(360deg); } }

  /* Transition sortie de l'overlay */
  #authOverlay.fade-out {
    animation: authFadeOut 0.6s ease forwards;
  }
  @keyframes authFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; pointer-events: none; }
  }

  #starsBg {
    position: fixed; inset: 0;
    width: 100%; height: 100%;
    z-index: -1; pointer-events: none;
  }

  body {
    background: #03020D;
    color: var(--paper);
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    min-height: 100vh;
    overflow-x: hidden;
  }

  header, main, #lightbox, #slideshow {
    position: relative; z-index: 1;
  }

  /* HEADER */
  header { display: flex; align-items: center; justify-content: space-between; padding: 1.5rem 2.5rem; border-bottom: 0.5px solid var(--border); position: sticky; top: 0; background: rgba(3,2,13,0.75); backdrop-filter: blur(14px); z-index: 100; }
  .logo { font-family: 'Cormorant Garamond', serif; font-size: 1.6rem; font-weight: 300; letter-spacing: 0.05em; }
  .logo em { color: var(--accent); font-style: italic; }
  .btn { background: transparent; border: 0.5px solid var(--border); color: var(--muted); font-family: 'DM Mono', monospace; font-size: 0.68rem; letter-spacing: 0.1em; padding: 0.4rem 0.9rem; cursor: pointer; transition: all 0.2s; text-transform: uppercase; }
  .btn:hover { border-color: var(--accent); color: var(--accent); }

  /* SCRABBLE 3D */
  main { padding: 1.5rem 2.5rem 3rem; }
  .gallery-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 0.5px solid var(--border); }
  .photo-count { font-size: 0.68rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }

  /* ── Scène & plateau incliné ── */
  #scrWrap {
    display: flex; justify-content: center; align-items: flex-start;
    perspective: 1200px; perspective-origin: 50% 10%;
    padding-bottom: 3rem;
    position: relative; z-index: 2;
    isolation: isolate;
  }
  #scrBoardWrap {
    transform: rotateX(46deg) rotateZ(-3deg);
    transform-origin: center 65%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(.4,0,.2,1);
    position: relative; z-index: 2;
  }
  #scrWrap:hover #scrBoardWrap { transform: rotateX(30deg) rotateZ(-1deg); }

  #scrBoard {
    display: grid;
    gap: 0;
    background: #080604;
    border: 5px solid #080604;
    box-shadow:
      0 0 0 1px rgba(245,240,232,0.1),
      0 0 0 3px #080604,
      0 32px 100px rgba(0,0,0,0.98);
    position: relative; z-index: 2;
  }

  .scr-cell { position: relative; overflow: hidden; }

  /* Case blanche vide (sans mot) */
  .cell-white {
    background: #EDE8D5;
    outline: 1px solid rgba(60,45,15,0.18);
  }

  /* Case noire */
  .cell-black {
    background: #0D0A07;
    box-shadow: inset 1px 1px 4px rgba(0,0,0,0.7),
                inset -1px -1px 2px rgba(255,255,240,0.02);
  }

  /* Numéro de définition */
  .cell-num {
    position: absolute; top: 2px; left: 2px;
    font-size: 0.32rem; color: rgba(25,15,2,0.6);
    font-family: 'DM Mono', monospace;
    line-height: 1; z-index: 3; font-weight: 300;
    pointer-events: none;
  }

  /* Lettre en surimpression sur la photo */
  .tile-letter-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400; line-height: 1;
    color: rgba(255, 255, 255, 0.92);
    text-shadow:
      0 2px 12px rgba(0,0,0,0.85),
      0 0 4px rgba(0,0,0,0.6);
    z-index: 4; pointer-events: none;
    user-select: none;
    transition: opacity 0.3s;
  }
  .scr-tile:hover .tile-letter-overlay { opacity: 0.25; }

  /* ── Clone overlay ── */
  #cloneOverlay {
    display: none; position: fixed; inset: 0;
    background: rgba(3,2,13,0.88); backdrop-filter: blur(6px);
    z-index: 3998;
  }
  #cloneOverlay.open { display: block; }

  #spinClone {
    position: fixed;
    z-index: 4000;
    pointer-events: none;
    transform-style: preserve-3d;
    will-change: transform, opacity, width, height, top, left;
  }
  #spinClone img {
    width: 100%; height: 100%;
    object-fit: contain; display: block;
    backface-visibility: hidden;
    background: #03020D;
  }

  /* Flèches de navigation du clone */
  .clone-nav {
    position: fixed; top: 50%; transform: translateY(-50%);
    z-index: 4002; pointer-events: auto; cursor: pointer;
    width: 52px; height: 52px;
    background: rgba(13,10,28,0.75); border: 0.5px solid rgba(201,124,58,0.35);
    color: var(--paper); font-size: 1.6rem;
    display: none; align-items: center; justify-content: center;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s;
    user-select: none;
  }
  .clone-nav.visible { display: flex; }
  .clone-nav:hover { background: rgba(201,124,58,0.18); border-color: var(--accent); color: var(--accent); }
  .clone-nav.disabled { opacity: 0.18; pointer-events: none; }
  #cloneNavL { left: 1.2rem; }
  #cloneNavR { right: 1.2rem; }

  /* Bouton fermer du clone */
  #cloneClose {
    position: fixed; top: 1.2rem; right: 1.2rem; z-index: 4002;
    display: none; width: 38px; height: 38px;
    background: rgba(13,10,28,0.75); border: 0.5px solid var(--border);
    color: var(--muted); font-size: 1rem; cursor: pointer;
    align-items: center; justify-content: center;
    transition: border-color 0.2s, color 0.2s;
  }
  #cloneClose.visible { display: flex; }
  #cloneClose:hover { border-color: var(--accent); color: var(--accent); }

  /* Caption du clone */
  #cloneCaption {
    position: fixed; z-index: 4002;
    pointer-events: none; text-align: center;
    padding: 1.2rem 5rem 1.4rem;
    background: linear-gradient(to top, rgba(13,13,15,0.9) 0%, transparent 100%);
    display: none; animation: lbFadeIn 0.3s ease;
  }
  #cloneCaption.visible { display: block; }


  /* Phase 1 : rotation sur Y (la case tourne sur elle-même) */
  @keyframes spinY {
    0%   { transform: perspective(800px) rotateY(0deg)   scale(1); }
    25%  { transform: perspective(800px) rotateY(90deg)  scale(1.08); }
    50%  { transform: perspective(800px) rotateY(180deg) scale(1.15); }
    75%  { transform: perspective(800px) rotateY(270deg) scale(1.08); }
    100% { transform: perspective(800px) rotateY(360deg) scale(1); }
  }

  /* Ripple au départ */
  .tile-ripple {
    position: absolute; inset: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.7) 0%, transparent 70%);
    animation: ripplePop 0.35s ease-out forwards;
    pointer-events: none; z-index: 10;
  }
  @keyframes ripplePop {
    0%   { transform: scale(0); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
  }

  /* Lightbox : l'image entre en fondu progressif depuis petit → grand */
  #lightboxImg { max-width: 88vw; max-height: 82vh; object-fit: contain; }
  #lightboxImg.lb-entering { animation: lbFadeIn 0.28s ease both; }
  @keyframes lbFadeIn { from { opacity: 0; } to { opacity: 1; } }



  /* LIGHTBOX */
  #lightbox { display: none; position: fixed; inset: 0; background: rgba(13,13,15,0.96); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
  #lightbox.open { display: flex; }
  .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: var(--glass); border: 0.5px solid var(--border); color: var(--paper); font-size: 1.4rem; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s; }
  .lb-nav:hover { border-color: var(--accent); color: var(--accent); }
  #lbPrev { left: 1.5rem; } #lbNext { right: 1.5rem; }
  #lbClose { position: absolute; top: 1.2rem; right: 1.2rem; transform: none; font-size: 1rem; width: 36px; height: 36px; }
  .lb-caption { position: absolute; bottom: 0; left: 0; right: 0; padding: 1.2rem 5rem; background: linear-gradient(to top, rgba(13,13,15,0.9) 0%, transparent 100%); text-align: center; }
  .lb-caption-title { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; margin-bottom: 0.3rem; }
  .lb-caption-desc { font-family: 'Cormorant Garamond', serif; font-size: 1.1rem; font-style: italic; color: rgba(245,240,232,0.85); font-weight: 300; }

  /* SLIDESHOW */
  #slideshow { display: none; position: fixed; inset: 0; background: var(--ink); z-index: 500; flex-direction: column; align-items: center; justify-content: center; }
  #slideshow.open { display: flex; }
  #ssProgress { position: absolute; top: 0; left: 0; height: 2px; background: var(--accent); transition: width 0.1s linear; }
  #ssImg { max-width: 100vw; max-height: 100vh; object-fit: contain; }
  #ssImg.tr-fade      { animation: trFade      0.9s ease both; }
  #ssImg.tr-zoomin    { animation: trZoomIn    0.9s ease both; }
  #ssImg.tr-zoomout   { animation: trZoomOut   0.9s ease both; }
  #ssImg.tr-slideleft { animation: trSlideLeft 0.75s cubic-bezier(.4,0,.2,1) both; }
  #ssImg.tr-slideup   { animation: trSlideUp   0.75s cubic-bezier(.4,0,.2,1) both; }
  #ssImg.tr-rotatein  { animation: trRotateIn  1s cubic-bezier(.2,.8,.3,1) both; }
  /* Première diapo : apparition progressive + zoom vers le coin bas-droit */
  #ssImg.tr-first {
    animation: trFirst var(--ss-dur, 10s) cubic-bezier(.1,0,.2,1) both;
    transform-origin: 100% 75%;
  }
  @keyframes trFirst {
    0%   { opacity: 0; transform: scale(1);   }
    7%   { opacity: 1; transform: scale(1);   }
    100% { opacity: 1; transform: scale(2.6); }
  }
  @keyframes trFade      { from { opacity: 0; }                                    to { opacity: 1; } }
  @keyframes trZoomIn    { from { opacity: 0; transform: scale(1.08); }            to { opacity: 1; transform: scale(1); } }
  @keyframes trZoomOut   { from { opacity: 0; transform: scale(0.93); }            to { opacity: 1; transform: scale(1); } }
  @keyframes trSlideLeft { from { opacity: 0; transform: translateX(60px); }       to { opacity: 1; transform: translateX(0); } }
  @keyframes trSlideUp   { from { opacity: 0; transform: translateY(50px); }       to { opacity: 1; transform: translateY(0); } }
  @keyframes trRotateIn  { from { opacity: 0; transform: scale(0.95) rotate(-1.5deg); } to { opacity: 1; transform: scale(1) rotate(0deg); } }
  .ss-counter { position: absolute; top: 1.4rem; right: 1.8rem; font-size: 0.62rem; color: rgba(245,240,232,0.3); letter-spacing: 0.1em; }

  /* Bloc description en bas du diaporama */
  #ssCaptionBlock {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, rgba(13,13,15,0.92) 0%, rgba(13,13,15,0.6) 60%, transparent 100%);
    padding: 3rem 3rem 5.5rem;
    display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
    text-align: center;
    animation: captionIn 0.6s ease;
  }
  @keyframes captionIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  #ssTitle {
    font-size: 0.62rem; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase;
  }
  #ssDesc {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.35rem; font-weight: 300; font-style: italic;
    color: rgba(245,240,232,0.88);
    max-width: 600px; line-height: 1.5;
  }
  #ssDesc:empty { display: none; }

  .ss-controls { position: absolute; bottom: 1.5rem; left: 50%; transform: translateX(-50%); display: flex; gap: 0.8rem; z-index: 10; transition: opacity 0.5s ease; }
  .ss-controls.hidden { opacity: 0; pointer-events: none; }

  .err-msg { font-size: 0.62rem; color: rgba(160,154,140,0.7); letter-spacing: 0.06em; }
</style>