/* ============================================================================================
   SCENE — the living home screen, the lit card table, and how cards are held.
   Loaded after royal.css (the look) and before motion.css (which can switch all movement off).
   Only opacity and translate / rotate / scale move here, so it stays smooth on phones.
   ============================================================================================ */

/* ---------------------------------------------------------------- HOME: a living scene -------- */
/* Soft beams of sunlight turning slowly over the cards. */
.home-scene .fx-rays {
  position: absolute; left: 50%; top: -70%; width: 110%; aspect-ratio: 1; translate: -50% 0;
  background: repeating-conic-gradient(from 0deg, rgba(255, 252, 228, 0) 0deg 7deg, rgba(255, 252, 228, 0.26) 9.5deg 12.5deg, rgba(255, 252, 228, 0) 15deg 22deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 72%); mask-image: radial-gradient(closest-side, #000 30%, transparent 72%);
  mix-blend-mode: screen; animation: raysTurn 60s linear infinite;
}
@keyframes raysTurn { to { rotate: 360deg; } }

/* Playing cards drifting through the sky. */
.home-scene .fx-drift {
  position: absolute; left: var(--x); top: var(--y); width: calc(var(--cqw) * 2.5); aspect-ratio: 2 / 3;
  background: #fff center / cover no-repeat; border-radius: calc(var(--cqw) * 0.28);
  box-shadow: 0 calc(var(--cqw) * 0.5) calc(var(--cqw) * 0.9) rgba(10, 40, 70, 0.35); rotate: var(--r);
  animation: cardDrift var(--t) ease-in-out var(--d) infinite;
}
@keyframes cardDrift {
  0%, 100% { translate: 0 0; rotate: var(--r); }
  25% { translate: calc(var(--cqw) * 1.4) calc(var(--cqw) * -1.3); rotate: calc(var(--r) + 14deg); }
  50% { translate: calc(var(--cqw) * 0.3) calc(var(--cqw) * -2.4); rotate: calc(var(--r) - 8deg); }
  75% { translate: calc(var(--cqw) * -1.3) calc(var(--cqw) * -1.1); rotate: calc(var(--r) + 9deg); }
}

/* Golden sparkles rising from the deck. */
.home-scene .fx-mote {
  position: absolute; left: var(--x); bottom: -3%; width: calc(var(--cqw) * 0.55); aspect-ratio: 1; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, #fff 0 22%, rgba(255, 238, 160, 0.95) 38%, rgba(255, 214, 110, 0) 70%);
  animation: moteRise var(--t) linear var(--d) infinite;
}
@keyframes moteRise {
  0% { translate: 0 0; scale: 0.5; opacity: 0; }
  12% { opacity: 1; }
  50% { translate: calc(var(--cqw) * 1.4) calc(var(--cqw) * -13); scale: 1; }
  85% { opacity: 0.85; }
  100% { translate: calc(var(--cqw) * -0.8) calc(var(--cqw) * -26); scale: 0.7; opacity: 0; }
}

/* ---------------------------------------------------------------- HOME: the mode cards -------- */
/* Pressing (or hovering) a card tilts it towards your finger, with a glare that follows. */
.home-scene .mode-card {
  transform: perspective(900px) rotateX(calc(var(--ty, 0) * -14deg)) rotateY(calc(var(--tx, 0) * 16deg));
  transition: transform 0.5s var(--ease-out, ease-out), scale 0.2s var(--spring, ease-out);
}
.home-scene .mode-card.tilting { transition-duration: 0.09s, 0.2s; }
.mode-card > .mc-glare {
  position: absolute; inset: 0; z-index: 3; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(circle at calc(50% + var(--tx, 0) * 120%) calc(50% + var(--ty, 0) * 120%), rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%);
  mix-blend-mode: overlay;
}
.mode-card.tilting > .mc-glare { opacity: 1; }

/* The main call to action breathes, and every arrow nudges you towards it. */
#quickPlayBtn .mode-action { animation: ctaGlow 2.2s ease-in-out infinite; }
@keyframes ctaGlow {
  50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85), 0 4px 0 #9b570d, 0 6px 12px rgba(0, 0, 0, 0.3), 0 0 0 calc(var(--cqw) * 0.4) rgba(255, 240, 150, 0.45), 0 0 calc(var(--cqw) * 2.2) rgba(255, 214, 90, 0.85); }
}
.mode-action b { display: inline-block; animation: arrowNudge 1.6s ease-in-out infinite; }
@keyframes arrowNudge { 50% { translate: calc(var(--cqw) * 0.35) 0; } }

