.mini-game-page {
    --mini-bg: linear-gradient(135deg, #fff8ec, #ffe0c2);
}

.memory-page {
    --mini-bg: linear-gradient(135deg, #fff8ec, #ffe0c2);
}

.piano-page {
    --mini-bg: linear-gradient(135deg, #102c38, #1e4f63);
}

.reaction-page {
    --mini-bg: linear-gradient(135deg, #071c33, #0b3b66);
}

.mini-stage {
    background: var(--mini-bg, linear-gradient(135deg, #fff8ec, #ffe0c2));
    cursor: pointer;
}

.theme-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 58px;
    padding: 7px 6px;
    border: 2px solid rgba(139, 117, 104, 0.16);
    border-radius: 14px;
    background: #fff;
    color: var(--game-ink);
    font-size: 0.72rem;
    font-weight: 800;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.theme-btn:hover {
    transform: translateY(-1px);
}

.theme-btn.is-active {
    border-color: var(--game-accent);
    background: var(--game-accent-soft);
}

.theme-dots {
    display: flex;
    gap: 3px;
}

.theme-dots i,
.memory-theme-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(0, 0, 0, 0.14);
    border-radius: 50%;
}

.theme-emoji-preview {
    font-size: 1.05rem;
    line-height: 1;
}

/* Memory match */
.memory-board {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    width: min(88%, 620px, 70vh);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
}

.memory-card {
    position: relative;
    padding: 0;
    border: 0;
    background: transparent;
    perspective: 700px;
    cursor: pointer;
}

.memory-card-inner {
    position: absolute;
    inset: 0;
    transition: transform 0.35s ease;
    transform-style: preserve-3d;
}

.memory-card.is-flipped .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-back,
.memory-card-face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 16px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.memory-card-back {
    background: linear-gradient(145deg, #ff9f43, #ff6b35);
    color: #fff;
    font-size: clamp(1.2rem, 3vw, 2rem);
    box-shadow: 0 8px 18px rgba(255, 107, 53, 0.24);
}

.memory-card-face {
    background: #fffdf9;
    transform: rotateY(180deg);
    box-shadow: 0 8px 18px rgba(104, 69, 48, 0.14);
}

.memory-emoji {
    font-size: clamp(1.5rem, 4vw, 2.8rem);
    line-height: 1;
}

.memory-color {
    display: block;
    width: 54%;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
}

.memory-card.is-matched {
    opacity: 0.55;
}

.memory-card.is-matched .memory-card-face {
    box-shadow: 0 0 0 3px rgba(143, 217, 182, 0.8);
}

/* Piano pads */
.piano-board {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    width: min(92%, 760px, 76vh);
    transform: translate(-50%, -50%);
}

.piano-pad {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: var(--pad-color, #ffd166);
    box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.12), 0 8px 20px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s ease;
}

.piano-pad.is-active {
    transform: scale(0.94);
    filter: brightness(1.18);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.65), 0 0 26px var(--pad-color);
}

.piano-emoji {
    font-size: clamp(1.6rem, 4vw, 2.9rem);
    line-height: 1;
}

.piano-note {
    color: rgba(30, 25, 20, 0.58);
    font-size: 0.68rem;
    font-weight: 800;
}

/* Reaction lights */
.reaction-board {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    width: min(82%, 520px, 62vh);
    transform: translate(-50%, -50%);
}

.reaction-pad {
    aspect-ratio: 1;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--pad-color, #ffd23f);
    box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.14), 0 8px 18px rgba(0, 0, 0, 0.16);
    opacity: 0.42;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.reaction-pad.is-active {
    opacity: 1;
    transform: scale(1.06);
    box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.6), 0 0 32px var(--pad-color);
}

@media (max-width: 767.98px) {
    .memory-board {
        width: min(92%, 520px, 62vh);
        gap: 6px;
    }

    .memory-card-back,
    .memory-card-face {
        border-radius: 12px;
    }

    .piano-board {
        width: min(94%, 620px, 66vh);
        gap: 7px;
    }

    .piano-pad {
        border-radius: 14px;
    }

    .reaction-board {
        width: min(86%, 430px, 54vh);
        gap: 10px;
    }

    .theme-btn {
        min-height: 52px;
        font-size: 0.68rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .memory-card-inner,
    .piano-pad,
    .reaction-pad {
        transition: none;
    }
}
