/* ─── Mini-games visual polish ──────────────────────────────────
   Self-contained CSS for the three "instant action" games:
   Coinflip, Dice (Limbo), and Hi-Lo. Uses the obsidian-vault
   palette (gold + black) consistently across all three so the
   trio reads as a series.

   The corresponding JS in js/mini-games.js attaches these classes
   to the existing markup; the previous inline-styled implementation
   stays as a fallback. ───────────────────────────────────────── */


/* ═══════════════════════════════════════════════════════════════
   Shared mini-game shell
   ═══════════════════════════════════════════════════════════════ */
.mg-shell {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px 32px;
    color: #e5e2e1;
}
.mg-eyebrow {
    text-align: center;
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #99907c;
    font-weight: 700;
}
.mg-title {
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    color: var(--accent);
    letter-spacing: 0.04em;
    margin: 6px 0 4px;
    text-shadow: 0 0 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.mg-subtitle {
    text-align: center;
    font-family: var(--font-body);
    font-size: 11px;
    color: #99907c;
    margin-bottom: 20px;
}
.mg-stage {
    background:
        radial-gradient(120% 60% at 50% -10%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%),
        linear-gradient(180deg, #14110a 0%, #0a0807 100%);
    border: 1px solid rgba(212, 175, 55, 0.22);
    border-radius: 8px;
    padding: 32px 24px;
    margin-bottom: 18px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 16px 30px -8px rgba(0, 0, 0, 0.6),
                inset 0 1px 0 color-mix(in srgb, var(--accent) 10%, transparent);
}
.mg-stage::before {
    /* Top-edge gold sheen — same motif as the lottery hero pot */
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent,
        color-mix(in srgb, var(--accent) 50%, transparent) 40%,
        color-mix(in srgb, var(--accent) 50%, transparent) 60%,
        transparent);
    pointer-events: none;
}
.mg-result {
    margin-top: 14px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    min-height: 22px;
    letter-spacing: 0.03em;
    transition: color 0.2s ease;
}
.mg-result.win  { color: var(--win); text-shadow: 0 0 8px color-mix(in srgb, var(--win) 40%, transparent); }
.mg-result.lose { color: var(--loss); }


/* ═══════════════════════════════════════════════════════════════
   Coinflip — real 3D coin flip
   ═══════════════════════════════════════════════════════════════ */
.mg-coin-stage {
    /* 3D perspective so the flip reads as actual rotation in space
       rather than a 2D scale. */
    perspective: 800px;
    perspective-origin: 50% 30%;
    padding: 36px 24px;
}
.mg-coin {
    position: relative;
    width: 156px;
    height: 156px;
    margin: 0 auto;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform 1200ms cubic-bezier(0.22, 0.8, 0.26, 1);
    will-change: transform;
}
.mg-coin.is-flipping {
    /* Default landing on heads; JS sets a custom rotateY for tails. */
    transform: rotateY(1800deg);
}
.mg-coin-face {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 56px;
    color: #3c2f00;
    text-shadow:
        0 1px 0 rgba(255, 230, 160, 0.5),
        0 -1px 0 rgba(60, 30, 0, 0.4);
    background:
        radial-gradient(circle at 35% 30%,
            #fff5cf 0%,
            var(--accent) 30%,
            #d4af37 60%,
            #8a6e1c 100%);
    box-shadow:
        inset 0 0 0 6px rgba(60, 47, 0, 0.25),
        inset 0 0 0 7px rgba(255, 220, 140, 0.4),
        0 16px 40px -8px rgba(0, 0, 0, 0.7),
        0 0 28px -2px color-mix(in srgb, var(--accent) 40%, transparent);
}
.mg-coin-face::before {
    /* Engraved ring inset — gives the coin that "minted" feel */
    content: '';
    position: absolute;
    inset: 12px;
    border-radius: 50%;
    border: 1px dashed rgba(60, 47, 0, 0.35);
    pointer-events: none;
}
.mg-coin-face--tails {
    transform: rotateY(180deg);
    background:
        radial-gradient(circle at 35% 30%,
            #ffe0b3 0%,
            #d4a868 30%,
            #b08a4d 60%,
            #6b4516 100%);
}
.mg-coin-side {
    /* Thin gold rim — visible only mid-spin */
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, #d4af37, #8a6e1c);
    transform: rotateY(90deg);
    backface-visibility: hidden;
}
.mg-coin-side::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: repeating-linear-gradient(
        90deg,
        rgba(60, 47, 0, 0.2) 0,
        rgba(60, 47, 0, 0.2) 2px,
        transparent 2px,
        transparent 4px);
}

/* History dots */
.mg-cf-history {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 18px;
    min-height: 26px;
    justify-content: center;
}
.mg-cf-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    border: 1px solid;
}
.mg-cf-chip--h {
    background: color-mix(in srgb, var(--accent) 18%, transparent);
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.mg-cf-chip--t {
    background: rgba(176, 138, 77, 0.18);
    color: #d4a868;
    border-color: rgba(176, 138, 77, 0.45);
}


/* ═══════════════════════════════════════════════════════════════
   Dice (Limbo) — roll-vs-target meter
   ═══════════════════════════════════════════════════════════════ */
.mg-dice-stage {
    padding: 28px 24px;
}
.mg-dice-roll {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(48px, 12vw, 72px);
    letter-spacing: 0.01em;
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent);
    font-variant-numeric: tabular-nums;
    transition: color 0.3s ease;
    margin-bottom: 4px;
}
.mg-dice-roll.win  { color: var(--win); text-shadow: 0 0 24px color-mix(in srgb, var(--win) 50%, transparent); }
.mg-dice-roll.lose { color: var(--loss); text-shadow: 0 0 24px color-mix(in srgb, var(--loss) 40%, transparent); }
.mg-dice-roll-label {
    font-family: var(--font-body);
    font-size: 9px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 700;
    margin-bottom: 18px;
}

/* The meter — log-scaled bar from 1.00x to 100x, with target marker. */
.mg-dice-meter {
    position: relative;
    height: 12px;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    overflow: visible;
}
.mg-dice-meter-fill {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0%;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--accent) 25%, transparent),
        var(--accent) 70%,
        #fff5cf);
    border-radius: 999px;
    transition: width 600ms cubic-bezier(0.22, 0.8, 0.26, 1),
                background 0.3s ease;
    box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 50%, transparent);
}
.mg-dice-meter-fill.win  { background: linear-gradient(90deg, color-mix(in srgb, var(--win) 25%, transparent), var(--win) 70%, #d6f4e0); box-shadow: 0 0 14px color-mix(in srgb, var(--win) 50%, transparent); }
.mg-dice-meter-fill.lose { background: linear-gradient(90deg, color-mix(in srgb, var(--loss) 25%, transparent), var(--loss) 70%, #f5b89a); box-shadow: 0 0 14px color-mix(in srgb, var(--loss) 40%, transparent); }
.mg-dice-meter-target {
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: 50%;
    width: 2px;
    background: rgba(255, 255, 255, 0.65);
    transform: translateX(-1px);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
}
.mg-dice-meter-target::after {
    content: 'TARGET';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-body);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    white-space: nowrap;
}


/* ═══════════════════════════════════════════════════════════════
   Hi-Lo — proper playing cards with suits + flip animation
   ═══════════════════════════════════════════════════════════════ */
.mg-hilo-stage {
    padding: 28px 16px;
}
.mg-cards {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    perspective: 900px;
    perspective-origin: 50% 60%;
    margin-bottom: 16px;
}
.mg-card-arrow {
    font-family: var(--font-body);
    font-size: 18px;
    color: color-mix(in srgb, var(--accent) 60%, transparent);
    line-height: 1;
}
.mg-card {
    width: 84px;
    height: 118px;
    border-radius: 6px;
    background: linear-gradient(180deg, #fdf7e3 0%, #ebd9a8 100%);
    color: #1a1409;
    position: relative;
    box-shadow:
        0 12px 24px -6px rgba(0, 0, 0, 0.7),
        inset 0 0 0 1px rgba(60, 47, 0, 0.25),
        inset 0 0 0 2px rgba(212, 175, 55, 0.7);
    font-family: var(--font-display);
    font-weight: 700;
    overflow: hidden;
    transform-style: preserve-3d;
    transform: rotateY(0deg);
    transition: transform 600ms cubic-bezier(0.22, 0.8, 0.26, 1);
    flex-shrink: 0;
}
.mg-card.is-flipping { transform: rotateY(180deg); }
.mg-card-face,
.mg-card-back {
    position: absolute;
    inset: 0;
    border-radius: 6px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
}
.mg-card-back {
    transform: rotateY(180deg);
    background:
        linear-gradient(135deg,
            #1a1409 0%,
            #2a1f0c 50%,
            #1a1409 100%);
    align-items: center;
    justify-content: center;
}
.mg-card-back::before {
    /* Filigree pattern: gold diamond grid */
    content: '';
    position: absolute;
    inset: 6px;
    border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent);
    border-radius: 4px;
    background:
        repeating-linear-gradient(45deg,
            transparent 0,
            transparent 8px,
            color-mix(in srgb, var(--accent) 12%, transparent) 8px,
            color-mix(in srgb, var(--accent) 12%, transparent) 9px),
        repeating-linear-gradient(-45deg,
            transparent 0,
            transparent 8px,
            color-mix(in srgb, var(--accent) 12%, transparent) 8px,
            color-mix(in srgb, var(--accent) 12%, transparent) 9px);
}
.mg-card-back-mark {
    position: relative;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 24px;
    color: var(--accent);
    text-shadow: 0 0 8px color-mix(in srgb, var(--accent) 50%, transparent);
    z-index: 2;
}

.mg-card-rank-tl,
.mg-card-rank-br {
    position: absolute;
    font-size: 14px;
    line-height: 1;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}
.mg-card-rank-tl { top: 6px; left: 6px; }
.mg-card-rank-br {
    bottom: 6px; right: 6px;
    transform: rotate(180deg);
}
.mg-card-suit-small {
    font-size: 11px;
    line-height: 1;
}
.mg-card-suit-big {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 44px;
    line-height: 1;
}
/* Suit colours: hearts/diamonds = ruby, spades/clubs = ink */
.mg-card[data-suit="H"], .mg-card[data-suit="D"] {
    color: #9b1c2e;
}
.mg-card[data-suit="S"], .mg-card[data-suit="C"] {
    color: #1a1409;
}
.mg-card.is-locked  { opacity: 0.55; }
.mg-card.is-current { outline: 2px solid color-mix(in srgb, var(--accent) 90%, transparent); outline-offset: 2px; box-shadow:
        0 12px 24px -6px rgba(0, 0, 0, 0.7),
        0 0 22px -2px color-mix(in srgb, var(--accent) 55%, transparent),
        inset 0 0 0 1px rgba(60, 47, 0, 0.25),
        inset 0 0 0 2px rgba(212, 175, 55, 0.7); }


/* Honor reduced motion across all three games */
@media (prefers-reduced-motion: reduce) {
    .mg-coin,
    .mg-card,
    .mg-dice-meter-fill { transition: none !important; }
}
