:root {
    --soft-light: #e6f0ff;
    --water-silver: #a0b8d4;
    --mist-blue: #8fbfe0;
    --deep-lilac: #c7b8ff;
    --accent-glow: #8fbfe0;
}
body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #0a0e1a;
    color: var(--soft-light);
}
.card-inner {
    position: relative;
    perspective: 1000px;
  }
  
  .face {
    backface-visibility: hidden;
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    transition: transform 0.8s;
  }
  
  .front {
    z-index: 2;
    transform: rotateY(0deg);
  }
  
  .back {
    transform: rotateY(180deg);
    z-index: 1;
  }
  
  .card-inner.flipped .front {
    transform: rotateY(180deg);
  }
  
  .card-inner.flipped .back {
    transform: rotateY(0deg);
    z-index: 3; 
  }
  


.grid-wrap { padding: 2rem; max-width: 1200px; margin: 0 auto; }
.cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.view-collection:hover
{
    scale: 1.05;
}
.view-collection:active
{
    scale: 0.95 ;
}
.card { perspective: 1200px; height: 16rem; cursor: pointer; position: relative; transition: all 0.3s ease-out; }
.card-inner { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform .65s ease; }
.card.is-flipped .card-inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; border-radius: 12px; padding: 1rem; backface-visibility: hidden; display:flex; flex-direction:column; justify-content:space-between; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.face.front { transform: none; }
.face.back { transform: rotateY(180deg); }
.tap-hint { font-size: .8rem; opacity: .85; color: var(--water-silver); }

.collect-btn { width: 100%; padding: .65rem; border-radius: 10px; border: 1px solid rgba(255,255,255,.06); background: rgba(255,107,107,.08); color: var(--soft-light); font-weight:600; cursor:pointer; }
.card.collected { 
    opacity: 1; 
    transform: scale(0.98);
    border: 3px solid var(--accent-glow);
    box-shadow: 0 0 30px rgba(143,191,224,.6), 0 0 60px rgba(143,191,224,.4);
    position: relative;
}
.card.collected .face.front::after {
    content: '✓';
    position: absolute;
    top: 15px;
    right: 15px;
    width: 50px;
    height: 50px;
    background: var(--accent-glow);
    color: #0a0e1a;
    border-radius: 50%;
    font-size: 28px;
    font-weight: bold;
    line-height: 50px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(143,191,224,.5);
    z-index: 10;
    animation: checkmark-pop 0.3s ease-out;
}
@keyframes checkmark-pop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
.collection-bar { display:flex; gap:.5rem; align-items:center; justify-content:center; }
.slot { width:40px; height:40px; border-radius:8px; border:2px solid rgba(143,191,224,.3); display:flex; align-items:center; justify-content:center; background:transparent; color:var(--soft-light); font-weight:600; }
.slot.filled { background: rgba(143,191,224,.18); border-color: rgba(143,191,224,.6); }
.collection-count { color: var(--mist-blue); font-size:.9rem; margin-left:.75rem; }


/* The Modal (background) */
.modal {
  display: none; /* Hidden by default */
  position: fixed; /* Stay in place */
  z-index: 1; /* Sit on top */
  left: 0;
  top: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height */
  overflow: auto; /* Enable scroll if needed */
  background-color: rgb(0,0,0); /* Fallback color */
  background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

#story-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

#story-modal > div {
  background: #1b1b2f;
  color: #e6f0ff;
  padding: 2rem;
  border-radius: 16px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  text-align: center;
  animation: pop-in 0.3s ease-out;
}

@keyframes pop-in {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}