:root {
  --minigame-blue: #45b7ff;
  --minigame-cyan: #77e8ff;
  --minigame-deep: #06101f;
  --minigame-ink: #03070e;
}

.minigame-screen {
  position: absolute;
  z-index: 760;
  inset: 0;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 46px 16px 18px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 50% 38%, rgba(69,183,255,.2), transparent 38%),
    linear-gradient(180deg, #071a32 0%, #050a17 58%, #02050b 100%);
  isolation: isolate;
}

.minigame-screen.show { display: grid; animation: minigameLoadIn 520ms cubic-bezier(.16,1,.3,1) both; }
.minigame-screen.unloading { animation: minigameUnload 430ms cubic-bezier(.55,0,1,.45) both; pointer-events: none; }
.minigame-grid { position: absolute; z-index: -1; inset: 0; opacity: .2; background-image: linear-gradient(rgba(72,188,255,.2) 1px, transparent 1px), linear-gradient(90deg, rgba(72,188,255,.16) 1px, transparent 1px); background-size: 24px 24px; animation: minigameGridDrift 8s linear infinite; }
.minigame-screen::before { content: ''; position: absolute; z-index: -1; inset: -20%; border: 3px solid rgba(72,188,255,.22); border-radius: 50%; box-shadow: 0 0 80px rgba(69,183,255,.22), inset 0 0 80px rgba(69,183,255,.14); animation: minigameRadar 5s linear infinite; }