/* Classic: a real hand of cards fanning open and closed behind the UNO PLAY plate. */
.classic-visual::before { content: none; }
.classic-visual::after { left: 22%; top: 50%; width: 56%; height: 46%; font-size: clamp(8px, calc(var(--cqw) * 1.05), 13px); rotate: -8deg; z-index: 2; }
.mc-fan { position: absolute; inset: 0; }
.mc-fan i {
  position: absolute; left: 50%; bottom: 8%; height: 88%; aspect-ratio: 2 / 3; translate: -50% 0; transform-origin: 50% 92%;
  background: #fff center / cover no-repeat; border-radius: 12%; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  rotate: calc((var(--k) - 1.5) * 13deg); animation: fanBreathe 3.6s ease-in-out infinite;
}
.mc-fan i:nth-child(1) { --k: 0; }
.mc-fan i:nth-child(2) { --k: 1; }
.mc-fan i:nth-child(3) { --k: 2; }
.mc-fan i:nth-child(4) { --k: 3; }
@keyframes fanBreathe { 50% { rotate: calc((var(--k) - 1.5) * 24deg); } }

/* Go Wild: the color wheel spins, with sparkles orbiting it. */
/* Always a true circle (the picture's box is wide in the portrait layout). */
.wild-visual::before { left: 50%; top: 5%; width: auto; height: 90%; aspect-ratio: 1; translate: -50% 0; animation: wheelSpin 10s linear infinite; }
@keyframes wheelSpin { from { rotate: -14deg; } to { rotate: 346deg; } }
.mc-orbit { position: absolute; left: 50%; top: 5%; height: 90%; aspect-ratio: 1; translate: -50% 0; animation: wheelSpin 4.5s linear infinite reverse; }
@media (orientation: portrait) and (max-width: 800px) {
  .home-scene .wild-visual::before, .home-scene .mc-orbit { top: 12%; height: 76%; }
}
.mc-orbit i { position: absolute; inset: 0; }
.mc-orbit i:nth-child(2) { rotate: 120deg; }
.mc-orbit i:nth-child(3) { rotate: 240deg; }
.mc-orbit i::before {
  content: ''; position: absolute; left: 50%; top: -9%; width: 17%; aspect-ratio: 1; translate: -50% 0; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 26%, rgba(255, 249, 200, 0.9) 40%, rgba(255, 255, 255, 0) 70%);
  animation: sparkleBeat 1.2s ease-in-out infinite;
}
.mc-orbit i:nth-child(2)::before { animation-delay: -0.4s; }
.mc-orbit i:nth-child(3)::before { animation-delay: -0.8s; }
@keyframes sparkleBeat { 50% { scale: 0.45; opacity: 0.6; } }

/* Friends: the players bob while chat bubbles pop up. */
.friends-visual::after { animation: friendsBob 2.6s ease-in-out infinite; }
@keyframes friendsBob { 50% { translate: 0 calc(var(--cqw) * -0.35); } }
.mc-bubble {
  position: absolute; right: 2%; top: -14%; z-index: 2; font-size: calc(var(--cqw) * 2); line-height: 1; opacity: 0;
  transform-origin: 0 100%; animation: bubblePop 4.4s ease-in-out infinite;
}
.mc-bubble.b2 { right: auto; left: 2%; top: 26%; transform-origin: 100% 100%; animation-delay: 2.2s; }
@keyframes bubblePop {
  0%, 10% { scale: 0; opacity: 0; }
  18% { scale: 1.2; opacity: 1; }
  24%, 62% { scale: 1; opacity: 1; }
  72%, 100% { scale: 0; opacity: 0; }
}
@media (orientation: portrait) and (max-width: 800px) {
  .home-scene .classic-visual::after { font-size: 9px; }
  .home-scene .mc-bubble { font-size: 15px; }
}

