/* ============================================================
   Mystical-Kingdom.com — title / game-select page
   ============================================================ */

:root {
  --void:        #05030f;
  --void-2:      #0d0726;
  --violet:      #2a1a5e;
  --violet-lift: #3b2585;
  --gold:        #f0c445;
  --gold-light:  #fff3c4;
  --gold-deep:   #a97a12;
  --ice:         #8de6ff;
  --parchment:   #e8dfc8;
  --muted:       #b0a3d8;

  --card-w: 400px;
  --ease-out-soft: cubic-bezier(.22, .9, .3, 1);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, Helvetica, Arial, sans-serif;
  color: var(--parchment);
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #3a1f7a 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 12% 100%, #14305c 0%, transparent 65%),
    radial-gradient(ellipse 70% 50% at 88% 90%,  #4a1d63 0%, transparent 65%),
    linear-gradient(180deg, var(--void-2) 0%, var(--void) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------- Starfield canvas ---------------- */

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

/* ---------------- Drifting embers ---------------- */

.embers {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.ember {
  position: absolute;
  bottom: -20px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-light);
  box-shadow: 0 0 8px 2px rgba(240, 196, 69, .7);
  opacity: 0;
  animation: rise linear infinite;
}

@keyframes rise {
  0%   { transform: translate3d(0, 0, 0) scale(.6);        opacity: 0; }
  10%  {                                                    opacity: .9; }
  85%  {                                                    opacity: .7; }
  100% { transform: translate3d(40px, -105vh, 0) scale(1.1); opacity: 0; }
}

/* ---------------- Layout ---------------- */

.stage {
  position: relative;
  z-index: 2;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 64px) clamp(16px, 4vw, 40px) 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* ---------------- Masthead / logo ---------------- */

.masthead {
  text-align: center;
  margin-bottom: clamp(28px, 5vw, 56px);
}

.logo {
  display: block;
  width: min(660px, 92vw);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 0 34px rgba(140, 90, 255, .45))
          drop-shadow(0 10px 24px rgba(0, 0, 0, .6));
  animation:
    logoIn 1.1s var(--ease-out-soft) both,
    hover 7s ease-in-out 1.1s infinite;
}

@keyframes logoIn {
  from { opacity: 0; transform: translateY(-28px) scale(.9); filter: blur(8px); }
  to   { opacity: 1; transform: none;                        filter: blur(0); }
}

@keyframes hover {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-9px); }
}

.tagline {
  margin: 6px 0 0;
  font-size: clamp(.95rem, 2vw, 1.2rem);
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--muted);
  animation: fadeUp .9s var(--ease-out-soft) .5s both;
}

.rune {
  color: var(--gold);
  display: inline-block;
  margin: 0 .5em;
  animation: pulseRune 3s ease-in-out infinite;
}
.rune:last-child { animation-delay: -1.5s; }

@keyframes pulseRune {
  0%, 100% { opacity: .45; transform: scale(.85) rotate(0deg); }
  50%      { opacity: 1;   transform: scale(1.15) rotate(180deg); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- Game cards ---------------- */

.games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, var(--card-w)));
  gap: clamp(22px, 4vw, 44px);
  justify-content: center;
  width: 100%;
  flex: 1;
  align-content: start;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  padding: 14px 14px 22px;
  cursor: pointer;
  isolation: isolate;
  background:
    linear-gradient(160deg, rgba(90, 60, 170, .38) 0%, rgba(20, 12, 48, .72) 55%),
    rgba(10, 6, 28, .55);
  border: 1px solid rgba(240, 196, 69, .28);
  box-shadow:
    0 18px 40px rgba(0, 0, 0, .55),
    inset 0 1px 0 rgba(255, 255, 255, .07);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  transition:
    transform .45s var(--ease-out-soft),
    box-shadow .45s var(--ease-out-soft),
    border-color .45s var(--ease-out-soft);
  animation: cardIn .8s var(--ease-out-soft) both;
}

.card:nth-child(1) { animation-delay: .75s; }
.card:nth-child(2) { animation-delay: .95s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(46px) rotateX(12deg) scale(.94); }
  to   { opacity: 1; transform: none; }
}

.card:hover,
.card:focus-visible {
  transform: translateY(-12px) scale(1.02);
  border-color: rgba(240, 196, 69, .75);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, .65),
    0 0 42px rgba(150, 100, 255, .38),
    inset 0 1px 0 rgba(255, 255, 255, .12);
  outline: none;
}

.card:focus-visible { border-color: var(--ice); }

.card:active { transform: translateY(-6px) scale(.99); }

/* soft aura that brightens on hover */
.card-glow {
  position: absolute;
  inset: -2px;
  z-index: -1;
  border-radius: 22px;
  background: conic-gradient(
    from 0deg,
    rgba(240, 196, 69, .55),
    rgba(141, 230, 255, .45),
    rgba(168, 107, 255, .55),
    rgba(240, 196, 69, .55)
  );
  opacity: 0;
  filter: blur(14px);
  transition: opacity .45s ease;
}

.card:hover .card-glow,
.card:focus-visible .card-glow {
  opacity: .85;
  animation: spinGlow 6s linear infinite;
}

