/* ============================================================
   WILD CARD
   ============================================================ */

@font-face {
  font-family: "Barlow Medium";
  src: url("assets/fonts/Barlow-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Round palettes: bg = full-bleed background, card = card face */
  --r1-bg: #df712a;   --r1-card: #efa93c;   /* Round 1 Memories  — Orange */
  --r2-bg: #3f7cc2;   --r2-card: #2c57cf;   /* Round 2 Insights  — Blue   */
  --r3-bg: #e76f5b;   --r3-card: #ec5e50;   /* Round 3 Beliefs   — Red    */
  --rF-bg: #5a43b0;   --rF-card: #7c5ce0;   /* Final             — Purple */

  --cream: #f4ead4;
  --title-bg: #1b1f2a;

  /* Active round colors, swapped by [data-round] */
  --bg: var(--title-bg);
  --card: var(--r1-card);

  /* Card geometry — vertical playing card, ~0.64 aspect */
  --card-w: clamp(150px, 23vw, 230px);
  --card-radius: clamp(14px, 2vw, 22px);

  --ease-card: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: fixed;
  inset: 0;
  background: var(--bg);
  transition: background-color 0.7s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Round-to-color mapping */
#app[data-round="title"] { --bg: var(--title-bg); }
#app[data-round="select"] { --bg: var(--title-bg); }
#app[data-round="1"] { --bg: var(--r1-bg); --card: var(--r1-card); }
#app[data-round="2"] { --bg: var(--r2-bg); --card: var(--r2-card); }
#app[data-round="3"] { --bg: var(--r3-bg); --card: var(--r3-card); }
#app[data-round="final"] { --bg: var(--rF-bg); --card: var(--rF-card); }

/* ---------- Screens ---------- */
.screen { display: none; width: 100%; height: 100%; }
.screen.is-active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* ---------- Title ---------- */
.title-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(36px, 7vh, 80px);
  animation: fadeUp 0.8s var(--ease-card) both;
}
.title-logo {
  width: clamp(260px, 46vw, 560px);
  height: auto;
  filter: drop-shadow(0 12px 30px rgba(0,0,0,0.35));
}

.btn {
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  user-select: none;
  transition: transform 0.18s var(--ease-card), box-shadow 0.18s ease, background 0.2s ease;
}
.btn:active { transform: translateY(2px) scale(0.98); }

.btn-start {
  background: var(--cream);
  color: var(--title-bg);
  font-size: clamp(18px, 2.4vw, 24px);
  padding: 18px 52px;
  box-shadow: 0 10px 0 rgba(0,0,0,0.22), 0 14px 30px rgba(0,0,0,0.3);
}
.btn-start:active { box-shadow: 0 4px 0 rgba(0,0,0,0.22), 0 8px 18px rgba(0,0,0,0.3); }

/* ---------- Round select ---------- */
.rounds-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(12px, 2vh, 20px);
  animation: fadeUp 0.6s var(--ease-card) both;
}
.rounds-title {
  color: var(--cream);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 800;
  letter-spacing: 0.2em;
  margin: 0 0 clamp(8px, 1.6vh, 18px);
}
.btn-round {
  width: min(80vw, 420px);
  padding: clamp(13px, 1.8vh, 18px) 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #fff;
  border-radius: clamp(16px, 2vw, 22px);
  box-shadow: 0 7px 0 rgba(0,0,0,0.25), 0 12px 26px rgba(0,0,0,0.3);
}
.btn-round:active { box-shadow: 0 3px 0 rgba(0,0,0,0.25), 0 6px 16px rgba(0,0,0,0.3); }
.btn-round .round-kicker {
  font-size: clamp(11px, 1.2vw, 13px);
  letter-spacing: 0.24em;
  opacity: 0.85;
}
.btn-round .round-name {
  font-size: clamp(18px, 2.2vw, 24px);
  letter-spacing: 0.1em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.btn-round-1 { background: var(--r1-card); }
.btn-round-2 { background: var(--r2-card); }
.btn-round-3 { background: var(--r3-card); }
.btn-round-final { background: var(--rF-card); }
@media (hover: hover) {
  .btn-round:hover { transform: translateY(-3px); }
}
.rounds-back {
  margin-top: clamp(10px, 2vh, 20px);
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(244,234,212,0.55);
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(12px, 1.3vw, 14px);
  letter-spacing: 0.16em;
}
.rounds-back:hover { color: rgba(244,234,212,0.85); }

/* ---------- Game / hand ---------- */
#game.is-active { justify-content: center; gap: clamp(28px, 5vh, 64px); }

.hand {
  position: relative;
  width: min(92vw, 760px);
  height: calc(var(--card-w) / 0.64 + 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1400px;
}

/* ---------- Card ---------- */
.card {
  position: absolute;
  width: var(--card-w);
  aspect-ratio: 0.64;
  border-radius: var(--card-radius);
  transform-style: preserve-3d;
  transition:
    transform 0.62s var(--ease-card),
    box-shadow 0.4s ease;
  cursor: pointer;
  will-change: transform;
}
.card.dealing { transition: transform 0.62s var(--ease-card), box-shadow 0.4s ease, opacity 0.4s ease; }

.card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--ease-card);
}
.card.flipped .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 18px 36px rgba(0,0,0,0.28);
}

