/* Game House — the page where the family picks a game */

@font-face { font-family: 'Vazirmatn'; src: url('../fonts/vazirmatn.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face {
  font-family: 'Lalezar'; src: url('../fonts/lalezar-arabic.woff2') format('woff2'); font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: 'Lalezar'; src: url('../fonts/lalezar-latin.woff2') format('woff2'); font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-200B, U+2010-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Lalezar'; src: url('../fonts/lalezar-latin-ext.woff2') format('woff2'); font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --font: 'Vazirmatn', Tahoma, system-ui, sans-serif;
  --title: 'Lalezar', 'Vazirmatn', Tahoma, sans-serif;
  --emoji: 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif;
  --bg1: #120a33; --bg2: #2a1660; --bg3: #0d3a5c;
}
* { box-sizing: border-box; }
html { background: var(--bg1); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); color: #fff; overflow-x: hidden;
  display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #ffd84d; outline-offset: 3px; }
.grow { flex: 1; }
[dir="rtl"] .flip { display: inline-block; transform: scaleX(-1); }

/* ---------- sky ---------- */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: radial-gradient(1200px 800px at 50% 120%, var(--bg3), transparent 60%), linear-gradient(170deg, var(--bg2) 0%, var(--bg1) 70%); }
.glow { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; animation: glowMove 18s ease-in-out infinite alternate; }
.g1 { width: 46vmax; height: 46vmax; background: #ff4f9a; top: -16vmax; left: -12vmax; }
.g2 { width: 40vmax; height: 40vmax; background: #ff9a1c; bottom: -18vmax; right: -10vmax; animation-delay: -6s; opacity: .4; }
.g3 { width: 34vmax; height: 34vmax; background: #1fc9a8; top: 30%; right: 30%; animation-delay: -11s; opacity: .28; }
@keyframes glowMove { from { transform: translate(0, 0) scale(1); } to { transform: translate(6vmax, 4vmax) scale(1.15); } }
.stars i { position: absolute; width: var(--s); height: var(--s); border-radius: 50%; background: #fff; opacity: .2; animation: twinkle var(--d) ease-in-out infinite; animation-delay: var(--dl); }
@keyframes twinkle { 0%, 100% { opacity: .15; transform: scale(.7); } 50% { opacity: .95; transform: scale(1.2); } }
.floaters span { position: absolute; bottom: -10vh; font-family: var(--emoji); font-size: var(--s); opacity: .22; animation: drift var(--d) linear infinite; animation-delay: var(--dl); }
@keyframes drift { from { transform: translateY(0) rotate(0deg); } to { transform: translateY(-125vh) rotate(var(--rot)); } }

/* ---------- top bar ---------- */
.top { position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px 4px; }
.lang { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.lang button { border: 0; background: transparent; color: #fff; cursor: pointer; font-weight: 800; font-size: 15px; padding: 7px 14px; border-radius: 999px; }
.lang button[aria-pressed="true"] { background: #fff; color: #2a1660; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; font-family: var(--emoji); font-size: 20px;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.icon-btn.off { opacity: .55; }

main { position: relative; z-index: 1; flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 18px; }

/* ---------- title ---------- */
.hero { text-align: center; padding: 6px 0 22px; position: relative; }
.title {
  margin: 0; font-family: var(--title); font-weight: 400; line-height: 1.1; font-size: clamp(54px, 12vw, 112px);
  background: linear-gradient(180deg, #fff 30%, #ffe08a 70%, #ffb347); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 5px 0 #4a1d8a) drop-shadow(0 14px 24px rgba(0, 0, 0, .45));
  animation: titleIn .9s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes titleIn { from { transform: scale(.5) rotate(-4deg); opacity: 0; } to { transform: none; opacity: 1; } }
.sub { margin: 6px 0 0; font-size: clamp(16px, 3.8vw, 21px); font-weight: 700; opacity: .92; animation: fadeUp .8s .25s both; }
@keyframes fadeUp { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.hero-dice { position: absolute; inset: 0; pointer-events: none; }
.hdie { position: absolute; width: 46px; height: 46px; border-radius: 12px; background: linear-gradient(145deg, #fff, #dcd6ca); box-shadow: 0 8px 18px rgba(0, 0, 0, .35);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 8px; }
.hdie i { width: 8px; height: 8px; border-radius: 50%; background: #1d1d24; place-self: center; }
.hdie.d1 { top: 18%; inset-inline-start: max(2%, calc(50% - 360px)); animation: bob 3.2s ease-in-out infinite; transform: rotate(-14deg); }
.hdie.d1 i:nth-child(1) { grid-area: 1 / 1; } .hdie.d1 i:nth-child(2) { grid-area: 1 / 3; } .hdie.d1 i:nth-child(3) { grid-area: 2 / 1; }
.hdie.d1 i:nth-child(4) { grid-area: 2 / 3; } .hdie.d1 i:nth-child(5) { grid-area: 3 / 1; } .hdie.d1 i:nth-child(6) { grid-area: 3 / 3; }
.hdie.d2 { top: 46%; inset-inline-end: max(2%, calc(50% - 370px)); animation: bob 3.6s -1.4s ease-in-out infinite; transform: rotate(12deg); }
.hdie.d2 i { background: #e2465c; }
.hdie.d2 i:nth-child(1) { grid-area: 1 / 1; } .hdie.d2 i:nth-child(2) { grid-area: 1 / 3; } .hdie.d2 i:nth-child(3) { grid-area: 2 / 2; }
.hdie.d2 i:nth-child(4) { grid-area: 3 / 1; } .hdie.d2 i:nth-child(5) { grid-area: 3 / 3; }
@keyframes bob { 0%, 100% { translate: 0 0; rotate: 0deg; } 50% { translate: 0 -14px; rotate: 18deg; } }

/* ---------- game cards ---------- */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px; perspective: 1200px; }
.game { display: block; text-decoration: none; color: #fff; border-radius: 34px; animation: cardIn .8s cubic-bezier(.2, 1.2, .4, 1) both; }
.game.maar { animation-delay: .15s; }
@keyframes cardIn { from { transform: translateY(60px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.card {
  position: relative; display: flex; flex-direction: column; height: 100%; border-radius: 34px; overflow: hidden; isolation: isolate;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px)); transform-style: preserve-3d;
  transition: transform .25s ease-out, box-shadow .25s; will-change: transform;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .45), inset 0 0 0 2px rgba(255, 255, 255, .22);
}
.ludo .card { background: radial-gradient(120% 90% at 50% 0%, #ffcf6b 0%, transparent 55%), linear-gradient(150deg, #ff8f3a, #e8413c 55%, #9c1f4f); }
.maar .card { background: radial-gradient(120% 90% at 50% 0%, #c9f27a 0%, transparent 55%), linear-gradient(150deg, #5fbf4a, #1b7a49 55%, #0b3d3a); }
.game:hover .card, .game:focus-visible .card { --lift: -8px; box-shadow: 0 30px 70px rgba(0, 0, 0, .55), inset 0 0 0 3px rgba(255, 255, 255, .45); }
.art { display: block; padding: 18px 18px 0; }
.art svg { display: block; width: 100%; height: auto; max-height: 250px; filter: drop-shadow(0 16px 18px rgba(0, 0, 0, .35)); overflow: visible; }
.info { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 6px 20px 24px; margin-top: auto; }
.name { font-family: var(--title); font-size: clamp(36px, 5vw, 54px); line-height: 1.1; text-shadow: 0 4px 0 rgba(0, 0, 0, .25), 0 10px 20px rgba(0, 0, 0, .25); }
.desc { font-size: 16.5px; font-weight: 700; line-height: 1.6; opacity: .95; max-width: 34ch; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.chips > span { font-family: var(--emoji); font-size: 14px; padding: 5px 11px; border-radius: 99px; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .28); }
.chips b { font-family: var(--font); font-weight: 800; }
.play {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 10px; padding: 14px 34px; border-radius: 99px; font-size: 22px;
  background: #fff; color: #2a1660; box-shadow: 0 6px 0 rgba(0, 0, 0, .25), 0 12px 24px rgba(0, 0, 0, .25); transition: transform .15s;
}
.play b { font-weight: 900; }
.ludo .play { color: #b8261f; }
.maar .play { color: #1b6a2a; }
.game:hover .play { transform: scale(1.06); }
.game:active .play { transform: translateY(3px) scale(1.02); box-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.shine { position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .35) 45%, transparent 60%); background-size: 250% 100%; background-position: 130% 0; }
.game:hover .shine { animation: shine 1.1s ease-out; }
@keyframes shine { to { background-position: -40% 0; } }
.badge { position: absolute; top: 16px; inset-inline-start: 16px; z-index: 3; padding: 6px 14px; border-radius: 99px; font-weight: 900; font-size: 14px;
  background: #ffd84d; color: #5a3b00; box-shadow: 0 4px 12px rgba(0, 0, 0, .3); animation: badge 2.2s ease-in-out infinite; }
@keyframes badge { 0%, 100% { rotate: -6deg; } 50% { rotate: 6deg; scale: 1.08; } }

/* moving bits in the pictures */
.pawn { animation: pawnHop 2.4s ease-in-out infinite; }
.pawn.p2 { animation-delay: -.6s; } .pawn.p3 { animation-delay: -1.2s; } .pawn.p4 { animation-delay: -1.8s; }
@keyframes pawnHop { 0%, 60%, 100% { translate: 0 0; } 70% { translate: 0 -16px; } 80% { translate: 0 0; } 86% { translate: 0 -5px; } }
.adie { animation: dieRoll 3.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes dieRoll { 0%, 40%, 100% { rotate: 0deg; translate: 0 0; } 55% { rotate: 200deg; translate: -6px -18px; } 70% { rotate: 360deg; translate: 0 0; } }
.head { animation: headBob 2.4s ease-in-out infinite; transform-box: fill-box; }
@keyframes headBob { 0%, 100% { translate: 0 0; } 50% { translate: 2px -5px; } }
.tongue { animation: tongue 2.4s ease-in-out infinite; }
@keyframes tongue { 0%, 70%, 100% { opacity: 0; } 76%, 90% { opacity: 1; } }

/* the die decides */
.game.chosen .card { animation: chosen .9s cubic-bezier(.2, 1.4, .4, 1); box-shadow: 0 0 0 6px #ffd84d, 0 0 60px 10px rgba(255, 216, 77, .6), 0 30px 70px rgba(0, 0, 0, .55); }
.game.dim { opacity: .55; filter: saturate(.6); transition: opacity .4s, filter .4s; }
@keyframes chosen { 0% { transform: scale(.94); } 50% { transform: scale(1.05) rotate(-1deg); } 100% { transform: scale(1); } }

/* ---------- decide ---------- */
.decide { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 0 10px; }
.decide-btn {
  display: inline-flex; align-items: center; gap: 16px; padding: 12px 26px 12px 16px; border-radius: 99px; cursor: pointer; border: 2px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .12); color: #fff; font-weight: 900; font-size: 19px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); transition: transform .12s, background .2s;
}
[dir="rtl"] .decide-btn { padding: 12px 16px 12px 26px; }
.decide-btn:hover { background: rgba(255, 255, 255, .2); }
.decide-btn:active { transform: scale(.97); }
.decide-btn:disabled { cursor: default; }
.cube-wrap { width: 46px; height: 46px; perspective: 400px; flex: none; }
.cube { position: relative; display: block; width: 100%; height: 100%; transform-style: preserve-3d; transform: rotateX(-20deg) rotateY(25deg); transition: transform 1.4s cubic-bezier(.15, .8, .25, 1.05); }
.face { position: absolute; inset: 0; border-radius: 10px; background: linear-gradient(145deg, #fff, #ddd6c8); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1);
  display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 7px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face i { width: 7px; height: 7px; border-radius: 50%; background: #1d1d24; place-self: center; }
.f1 i { background: #e2465c; width: 10px; height: 10px; grid-area: 2 / 2; }
.f2 i:nth-child(1) { grid-area: 1 / 1; } .f2 i:nth-child(2) { grid-area: 3 / 3; }
.f3 i:nth-child(1) { grid-area: 1 / 1; } .f3 i:nth-child(2) { grid-area: 2 / 2; } .f3 i:nth-child(3) { grid-area: 3 / 3; }
.f4 i:nth-child(1) { grid-area: 1 / 1; } .f4 i:nth-child(2) { grid-area: 1 / 3; } .f4 i:nth-child(3) { grid-area: 3 / 1; } .f4 i:nth-child(4) { grid-area: 3 / 3; }
.f5 i:nth-child(1) { grid-area: 1 / 1; } .f5 i:nth-child(2) { grid-area: 1 / 3; } .f5 i:nth-child(3) { grid-area: 2 / 2; } .f5 i:nth-child(4) { grid-area: 3 / 1; } .f5 i:nth-child(5) { grid-area: 3 / 3; }
.f6 i:nth-child(1) { grid-area: 1 / 1; } .f6 i:nth-child(2) { grid-area: 1 / 3; } .f6 i:nth-child(3) { grid-area: 2 / 1; } .f6 i:nth-child(4) { grid-area: 2 / 3; } .f6 i:nth-child(5) { grid-area: 3 / 1; } .f6 i:nth-child(6) { grid-area: 3 / 3; }
.f1 { transform: translateZ(23px); }
.f6 { transform: rotateY(180deg) translateZ(23px); }
.f3 { transform: rotateY(90deg) translateZ(23px); }
.f4 { transform: rotateY(-90deg) translateZ(23px); }
.f2 { transform: rotateX(90deg) translateZ(23px); }
.f5 { transform: rotateX(-90deg) translateZ(23px); }
.decide-btn.rolling .cube-wrap { animation: hop 1.4s ease-out; }
@keyframes hop { 0% { translate: 0 0; } 20% { translate: 0 -36px; } 45% { translate: 0 0; } 60% { translate: 0 -12px; } 75% { translate: 0 0; } 85% { translate: 0 -4px; } 100% { translate: 0 0; } }
.verdict { min-height: 1.6em; margin: 4px 0 0; font-family: var(--title); font-size: clamp(22px, 5vw, 32px); text-align: center; text-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.verdict.show { animation: titleIn .6s cubic-bezier(.2, 1.4, .4, 1) both; }

.foot { position: relative; z-index: 1; text-align: center; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); font-size: 13.5px; opacity: .7; }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 2px; background: var(--c); animation: fall var(--d) cubic-bezier(.25, .5, .4, 1) forwards; }
@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }

/* ---------- small screens ---------- */
@media (max-width: 760px) {
  .cards { grid-template-columns: 1fr; gap: 20px; }
  .art svg { max-height: 200px; }
  .hdie { width: 36px; height: 36px; padding: 6px; border-radius: 10px; }
  .hdie i { width: 6px; height: 6px; }
  .hdie.d1 { top: 2%; } .hdie.d2 { top: 6%; }
  .play { padding: 12px 30px; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .glow, .stars i, .floaters span, .pawn, .adie, .head, .tongue, .hdie, .badge { animation: none !important; }
}
