@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=Syne:wght@400;700;800&display=swap');

/* ════════════════════════════════════════
   DESIGN TOKENS
   To change the look of the whole app, edit here.
   ════════════════════════════════════════ */
:root {
  --bg:       #0D0F1A;
  --surface:  #12152A;
  --surface2: #1A1E35;
  --gold:     #C9A84C;
  --gold-dim: #7a6530;
  --mint:     #00FFB3;
  --violet:   #7B4FFF;
  --text:     #E8E6FF;
  --muted:    #6B6E8A;
  --danger:   #FF4F6B;
}

/* ════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ════════════════════════════════════════
   PAGE ROUTER
   ════════════════════════════════════════ */
.page { display: none; min-height: 100vh; }
.page.active { display: flex; flex-direction: column; }

/* ════════════════════════════════════════
   STARS (ambient background)
   ════════════════════════════════════════ */
#stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.star {
  position: absolute; background: white; border-radius: 50%; opacity: 0;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
@keyframes twinkle {
  0%, 100% { opacity: 0; }
  50%       { opacity: var(--op, 0.4); }
}

/* ════════════════════════════════════════
   PORTAL
   ════════════════════════════════════════ */
#portal { background: radial-gradient(ellipse at 20% 50%, #1a0d2e 0%, var(--bg) 60%); }

.portal-nav {
  padding: 2rem 3rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid rgba(201,168,76,0.15);
  position: relative; z-index: 1;
}
.logo { font-family: 'Syne', sans-serif; font-size: 1.5rem; font-weight: 800; letter-spacing: 0.2em; color: var(--gold); }
.logo span { color: var(--text); }
.nav-hint { font-size: 0.75rem; color: var(--muted); letter-spacing: 0.1em; }