.minigame-header { min-height: 88px; display: grid; justify-items: center; align-content: center; gap: 4px; text-align: center; }
.minigame-header p { margin: 0; color: var(--minigame-cyan); font: 1000 9px/1 var(--mono); }
.minigame-header h2 { margin: 0; color: #fff; font: 1000 37px/.9 var(--font); text-shadow: 5px 5px 0 #000, 0 0 24px rgba(69,183,255,.8); }
.minigame-header > span { padding: 5px 10px; border: 2px solid #05080d; border-radius: 999px; color: #06101f; background: var(--minigame-blue); box-shadow: 3px 3px 0 #000, 0 0 14px rgba(69,183,255,.7); font: 1000 9px/1 var(--mono); }

.minigame-stage { position: relative; min-height: 0; display: grid; place-items: center; }
.minigame-message { min-height: 64px; display: grid; place-content: center; gap: 5px; padding: 8px 12px; border: 2px solid rgba(69,183,255,.62); border-radius: 6px; color: #fff; background: rgba(4,12,25,.9); box-shadow: 5px 5px 0 #000, inset 0 0 18px rgba(69,183,255,.1); text-align: center; }
.minigame-message strong { color: var(--minigame-cyan); font: 1000 13px/1 var(--mono); }
.minigame-message span { color: #dcefff; font: 800 10px/1.25 var(--mono); }
.minigame-primary { min-height: 58px; min-width: 210px; padding: 0 28px; border: 3px solid #02060d; border-radius: 999px; color: #04101d; background: var(--minigame-blue); box-shadow: 6px 6px 0 #000, 0 0 25px rgba(69,183,255,.65); font: 1000 20px/1 var(--mono); touch-action: manipulation; }
.minigame-primary:active { transform: translateY(2px); box-shadow: 3px 3px 0 #000, 0 0 18px rgba(69,183,255,.55); }
.minigame-primary:disabled { filter: grayscale(.5) brightness(.65); }

.minigame-loader { position: absolute; z-index: 20; inset: 0; display: none; place-content: center; justify-items: center; gap: 18px; background: #031020; }
.minigame-screen.loading .minigame-loader { display: grid; }
.minigame-screen.loading .minigame-header,
.minigame-screen.loading .minigame-stage,
.minigame-screen.loading .minigame-message { opacity: 0; }
.minigame-loader strong { color: var(--minigame-cyan); font: 1000 14px/1 var(--mono); text-shadow: 0 0 14px var(--minigame-blue); }
.minigame-loader > span { width: 250px; height: 14px; padding: 3px; border: 2px solid var(--minigame-blue); border-radius: 999px; background: #02070f; box-shadow: 0 0 20px rgba(69,183,255,.5); }
.minigame-loader > span i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #258dff, #7aeeff); transform-origin: left; animation: minigameLoadBar 850ms cubic-bezier(.2,.75,.3,1) both; }
.minigame-loader-mark { width: 92px; height: 92px; position: relative; display: grid; place-items: center; }
.minigame-loader-mark i { position: absolute; width: 58px; height: 58px; border: 5px solid transparent; border-top-color: var(--minigame-blue); border-radius: 50%; animation: minigameSpinner 1s linear infinite; }
.minigame-loader-mark i:nth-child(2) { width: 78px; height: 78px; border-top-color: var(--minigame-cyan); animation-direction: reverse; animation-duration: 1.45s; }
.minigame-loader-mark i:nth-child(3) { width: 24px; height: 24px; border: 0; background: #fff; box-shadow: 0 0 24px var(--minigame-cyan); animation: minigameCore 650ms ease-in-out infinite; }

.memory-game { width: 100%; height: 100%; min-height: 330px; display: grid; place-items: center; }
.memory-table { position: relative; width: 100%; max-width: 350px; height: 300px; border-bottom: 8px solid #173d5f; background: radial-gradient(ellipse at 50% 88%, rgba(69,183,255,.17), transparent 60%); }
.memory-cup { position: absolute; z-index: 3; left: var(--cup-left); bottom: 20px; width: 88px; height: 122px; padding: 0; border: 0; color: #fff; background: transparent; transform: translateX(-50%); transition: left var(--swap-duration, 380ms) cubic-bezier(.18,.78,.2,1), transform 240ms cubic-bezier(.16,1.35,.3,1), filter 180ms ease; touch-action: manipulation; }
.memory-cup i { position: absolute; inset: 5px 8px 9px; border: 4px solid #02101d; border-radius: 28px 28px 13px 13px; background: linear-gradient(100deg, #167cd2, #8ceeff 42%, #2a9de9 60%, #0c61ae); box-shadow: 6px 8px 0 #000, inset 0 0 16px rgba(255,255,255,.24), 0 0 18px rgba(69,183,255,.35); clip-path: polygon(12% 0, 88% 0, 100% 100%, 0 100%); }
.memory-cup b { position: absolute; z-index: 2; inset: 48px 0 auto; color: #02101d; font: 1000 22px/1 var(--mono); text-shadow: 1px 1px 0 rgba(255,255,255,.45); }
.memory-ball { position: absolute; z-index: 2; left: var(--ball-left); bottom: 18px; width: 34px; height: 34px; border: 4px solid #02060c; border-radius: 50%; background: #ffd766; box-shadow: 3px 4px 0 #000, 0 0 24px #ffd766; transform: translateX(-50%) scale(.2); opacity: 0; transition: left var(--swap-duration, 380ms) cubic-bezier(.18,.78,.2,1), opacity 150ms ease, transform 220ms cubic-bezier(.16,1.4,.3,1); }
.memory-game.showing-ball .memory-ball,
.memory-game.resolved .memory-ball { opacity: 1; transform: translateX(-50%) scale(1); }
.memory-game.showing-ball .memory-cup { transform: translateX(-50%) translateY(-62px) rotate(-4deg); }
.memory-game.guessing .memory-cup { cursor: pointer; animation: cupGuess 1.4s ease-in-out infinite; }
.memory-game.guessing .memory-cup:nth-of-type(2) { animation-delay: 120ms; }
.memory-game.guessing .memory-cup:nth-of-type(3) { animation-delay: 240ms; }
.memory-game.resolved .memory-cup.target { transform: translateX(-50%) translateY(-68px) rotate(7deg); filter: brightness(1.35) drop-shadow(0 0 18px #ffd766); }
.memory-game.resolved .memory-cup.chosen:not(.target) { filter: grayscale(.7) brightness(.58); }

.slot-game { width: 100%; display: grid; place-items: center; gap: 30px; }
.slot-machine-frame { position: relative; width: 330px; max-width: 100%; padding: 26px 18px; border: 5px solid #02060c; border-radius: 8px; background: linear-gradient(145deg, #278ed6, #8beaff 46%, #1664a5 47%, #082a50); box-shadow: 10px 12px 0 #000, 0 0 36px rgba(69,183,255,.65), inset 0 0 26px rgba(255,255,255,.24); }
.slot-reels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 9px; border: 4px solid #02060c; border-radius: 6px; background: #02050a; }
.slot-reel { height: 120px; display: grid; place-items: center; overflow: hidden; border: 3px solid #06111e; border-radius: 4px; color: #06203a; background: linear-gradient(#dff9ff, #80dfff); box-shadow: inset 0 0 22px rgba(15,79,127,.45); font: 1000 34px/1 var(--mono); }
.slot-reel.rolling { animation: slotReelShake 110ms linear infinite; filter: blur(1px) brightness(1.15); }
.slot-reel.landed { animation: slotLand 420ms cubic-bezier(.16,1.5,.3,1) both; }
.slot-payline { position: absolute; right: 12px; left: 12px; top: 50%; height: 3px; background: #ff3159; box-shadow: 0 0 12px #ff3159; transform: translateY(-50%); pointer-events: none; }

.sequence-game { width: 100%; display: grid; gap: 30px; align-content: center; }
.sequence-tries { display: flex; justify-content: center; gap: 10px; }
.sequence-try { width: 18px; height: 18px; border: 3px solid #02060c; border-radius: 50%; background: var(--minigame-cyan); box-shadow: 2px 2px 0 #000, 0 0 12px var(--minigame-blue); transition: background 180ms ease, filter 180ms ease, transform 180ms ease; }
.sequence-try.spent { background: #ff3159; filter: grayscale(.6) brightness(.7); transform: scale(.74); }
.sequence-readout { min-height: 116px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 5px; padding: 14px 10px; border: 4px solid var(--minigame-blue); border-radius: 7px; background: rgba(2,8,18,.92); box-shadow: 7px 7px 0 #000, 0 0 24px rgba(69,183,255,.35); }
.sequence-readout b { min-width: 33px; color: #fff; font: 1000 28px/1 var(--mono); text-align: center; }
.sequence-readout b.missing { color: #07101d; background: var(--minigame-cyan); box-shadow: 3px 3px 0 #000, 0 0 16px var(--minigame-blue); }
.sequence-readout span { color: #4481ad; font: 1000 20px/1 var(--mono); }
.sequence-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.sequence-options button { min-height: 66px; border: 3px solid var(--minigame-blue); border-radius: 6px; color: #fff; background: #071426; box-shadow: 5px 5px 0 #000, inset 0 0 15px rgba(69,183,255,.1); font: 1000 24px/1 var(--mono); touch-action: manipulation; }
.sequence-options button:active { transform: translateY(2px); }
.sequence-options button.wrong { border-color: #ff3159; color: #ff8fa2; background: #280711; animation: sequenceWrong 440ms ease both; }
.sequence-options button.correct { border-color: #6af2c2; color: #04120d; background: #6af2c2; box-shadow: 5px 5px 0 #000, 0 0 24px #6af2c2; animation: sequenceCorrect 560ms cubic-bezier(.16,1.4,.3,1) both; }
.sequence-options button:disabled:not(.correct):not(.wrong) { opacity: .38; }

.simon-game { width: 100%; display: grid; align-content: center; gap: 34px; }
.simon-progress { display: flex; justify-content: center; gap: 7px; }
.simon-progress i { width: 27px; height: 8px; border: 2px solid #04101b; border-radius: 999px; background: #1d405c; box-shadow: 2px 2px 0 #000; transition: background 160ms ease, box-shadow 160ms ease; }
.simon-progress i.complete { background: #78ecff; box-shadow: 2px 2px 0 #000, 0 0 12px #78ecff; }
.simon-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.simon-buttons button { aspect-ratio: 1; display: grid; place-items: center; padding: 0; border: 5px solid #02060c; border-radius: 50%; color: #06101d; background: var(--simon-color); box-shadow: 7px 8px 0 #000, inset 0 0 24px rgba(255,255,255,.25), 0 0 18px color-mix(in srgb, var(--simon-color) 46%, transparent); filter: brightness(.58) saturate(.72); transform: scale(.94); transition: transform 100ms ease, filter 100ms ease, box-shadow 100ms ease; touch-action: manipulation; }
.simon-buttons button[data-suit="♥"] { --simon-color: #ff3159; }
.simon-buttons button[data-suit="♦"] { --simon-color: #5a76ff; }
.simon-buttons button[data-suit="♣"] { --simon-color: #7ddd62; }
.simon-buttons button[data-suit="♠"] { --simon-color: #d7d3cb; }
.simon-buttons button span { font: 1000 48px/1 var(--font); text-shadow: 2px 2px 0 rgba(255,255,255,.25); }
.simon-buttons button.lit,
.simon-buttons button:active:not(:disabled) { filter: brightness(1.35) saturate(1.2); transform: scale(1.08); box-shadow: 7px 8px 0 #000, 0 0 42px var(--simon-color), inset 0 0 28px rgba(255,255,255,.5); }
.simon-buttons button.wrong { --simon-color: #ff3159; animation: simonWrong 460ms ease both; }
.simon-buttons button:disabled { pointer-events: none; }

.minigame-outcome { position: absolute; z-index: 30; inset: 0; display: none; place-content: center; justify-items: center; gap: 10px; padding: 30px 22px; overflow: hidden; color: #fff; background: rgba(2,6,14,.94); text-align: center; }
.minigame-outcome.show { display: grid; animation: minigameOutcomeIn 420ms cubic-bezier(.16,1,.3,1) both; }
.minigame-outcome::before { content: ''; position: absolute; z-index: -1; inset: 15% -30%; background: radial-gradient(ellipse, color-mix(in srgb, var(--outcome-color) 36%, transparent), transparent 66%); animation: outcomeGlow 1.1s ease-in-out infinite; }
.minigame-outcome.victory { --outcome-color: #45b7ff; }
.minigame-outcome.failed { --outcome-color: #ff3159; }
.minigame-outcome > p { margin: 0; color: var(--outcome-color); font: 1000 12px/1 var(--mono); }
.minigame-outcome > h2 { margin: 0; color: #fff; font: 1000 68px/.82 var(--font); text-shadow: 8px 8px 0 #000, 0 0 32px var(--outcome-color); }
.minigame-outcome > span { max-width: 300px; color: #dfeeff; font: 900 13px/1.3 var(--mono); }
.minigame-outcome > button { width: min(300px, 100%); min-height: 64px; margin-top: 18px; border: 4px solid #02050a; border-radius: 7px; color: #030911; background: var(--outcome-color); box-shadow: 7px 7px 0 #000, 0 0 25px var(--outcome-color); font: 1000 16px/1 var(--mono); }
.minigame-confetti,
.reward-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.minigame-confetti i,
.reward-confetti i { position: absolute; top: -8%; left: var(--mini-confetti-x, var(--confetti-x)); width: 9px; height: 16px; background: var(--mini-confetti-color, var(--confetti-color)); box-shadow: 0 0 8px var(--mini-confetti-color, var(--confetti-color)); animation: minigameConfetti 2.4s var(--mini-confetti-delay, var(--confetti-delay)) cubic-bezier(.2,.72,.3,1) infinite; }

.reward-reveal { position: absolute; z-index: 900; inset: 0; display: none; grid-template-rows: auto auto auto auto auto; place-content: center; justify-items: center; gap: 10px; padding: 28px 24px; overflow: hidden; color: #fff; background: rgba(2,3,8,.98); text-align: center; isolation: isolate; --reward-accent: #ffd766; }
.reward-reveal.show { display: grid; animation: rewardScreenIn 360ms ease-out both; }
.reward-reveal.leaving { animation: rewardScreenOut 380ms ease-in both; pointer-events: none; }
.reward-reveal.reward-chips { --reward-accent: #63f0ce; }
.reward-reveal.reward-glass { --reward-accent: #ffef7c; }
.reward-reveal.reward-crew { --reward-accent: #ff78c6; }
.reward-reveal.reward-spike { --reward-accent: #ff9f43; }
.reward-reveal.reward-cypher { --reward-accent: #bd7cff; }
.reward-reveal.reward-heat { --reward-accent: #55ddff; }
.reward-reveal.reward-damage { --reward-accent: #ff5a67; }
.reward-reveal::before { content: ''; position: absolute; z-index: -1; inset: -35%; background: conic-gradient(from 0deg, transparent, color-mix(in srgb, var(--reward-accent) 18%, transparent), transparent 18%, transparent 50%, color-mix(in srgb, var(--reward-accent) 18%, transparent), transparent 68%); animation: rewardRays 9s linear infinite; opacity: 0; transition: opacity 250ms ease; }
.reward-reveal.revealed::before { opacity: 1; }
.reward-reveal > p { margin: 0; color: var(--reward-accent); font: 1000 11px/1 var(--mono); }
.reward-icon { width: 142px; height: 142px; display: grid; place-items: center; border: 6px solid #05060a; border-radius: 18px; color: #05060a; background: var(--reward-accent); box-shadow: 10px 12px 0 #000, 0 0 60px var(--reward-accent), inset 0 0 30px rgba(255,255,255,.35); font: 1000 62px/1 var(--mono); transform: scale(.15) rotate(-18deg); filter: brightness(.15); }
.reward-reveal.mystery .reward-icon { color: transparent; background: #0d1018; box-shadow: 10px 12px 0 #000, 0 0 24px rgba(255,255,255,.12); animation: rewardMystery 650ms ease-in-out infinite; }
.reward-reveal.flare .reward-icon { animation: rewardFlare 560ms ease-out both; }
.reward-reveal.revealed .reward-icon { transform: scale(1) rotate(0); filter: brightness(1); animation: rewardIconBreathe 1.6s ease-in-out infinite; }
.reward-reveal > h2 { max-width: 340px; margin: 4px 0 0; color: var(--reward-accent); font: 1000 45px/.88 var(--font); text-shadow: 6px 6px 0 #000, 0 0 25px var(--reward-accent); opacity: 0; transform: translateY(18px); }
.reward-reveal > span { color: #fff; font: 1000 11px/1.2 var(--mono); opacity: 0; }
.reward-reveal > button { width: min(300px, 100%); min-height: 64px; margin-top: 18px; border: 4px solid #05060a; border-radius: 7px; color: #05060a; background: var(--reward-accent); box-shadow: 7px 7px 0 #000, 0 0 22px var(--reward-accent); font: 1000 19px/1 var(--mono); opacity: 0; transform: translateY(18px); }
.reward-reveal.revealed > h2,
.reward-reveal.revealed > span,
.reward-reveal.revealed > button { opacity: 1; transform: translateY(0); transition: opacity 320ms ease, transform 420ms cubic-bezier(.16,1.25,.3,1); }
.reward-reveal > button:disabled { pointer-events: none; }
.reward-reveal.claimed > span { color: var(--reward-accent); font-size: 14px; text-shadow: 0 0 14px var(--reward-accent); animation: rewardReceiptIn 420ms cubic-bezier(.16,1.25,.3,1) both; }
.reward-reveal.claimed > button { color: #fff; background: transparent; border-color: var(--reward-accent); box-shadow: 0 0 24px var(--reward-accent); }
.reward-scan { position: absolute; z-index: -1; inset: 0; opacity: .15; background: repeating-linear-gradient(180deg, transparent 0 7px, var(--reward-accent) 7px 8px); animation: rewardScan 4s linear infinite; }

@keyframes minigameLoadIn { from { opacity: 0; transform: scale(1.08); filter: brightness(2.2); } to { opacity: 1; transform: scale(1); filter: brightness(1); } }
@keyframes minigameUnload { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.94); filter: brightness(1.8); } }
@keyframes minigameLoadBar { from { transform: scaleX(.04); } to { transform: scaleX(1); } }
@keyframes minigameSpinner { to { transform: rotate(360deg); } }
@keyframes minigameCore { 0%, 100% { transform: scale(.72) rotate(45deg); } 50% { transform: scale(1.08) rotate(45deg); } }
@keyframes minigameGridDrift { to { background-position: 0 48px, 48px 0; } }
@keyframes minigameRadar { to { transform: rotate(360deg); } }
@keyframes cupGuess { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes slotReelShake { 0%, 100% { transform: translateY(-4px); } 50% { transform: translateY(5px); } }
@keyframes slotLand { 0% { transform: translateY(-22px) scale(.86); filter: brightness(2); } 65% { transform: translateY(5px) scale(1.08); } 100% { transform: translateY(0) scale(1); filter: brightness(1); } }
@keyframes sequenceWrong { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 55% { transform: translateX(7px); } 78% { transform: translateX(-3px); } }
@keyframes sequenceCorrect { 0% { transform: scale(1); } 55% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes simonWrong { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-9px); } 55% { transform: translateX(8px); } 78% { transform: translateX(-4px); } }
@keyframes minigameOutcomeIn { from { opacity: 0; transform: scale(1.12); filter: brightness(2); } to { opacity: 1; transform: scale(1); filter: brightness(1); } }
@keyframes outcomeGlow { 0%, 100% { opacity: .55; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.08); } }
@keyframes minigameConfetti { 0% { opacity: 0; transform: translate3d(0,-20px,0) rotate(0); } 12% { opacity: 1; } 100% { opacity: 0; transform: translate3d(var(--mini-confetti-drift, var(--confetti-drift)),900px,0) rotate(620deg); } }
@keyframes rewardScreenIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rewardScreenOut { from { opacity: 1; } to { opacity: 0; transform: scale(.95); } }
@keyframes rewardMystery { 0%, 100% { transform: scale(.72) rotate(-7deg); filter: brightness(.16); } 50% { transform: scale(.78) rotate(7deg); filter: brightness(.3); } }
@keyframes rewardFlare { 0% { transform: scale(.65); filter: brightness(.2); } 42% { transform: scale(1.25); filter: brightness(7); box-shadow: 0 0 140px #fff, 0 0 220px var(--reward-accent); } 100% { transform: scale(1); filter: brightness(1); } }
@keyframes rewardIconBreathe { 0%, 100% { transform: scale(.98); } 50% { transform: scale(1.04); } }
@keyframes rewardReceiptIn { from { opacity: 0; transform: translateY(12px) scale(.92); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes rewardRays { to { transform: rotate(360deg); } }
@keyframes rewardScan { to { background-position-y: 80px; } }

@media (max-height: 760px) {
  .minigame-screen { padding-top: 34px; gap: 6px; }
  .minigame-header { min-height: 68px; }
  .minigame-header h2 { font-size: 31px; }
  .memory-game { min-height: 270px; }
  .memory-table { height: 250px; }
  .slot-reel { height: 98px; }
  .sequence-game,
  .simon-game { gap: 20px; }
  .minigame-outcome > h2 { font-size: 58px; }
  .reward-icon { width: 120px; height: 120px; }
}

@media (prefers-reduced-motion: reduce) {
  .minigame-screen.show,
  .minigame-screen.unloading,
  .minigame-grid,
  .minigame-screen::before,
  .minigame-loader > span i,
  .minigame-loader-mark i,
  .memory-game.guessing .memory-cup,
  .slot-reel.rolling,
  .slot-reel.landed,
  .sequence-options button.wrong,
  .sequence-options button.correct,
  .simon-buttons button.wrong,
  .minigame-outcome.show,
  .minigame-outcome::before,
  .minigame-confetti i,
  .reward-reveal.show,
  .reward-reveal.leaving,
  .reward-reveal::before,
  .reward-reveal.claimed > span,
  .reward-icon,
  .reward-confetti i,
  .reward-scan { animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