@keyframes spinGlow { to { transform: rotate(360deg); } }

/* --- card artwork --- */

.card-art {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .1);
  background: #08051c;
}

.card-art img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform .6s var(--ease-out-soft);
}

.card:hover .card-art img,
.card:focus-visible .card-art img { transform: scale(1.07); }

/* shine sweep across the art on hover */
.card-art::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -70%;
  width: 45%;
  height: 200%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, .22) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-20deg);
  pointer-events: none;
}

.card:hover .card-art::after,
.card:focus-visible .card-art::after { animation: shine 1.1s ease-out; }

@keyframes shine {
  from { left: -70%; }
  to   { left: 130%; }
}

/* --- card text --- */

.card-body { padding: 18px 10px 0; }

.card-title {
  margin: 0 0 10px;
  font-family: 'Cinzel', 'Palatino Linotype', Palatino, Georgia, serif;
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  font-weight: 700;
  letter-spacing: .06em;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 18px rgba(240, 196, 69, .25);
}

.card-text {
  margin: 0 0 16px;
  font-size: .96rem;
  line-height: 1.6;
  color: var(--muted);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.card-meta li {
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 999px;
  color: #d8cdf5;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .12);
}

/* --- play button --- */

.play-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 13px 30px;
  font: inherit;
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: #2a1a05;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 50%, var(--gold-deep) 100%);
  box-shadow:
    0 8px 22px rgba(240, 196, 69, .3),
    inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: transform .25s var(--ease-out-soft), box-shadow .25s ease;
}

.play-btn:hover,
.card:hover .play-btn {
  transform: translateY(-2px);
  box-shadow:
    0 12px 30px rgba(240, 196, 69, .48),
    inset 0 1px 0 rgba(255, 255, 255, .8);
}

.play-btn:active { transform: translateY(0) scale(.97); }

.play-btn:focus-visible {
  outline: 3px solid var(--ice);
  outline-offset: 3px;
}

.play-btn-arrow {
  display: inline-block;
  transition: transform .3s var(--ease-out-soft);
}

.card:hover .play-btn-arrow,
.play-btn:hover .play-btn-arrow { transform: translateX(6px); }

/* click ripple, spawned by JS */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .55);
  transform: scale(0);
  pointer-events: none;
  animation: ripple .6s ease-out forwards;
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* ---------------- Footer ---------------- */

.footer {
  margin-top: clamp(32px, 6vw, 64px);
  font-size: .82rem;
  color: #7f74a8;
  text-align: center;
  animation: fadeUp .9s var(--ease-out-soft) 1.2s both;
}

.footer p { margin: 0; }

.footer-mark {
  color: var(--gold);
  letter-spacing: .1em;
}

kbd {
  font-family: inherit;
  font-size: .78em;
  padding: 2px 7px;
  margin: 0 1px;
  border-radius: 5px;
  color: #ddd3f7;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .16);
  border-bottom-width: 2px;
}

/* ---------------- Portal (launch transition) ---------------- */

.portal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  background: radial-gradient(circle at 50% 50%, rgba(60, 30, 130, .9) 0%, rgba(3, 2, 12, .97) 70%);
  opacity: 0;
  visibility: hidden;
  transition: opacity .5s ease, visibility .5s;
}

.portal.open {
  opacity: 1;
  visibility: visible;
}

.portal-rings {
  position: relative;
  width: 190px;
  height: 190px;
}

.portal-rings span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--gold);
  border-right-color: rgba(141, 230, 255, .8);
  animation: portalSpin 1.5s linear infinite;
}

.portal-rings span:nth-child(2) {
  inset: 26px;
  border-top-color: var(--ice);
  border-right-color: rgba(168, 107, 255, .85);
  animation-duration: 1.1s;
  animation-direction: reverse;
}

.portal-rings span:nth-child(3) {
  inset: 52px;
  border-top-color: #a86bff;
  border-right-color: rgba(240, 196, 69, .8);
  animation-duration: .8s;
}

@keyframes portalSpin { to { transform: rotate(360deg); } }

.portal-text {
  margin: 0;
  font-family: 'Cinzel', Georgia, serif;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold-light);
  text-shadow: 0 0 22px rgba(240, 196, 69, .6);
  animation: breathe 1.6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: .55; }
  50%      { opacity: 1; }
}

/* ---------------- Toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  z-index: 60;
  transform: translate(-50%, 140%);
  max-width: min(560px, 90vw);
  padding: 14px 26px;
  border-radius: 999px;
  font-size: .92rem;
  text-align: center;
  color: var(--parchment);
  background: rgba(20, 12, 48, .95);
  border: 1px solid rgba(240, 196, 69, .5);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .6), 0 0 26px rgba(150, 100, 255, .25);
  opacity: 0;
  transition: transform .5s var(--ease-out-soft), opacity .5s ease;
  pointer-events: none;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 700px) {
  .tagline { letter-spacing: .2em; }
  .card-body { padding: 16px 6px 0; }
  .play-btn { width: 100%; justify-content: center; }
}

/* ---------------- Reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }

  .logo, .tagline, .card, .footer { opacity: 1; transform: none; }
  .ember { display: none; }
}
