body {
  font-family: 'Montserrat', Arial, sans-serif;
  background: linear-gradient(135deg, #f5d7e3 0%, #cffaf7 100%);
  margin: 0;
  color: #34354a;
  min-height: 100vh;
}
header {
  text-align: center;
  margin-top: 1.2em;
}
header h1 {
  margin-bottom: 0.2em;
  font-size: 1.8em;
  font-weight: 700;
  color: #6c1b3a;
  letter-spacing: 1px;
}
header p {
  font-size: 1em;
  color: #4d426d;
}

#deck-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 2em auto 0;
  max-width: 420px;
  padding-bottom: 64px;
}

.card {
  width: 68px;
  height: 98px;
  background: #fff0f7;
  border-radius: 11px;
  border: 2px solid #c0a6c8;
  box-shadow: 0 2px 8px #b03c7b32;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2em;
  font-weight: bold;
  color: #be4a87;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0.12s;
  backface-visibility: hidden;
  outline: none;
}
.card:active,
.card:focus {
  transform: scale(1.05) rotate(-2deg);
  border-color: #e26c9b;
}

#result-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(39, 17, 32, 0.56);
  display: flex;
  justify-content: center;
  align-items: center;
}

#result-modal.hidden {
  display: none;
}

.modal-content {
  background: #fffefa;
  border-radius: 16px;
  max-width: 92vw;
  width: 360px;
  padding: 22px 16px 18px 16px;
  position: relative;
  text-align: center;
  animation: popin 0.33s;
  box-shadow: 0 6px 18px #4c225327;
}
@keyframes popin {
  0% { transform: scale(0.88); opacity: 0.3;}
  100% { transform: scale(1); opacity: 1;}
}
#close-modal {
  position: absolute;
  right: 12px;
  top: 8px;
  background: none;
  border: none;
  font-size: 2em;
  color: #be4a87;
  cursor: pointer;
  line-height: 1;
}

#card-image {
  width: 100px;
  height: 100px;
  object-fit: contain;
  display: block;
  margin: 0.5em auto 0.9em;
}
#card-title {
  font-size: 1.12em;
  font-weight: bold;
  color: #7d1757;
  margin-bottom: 0.5em;
}
#card-advice {
  font-size: 1em;
  color: #503154;
}

/* --- GALLERY STYLES --- */
.gallery-preview {
  margin: 2em auto 2em auto;
  max-width: 700px;
  background: #fff4f8cc;
  border-radius: 12px;
  box-shadow: 0 2px 6px #d278b422;
  padding: 1.2em 0.8em;
  text-align: center;
}
.gallery-preview h3 {
  color: #b94798;
  font-weight: 700;
  margin-bottom: 14px;
  font-size: 1.15em;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 10px;
  justify-items: center;
  align-items: end;
  padding: 0 0.5em;
}
.gallery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff9fc;
  border-radius: 10px;
  box-shadow: 0 1px 6px #e88fc291;
  padding: 0.3em 0.23em 0.6em 0.23em;
  cursor: pointer;
  width: 83px;
  min-width: 62px;
  transition: box-shadow 0.12s;
}
.gallery-card:active, .gallery-card:focus {
  box-shadow: 0 3px 9px #db66b1c6;
}
.gallery-card img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 7px;
  margin-bottom: 0.3em;
}
.gallery-card span {
  font-size: 0.92em;
  color: #853e6a;
  display: block;
  max-width: 84px;
  word-break: break-word;
  white-space: normal;
  line-height: 1.1;
  margin-top: 1px;
}

@media (max-width: 600px) {
  #deck-container {
    max-width: 99vw;
    gap: 7px;
  }
  .card {
    width: 54px;
    height: 76px;
    font-size: 1.2em;
  }
  .modal-content {
    width: 96vw;
    padding: 12px 5vw;
  }
  #card-image {
    width: 72px;
    height: 72px;
  }
  /* GALLERY mobile grid */
  .gallery-preview {
    max-width: 99vw;
    padding: 0.8em 1vw;
    margin: 1.2em 0.6em 1.4em 0.6em;
  }
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 0 0.2em;
  }
  .gallery-card img {
    width: 41px;
    height: 41px;
  }
  .gallery-card span {
    font-size: 0.71em;
    max-width: 55px;
  }
  .gallery-card {
    width: 58px;
    min-width: 38px;
    padding: 0.25em 0.13em 0.4em 0.13em;
  }
}