/* ---------------------------------------------------------------- THE TABLE -------------------- */
/* Bulbs all around the rim (placed by app.js). They chase slowly, and run gold when it's your turn. */
.rim-lights { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; pointer-events: none; overflow: visible; filter: drop-shadow(0 0 2px rgba(255, 214, 110, 0.9)) drop-shadow(0 0 6px rgba(255, 196, 70, 0.55)); }
.rim-lights rect { fill: none; stroke-linecap: round; }
.rim-lights .bulbs { stroke: rgba(255, 240, 200, 0.7); stroke-width: 6; }
.rim-lights .lit { stroke: #fffbe6; stroke-width: 8; animation: bulbChase 2.4s steps(3) infinite; }
@keyframes bulbChase { to { stroke-dashoffset: var(--chase, -6); } }
.my-turn .rim-lights .lit { stroke: #ffe46b; stroke-width: 9; animation-duration: 0.7s; }
.my-turn .rim-lights { filter: drop-shadow(0 0 3px rgba(255, 220, 90, 1)) drop-shadow(0 0 12px rgba(255, 186, 30, 0.8)); }

/* A slow sheen of light gliding across the felt. */
.felt-sheen { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; z-index: 0; }
.felt-sheen::before {
  content: ''; position: absolute; top: -30%; bottom: -30%; left: 0; width: 28%; rotate: 16deg; translate: -160% 0;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 240, 0.09) 40%, rgba(255, 255, 240, 0.16) 50%, rgba(255, 255, 240, 0.09) 60%, rgba(255, 255, 255, 0));
  animation: feltSheen 12s ease-in-out infinite;
}
@keyframes feltSheen { 0%, 50% { translate: -160% 0; } 100% { translate: 470% 0; } }

/* The player on turn sits in a pool of warm light. */
.seat.opp .ring-wrap::before {
  content: ''; position: absolute; inset: -65%; border-radius: 50%; pointer-events: none; z-index: -1; opacity: 0;
  background: radial-gradient(circle, rgba(255, 230, 130, 0.6), rgba(255, 200, 61, 0) 66%); transition: opacity 0.35s;
}
.seat.opp.turn .ring-wrap::before { opacity: 1; animation: seatGlow 1.6s ease-in-out infinite; }
@keyframes seatGlow { 50% { scale: 1.18; opacity: 0.7; } }

/* ---------------------------------------------------------------- HOLDING CARDS --------------- */
/* Opponents hold a real fan of cards, tilted towards the middle of the table; it grows and shrinks
   card by card (app.js keeps the cards and animates them). */
.seat .mini-fan { width: 48px; height: 30px; rotate: 14deg; transform-origin: 20% 100%; }
.seat.flip .mini-fan { rotate: -14deg; transform-origin: 80% 100%; }
.seat .mini-fan img {
  width: 16px; height: 24px; border-radius: 2px; transform-origin: 50% 115%;
  transition: transform 0.4s var(--spring-soft, ease-out), opacity 0.3s;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.55));
}
.seat.last-one .mini-fan img { filter: drop-shadow(0 0 4px #ff4d4d) drop-shadow(0 1px 1px rgba(0, 0, 0, 0.6)); }

/* My hand: a soft shadow under the cards grounds them on the table. */
.hand::before {
  content: ''; position: absolute; left: -6%; right: -6%; bottom: -8%; height: 55%; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 60% 100% at 50% 100%, rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0) 70%);
}
/* New cards are placed straight at their spot; only cards already held slide when the hand re-fans. */
.hand .card.settling { transition: none !important; }
/* On my turn the cards I can play ripple, one after another. */
.my-turn .hand .card.playable:not(.dealt):not(.incoming):not(.picked) {
  animation: playableWave 2.8s ease-in-out infinite; animation-delay: calc(var(--k, 0) * 0.14s);
}
@keyframes playableWave { 0%, 55%, 100% { translate: 0 0; } 25% { translate: 0 -7px; } }
/* Tapped: the card lifts out of the hand; a card that can't be played gives a little shake. */
.hand .card.picked { translate: 0 -22px; scale: 1.07; z-index: 60 !important; }
.hand .card.nope { animation: cardNope 0.42s ease-in-out; }
@keyframes cardNope { 20% { translate: -6px 0; } 40% { translate: 5px 0; } 60% { translate: -4px 0; } 80% { translate: 2px 0; } }

/* ---------------------------------------------------------------- DAILY REWARD ---------------- */
/* A treasure-chest feel: deep violet with gold trim and a sunburst turning behind the title. */
#dailyModal .daily-box {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(ellipse 80% 55% at 50% 0%, rgba(255, 214, 90, 0.3), rgba(255, 214, 90, 0) 70%), linear-gradient(170deg, #3d1f80 0%, #26115a 55%, #170b3a 100%);
  border: 2px solid rgba(255, 214, 120, 0.8);
  box-shadow: 0 0 0 4px rgba(90, 50, 170, 0.45), 0 24px 60px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
