/* ════════════════════════════════════════════════════════
   TITLE SCREEN — Enhanced styles
   ════════════════════════════════════════════════════════ */

/* Background canvas — sits behind everything on title */
#title-bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* Override base title-screen to be transparent over the canvas */
#title-screen {
  background: transparent !important;
  z-index: 10;
  position: relative;
  padding: 2rem;
}

/* ── Title text ── */
#title-screen h1 {
  font-size: clamp(1.8rem, 6vw, 4rem);
  letter-spacing: 0.4em;
  color: #d4a438;
  text-transform: uppercase;
  text-shadow:
    0 0 10px rgba(212,164,56,0.8),
    0 0 30px rgba(212,164,56,0.5),
    0 0 60px rgba(212,164,56,0.3),
    0 0 100px rgba(212,164,56,0.15),
    0 2px 4px rgba(0,0,0,0.8);
  animation: titlePulse 4s ease-in-out infinite, titleAppear 2s ease-out;
  position: relative;
  -webkit-text-stroke: 0.5px rgba(255,200,100,0.3);
}

@keyframes titlePulse {
  0%, 100% {
    text-shadow:
      0 0 10px rgba(212,164,56,0.8),
      0 0 30px rgba(212,164,56,0.5),
      0 0 60px rgba(212,164,56,0.3),
      0 0 100px rgba(212,164,56,0.15),
      0 2px 4px rgba(0,0,0,0.8);
    filter: brightness(1);
  }
  50% {
    text-shadow:
      0 0 15px rgba(212,164,56,1),
      0 0 40px rgba(212,164,56,0.7),
      0 0 80px rgba(212,164,56,0.4),
      0 0 120px rgba(212,164,56,0.2),
      0 2px 4px rgba(0,0,0,0.8);
    filter: brightness(1.15);
  }
}

@keyframes titleAppear {
  0% {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    letter-spacing: 0.8em;
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    letter-spacing: 0.4em;
  }
}

/* ── Subtitle ── */
#title-screen .subtitle {
  color: #8a7a6a;
  letter-spacing: 0.3em;
  font-size: clamp(0.6rem, 1.5vw, 0.85rem);
  visibility: hidden; /* JS typewriter will make visible */
  min-height: 1.2em;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}

/* ── Decorative line under title ── */
#title-screen h1::after {
  content: '';
  display: block;
  width: 60%;
  max-width: 300px;
  height: 1px;
  margin: 0.8rem auto 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(212,164,56,0.6) 20%,
    rgba(212,164,56,0.8) 50%,
    rgba(212,164,56,0.6) 80%,
    transparent 100%);
  animation: lineGlow 4s ease-in-out infinite;
}

@keyframes lineGlow {
  0%, 100% { opacity: 0.5; width: 55%; }
  50% { opacity: 1; width: 65%; }
}

/* ── Class cards — polished ── */
.class-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  max-width: 600px;
  animation: cardsAppear 1.5s ease-out 0.8s both;
}

@keyframes cardsAppear {
  0% { opacity: 0; transform: translateY(30px); }
  100% { opacity: 1; transform: translateY(0); }
}

.class-card {
  background: rgba(18, 18, 30, 0.85);
  border: 1px solid rgba(42, 42, 74, 0.6);
  border-radius: 6px;
  padding: 1.2rem 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}

/* Shimmer on hover */
.class-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center,
    rgba(212,164,56,0.05) 0%,
    transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.class-card:hover::before {
  opacity: 1;
}

/* Top accent line */
.class-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  width: 80%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(212,164,56,0.4), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}
.class-card:hover::after {
  opacity: 1;
}

.class-card:hover {
  border-color: rgba(212,164,56,0.6);
  background: rgba(26, 26, 46, 0.9);
  transform: translateY(-4px) scale(1.02);
  box-shadow:
    0 8px 30px rgba(212,164,56,0.15),
    0 0 15px rgba(212,164,56,0.1),
    inset 0 0 20px rgba(212,164,56,0.03);
}

.class-card:active {
  transform: translateY(-1px) scale(0.98);
  transition: transform 0.1s;
}

.class-card .icon {
  font-size: 2.2rem;
  margin-bottom: 0.6rem;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.5));
  transition: transform 0.3s;
}

.class-card:hover .icon {
  transform: scale(1.15);
}

.class-card .name {
  color: #d4a438;
  font-weight: bold;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
  text-shadow: 0 0 10px rgba(212,164,56,0.3);
}

.class-card .desc {
  font-size: 0.65rem;
  color: #6a5a4a;
  margin-top: 0.4rem;
  line-height: 1.5;
}

/* ── Save banner — refined ── */
#save-banner {
  background: rgba(18, 18, 30, 0.85);
  border: 1px solid rgba(212, 164, 56, 0.2);
  border-radius: 6px;
  padding: 1rem 1.5rem;
  text-align: center;
  backdrop-filter: blur(8px);
  animation: cardsAppear 1.5s ease-out 0.5s both;
}

.save-btn {
  background: rgba(26, 26, 46, 0.8);
  border: 1px solid rgba(212, 164, 56, 0.3);
  border-radius: 4px;
  padding: 0.5rem 1.2rem;
  color: #d4a438;
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
}

.save-btn:hover {
  background: rgba(40, 40, 64, 0.9);
  border-color: #d4a438;
  box-shadow: 0 0 15px rgba(212,164,56,0.15);
}

/* ── Class select area ── */
#class-select-area {
  animation: cardsAppear 1.5s ease-out 0.8s both;
}

#class-select-area > div:first-child {
  color: #6a5a4a;
  font-size: 0.75rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  margin-bottom: 0.5rem;
  letter-spacing: 0.15em;
}

/* ── Control hint ── */
#control-hint {
  color: #3a3a5a !important;
  font-size: 0.6rem !important;
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  animation: cardsAppear 1.5s ease-out 1.2s both;
  letter-spacing: 0.08em;
}

/* ── Version tag ── */
#title-version {
  position: absolute;
  bottom: 1rem;
  right: 1.5rem;
  color: rgba(100, 90, 74, 0.4);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  z-index: 11;
}

/* ── Music toggle on title screen ── */
#title-mute-btn {
  position: absolute;
  bottom: 1rem;
  left: 1.5rem;
  background: rgba(18, 18, 30, 0.6);
  border: 1px solid rgba(42, 42, 74, 0.4);
  border-radius: 4px;
  color: #6a5a4a;
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 11;
  font-family: inherit;
}

#title-mute-btn:hover {
  border-color: rgba(212,164,56,0.4);
  color: #d4a438;
}

/* ── Mobile adjustments ── */
@media (max-width: 600px) {
  #title-screen {
    gap: 1.2rem;
    padding: 1rem;
  }

  #title-screen h1 {
    font-size: clamp(1.4rem, 8vw, 2.5rem);
    letter-spacing: 0.25em;
  }

  .class-grid {
    grid-template-columns: 1fr;
    max-width: 280px;
    gap: 0.7rem;
  }

  .class-card {
    padding: 0.8rem;
  }

  .class-card .icon {
    font-size: 1.6rem;
  }
}

@media (max-width: 400px) {
  #title-screen h1 {
    font-size: 1.3rem;
    letter-spacing: 0.2em;
  }
}