/* Back — colored, logo centered */
.card-back {
  background: var(--card-color, var(--card));
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-back img {
  width: 74%;
  height: auto;
  pointer-events: none;
}

/* Front — question text */
.card-front {
  transform: rotateY(180deg);
  background: var(--card-color, var(--card));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 2.4vw, 26px);
}
.card-front .q {
  color: #fff;
  font-family: "Barlow Medium", "Avenir Next", system-ui, sans-serif;
  font-weight: 500;
  font-size: clamp(16px, 2vw, 23px);
  line-height: 1.32;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

/* Position number above each card */
.card .pos-num {
  position: absolute;
  top: -46px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--cream);
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 800;
  opacity: 0.92;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Hover lift on un-revealed cards (desktop) */
@media (hover: hover) {
  .hand.selectable .card:not(.revealed):hover {
    transform: translate(var(--tx), calc(var(--ty) - 16px)) rotate(var(--rot)) !important;
  }
}

/* The revealed card sits on top, centered, others tuck behind */
.hand.has-reveal .pos-num { opacity: 0; }

.card.revealed {
  z-index: 30;
  cursor: pointer;
  box-shadow: 0 30px 60px rgba(0,0,0,0.4);
}
.card.tucked { filter: brightness(0.82); }

/* Final purple single card — a touch larger, it's the closer */
.card.final-card {
  --card-color: var(--rF-card);
  width: clamp(196px, 30vw, 300px);
}
.card.final-card .card-front { padding: clamp(20px, 3vw, 34px); }
.card.final-card .card-front .q { font-size: clamp(15px, 1.7vw, 21px); line-height: 1.4; }
.final-back {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 3vh, 26px);
  padding: 10%;
  text-align: center;
}
.final-back img { width: 64%; height: auto; }
.final-label {
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: clamp(13px, 1.7vw, 19px);
  line-height: 1.3;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* ---------- Actions ---------- */
.actions {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-skip {
  background: rgba(255,255,255,0.16);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.6);
  font-size: clamp(15px, 1.7vw, 19px);
  padding: 13px 44px;
  backdrop-filter: blur(2px);
  animation: fadeUp 0.4s var(--ease-card) both;
}
.btn-skip:hover { background: rgba(255,255,255,0.26); }

.menu {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  animation: fadeUp 0.4s var(--ease-card) both;
}
.btn-menu {
  background: var(--cream);
  color: #2a2a2a;
  font-size: clamp(14px, 1.6vw, 18px);
  padding: 15px 34px;
  box-shadow: 0 7px 0 rgba(0,0,0,0.18), 0 10px 22px rgba(0,0,0,0.22);
}
.btn-menu:active { box-shadow: 0 3px 0 rgba(0,0,0,0.18); }
.btn-menu-alt {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: none;
}
.btn-menu-alt:hover { background: rgba(255,255,255,0.28); }

/* ---------- Misc ---------- */
.load-error {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  max-width: 90vw;
  text-align: center;
}

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

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}