#dailyModal .daily-box::before {
  content: ''; position: absolute; left: 50%; top: -150px; width: 380px; aspect-ratio: 1; translate: -50% 0; border-radius: 50%; pointer-events: none;
  background: repeating-conic-gradient(rgba(255, 226, 122, 0.16) 0deg 9deg, rgba(255, 226, 122, 0) 9deg 18deg);
  -webkit-mask-image: radial-gradient(closest-side, #000 35%, transparent); mask-image: radial-gradient(closest-side, #000 35%, transparent);
  animation: raysTurn 40s linear infinite;
}
#dailyModal .daily-box > * { position: relative; }
#dailyModal .daily-box h2 {
  font-family: 'Arial Black', Roboto, sans-serif; font-size: 1.55rem; font-weight: 900; color: #ffe27a; letter-spacing: 0.02em;
  text-shadow: 0 3px 0 #a3480a, 0 6px 14px rgba(0, 0, 0, 0.55);
}
#dailyModal .daily-gift { display: inline-block; animation: giftWobble 1.6s ease-in-out infinite; }
#dailyModal #dailySub { color: #e3d8ff; }
#dailyModal .daily-days li:not(.today) { background: linear-gradient(180deg, #4a7bea, #2c4fb8); box-shadow: 0 3px 0 #1d3480, inset 0 1px 0 rgba(255, 255, 255, 0.3); }
#dailyModal #dailyClose { color: #cbbcf5; }

/* ---------------------------------------------------------------- MESSAGES FROM UNO PLAY ------ */
/* A gold ribbon that slides down from the top (announcements, messages and gifts from an admin). */
.announce {
  position: fixed; z-index: 70; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; translate: -50% 0;
  max-width: min(560px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px;
  border-radius: 16px; border: 2px solid #fff2b5; color: #3b2400; font-weight: 800; font-size: 0.92rem; line-height: 1.3;
  background: linear-gradient(180deg, #ffe47a, #f5b21e); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 4px rgba(255, 214, 90, 0.25);
  animation: announceIn 0.55s var(--spring, ease-out) backwards;
}
.announce.gift { background: linear-gradient(180deg, #ffe9a3, #ffc83d); }
.announce.out { animation: announceOut 0.38s var(--ease-in, ease-in) forwards; }
.announce-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: rgba(59, 36, 0, 0.12); color: #3b2400; font-weight: 900; cursor: pointer; }
@keyframes announceIn { from { opacity: 0; translate: -50% -140%; scale: 0.9; } }
@keyframes announceOut { to { opacity: 0; translate: -50% -140%; } }

/* ---------------------------------------------------------------- HOME: glass mode cards ---- */
/* Tinted frosted glass over the scenery: the island shows through, blurred; a bright rim, a glossy
   top and a soft glow in each card's own color. */
.home-scene .mode-card {
  border: calc(var(--cqw) * 0.14) solid rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(12px) saturate(1.45); backdrop-filter: blur(12px) saturate(1.45);
  box-shadow:
    0 calc(var(--cqw) * 1.1) calc(var(--cqw) * 2.8) rgba(6, 19, 35, 0.42),
    0 0 calc(var(--cqw) * 2.4) var(--glass-glow, rgba(255, 255, 255, 0.2)),
    inset 0 calc(var(--cqw) * 0.12) 0 rgba(255, 255, 255, 0.75),
    inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.home-scene .mode-classic {
  --glass-glow: rgba(255, 92, 92, 0.38);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.36) 0%, rgba(255, 255, 255, 0.1) 30%, rgba(255, 255, 255, 0) 52%),
    linear-gradient(155deg, rgba(255, 94, 88, 0.66), rgba(206, 31, 54, 0.6) 55%, rgba(120, 20, 50, 0.68));
}
.home-scene .mode-wild {
  --glass-glow: rgba(160, 110, 255, 0.4);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.1) 30%, rgba(255, 255, 255, 0) 52%),
    linear-gradient(155deg, rgba(130, 80, 210, 0.64), rgba(88, 42, 160, 0.58) 55%, rgba(46, 27, 96, 0.68));
}
.home-scene .mode-friends {
  --glass-glow: rgba(60, 210, 220, 0.38);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.34) 0%, rgba(255, 255, 255, 0.1) 30%, rgba(255, 255, 255, 0) 52%),
    linear-gradient(155deg, rgba(36, 170, 188, 0.62), rgba(24, 110, 150, 0.56) 56%, rgba(20, 62, 100, 0.66));
}
/* Text stays crisp on glass. */
.home-scene .mode-name { text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45), 0 4px 12px rgba(0, 0, 0, 0.45); }
.home-scene .mode-detail { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85); }