.portal-hero {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 4rem 2rem 2rem; text-align: center; position: relative; z-index: 1;
}
.portal-eyebrow { font-size: 0.7rem; letter-spacing: 0.35em; color: var(--mint); margin-bottom: 1.5rem; text-transform: uppercase; }
.portal-title {
  font-family: 'Syne', sans-serif; font-size: clamp(3rem, 8vw, 7rem); font-weight: 800;
  line-height: 0.9; margin-bottom: 1.5rem;
  background: linear-gradient(135deg, #fff 30%, var(--gold) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.portal-sub { font-size: 1rem; color: var(--muted); max-width: 400px; line-height: 1.7; margin-bottom: 4rem; }

.games-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem; max-width: 1000px; width: 100%; padding: 0 2rem 4rem; margin: 0 auto;
  position: relative; z-index: 1;
}

/* ── Game Cards ── */
.game-card {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px; padding: 2rem; cursor: pointer;
  transition: all 0.3s ease; position: relative; overflow: hidden;
}
.game-card::before {
  content: ''; position: absolute; inset: 0; opacity: 0;
  transition: opacity 0.3s ease; border-radius: 16px;
}
.game-card.featured { border-color: rgba(201,168,76,0.3); }
.game-card.featured::before { background: radial-gradient(ellipse at top left, rgba(201,168,76,0.08) 0%, transparent 60%); }
.game-card.featured:hover { border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 30px rgba(201,168,76,0.15); }
.game-card.featured:hover::before { opacity: 1; }
.game-card.locked { cursor: default; opacity: 0.5; }
.game-card.locked:hover { transform: none; }
.game-card.playable:not(.featured):hover { transform: translateY(-2px); border-color: rgba(123,79,255,0.4); box-shadow: 0 10px 40px rgba(0,0,0,0.3); }

.card-tag {
  display: inline-block; font-size: 0.6rem; letter-spacing: 0.2em;
  text-transform: uppercase; padding: 0.25rem 0.6rem;
  border-radius: 100px; margin-bottom: 1.2rem; font-weight: 600;
}
.tag-live { background: rgba(201,168,76,0.15); color: var(--gold); }
.tag-soon { background: rgba(107,110,138,0.2); color: var(--muted); }
.tag-new  { background: rgba(0,255,179,0.1); color: var(--mint); }

.card-icon  { font-size: 2.5rem; margin-bottom: 1rem; display: block; }
.card-title { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 700; margin-bottom: 0.5rem; }
.card-desc  { font-size: 0.85rem; color: var(--muted); line-height: 1.6; }
.card-arrow {
  position: absolute; bottom: 1.5rem; right: 1.5rem; color: var(--gold);
  font-size: 1.2rem; opacity: 0; transform: translateX(-6px); transition: all 0.2s ease;
}
.game-card.featured:hover .card-arrow,
.game-card.playable:not(.featured):hover .card-arrow { opacity: 1; transform: translateX(0); }

/* ════════════════════════════════════════
   GAME SHELL  (nav + body, shared by all games)
   ════════════════════════════════════════ */
.game-page { background: radial-gradient(ellipse at 50% 0%, #1a0d2e 0%, var(--bg) 55%); }

.game-nav {
  padding: 1.5rem 2.5rem; display: flex; align-items: center; gap: 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.06); position: relative; z-index: 1;
}
.back-btn {
  background: none; border: 1px solid rgba(255,255,255,0.1); color: var(--muted);
  padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; font-size: 0.8rem; letter-spacing: 0.05em;
  transition: all 0.2s ease;
}
.back-btn:hover { border-color: var(--gold); color: var(--gold); }
.game-nav-title { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 0.95rem; color: var(--muted); }

.game-body {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 2.5rem 1.5rem; gap: 2rem; position: relative; z-index: 1;
}

/* ════════════════════════════════════════
   SHARED UI COMPONENTS
   Used by every game module.
   ════════════════════════════════════════ */
.game-header { text-align: center; max-width: 560px; }
.phase-label { font-size: 0.65rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--mint); margin-bottom: 0.75rem; }
.instruction {
  font-family: 'Syne', sans-serif; font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 700; line-height: 1.3; min-height: 2.6em; transition: all 0.4s ease;
}

.stats-bar { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.stat-pill {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.07);
  border-radius: 100px; padding: 0.5rem 1.2rem; font-size: 0.8rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.stat-pill .lbl { color: var(--muted); }
.stat-pill .val { color: var(--text); font-weight: 600; }
.val.green  { color: var(--mint); }
.val.gold   { color: var(--gold); }
.val.violet { color: var(--violet); }

.action-area {
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem; min-height: 120px; justify-content: center;
}
.choice-btns { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }

/* Buttons */
.btn {
  padding: 0.85rem 2rem; border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.2s ease; letter-spacing: 0.03em;
}
.btn-primary   { background: var(--gold); color: #0a0c18; }
.btn-primary:hover { background: #d9b85c; transform: translateY(-1px); box-shadow: 0 8px 24px rgba(201,168,76,0.35); }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid rgba(255,255,255,0.15); }
.btn-secondary:hover { border-color: var(--violet); color: var(--violet); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,0.07); font-size: 0.8rem; padding: 0.6rem 1.4rem; }
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff6b82; transform: translateY(-1px); }

/* Result panel */
.result-panel {
  background: var(--surface); border-radius: 16px; border: 1px solid rgba(255,255,255,0.07);
  padding: 2rem 2.5rem; text-align: center; max-width: 440px; width: 100%;
  animation: slideUp 0.4s cubic-bezier(0.4,0,0.2,1) both;
}
.result-emoji  { font-size: 3rem; margin-bottom: 0.75rem; }
.result-title  { font-family: 'Syne', sans-serif; font-size: 1.4rem; font-weight: 800; margin-bottom: 0.5rem; }
.result-title.win  { color: var(--mint); }
.result-title.lose { color: var(--danger); }
.result-desc { font-size: 0.85rem; color: var(--muted); line-height: 1.7; margin-bottom: 1.5rem; }

/* Probability bars */
.prob-section {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 1.5rem 2rem; max-width: 500px; width: 100%;
}
.prob-title { font-size: 0.65rem; letter-spacing: 0.25em; text-transform: uppercase; color: var(--muted); margin-bottom: 1.2rem; }
.prob-row { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.8rem; }
.prob-row:last-child { margin-bottom: 0; }
.prob-label { font-size: 0.8rem; color: var(--muted); width: 130px; flex-shrink: 0; }
.prob-bar-track { flex: 1; height: 6px; background: rgba(255,255,255,0.06); border-radius: 100px; overflow: hidden; }
.prob-bar-fill { height: 100%; border-radius: 100px; transition: width 0.8s cubic-bezier(0.4,0,0.2,1); }
.fill-gold   { background: var(--gold); }
.fill-mint   { background: var(--mint); }
.fill-violet { background: var(--violet); }
.fill-danger { background: var(--danger); }
.prob-pct { font-size: 0.85rem; font-weight: 600; width: 40px; text-align: right; }

/* Theory box */
.theory-box {
  max-width: 580px; width: 100%;
  background: rgba(123,79,255,0.06); border: 1px solid rgba(123,79,255,0.2);
  border-radius: 12px; padding: 1.5rem;
}
.theory-box h3 { font-family: 'Syne', sans-serif; font-size: 0.9rem; color: var(--violet); margin-bottom: 0.75rem; letter-spacing: 0.05em; }
.theory-box p  { font-size: 0.82rem; color: var(--muted); line-height: 1.75; }

/* ════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════ */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes revealPop {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}
.shake  { animation: shake 0.4s ease both; }
.hidden { display: none !important; }
