/* =============================================
   카드 짝 맞추기 게임 스타일
   ============================================= */

html { background: #000; }

.cm-body {
    overflow: hidden;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
}

.cm-game {
    width: 100%;
    height: 100dvh;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    transition: background-color 0.2s;
}

/* States */
.state-intro { background: #1a1a2e; justify-content: flex-start; overflow-y: auto; padding-top: 70px; }
.state-playing { background: #1a1a2e; justify-content: flex-start; overflow-y: auto; padding-top: 56px; }
.state-result { background: #1a1a2e; justify-content: flex-start; overflow-y: auto; padding-top: 60px; }

/* Top Bar */
.cm-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(8px);
}
.cm-back {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
}
.cm-back:hover { color: #fff; }
.cm-info-badge {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.8);
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(0,0,0,0.2);
}

/* Content */
.cm-content {
    text-align: center;
    padding: 16px;
    width: 100%;
    max-width: 480px;
}

/* Intro */
.cm-intro-emoji { font-size: 72px; margin-bottom: 12px; }
.cm-intro-title { font-size: 28px; font-weight: 800; color: #fff; margin-bottom: 8px; }
.cm-intro-desc { font-size: 15px; color: rgba(255,255,255,0.6); line-height: 1.6; margin-bottom: 20px; }
.cm-intro-best {
    background: rgba(255,215,0,0.15);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    font-size: 15px;
    color: #ffd700;
}
.cm-intro-best strong { font-size: 22px; display: block; margin-top: 4px; }

/* Difficulty */
.cm-diff-wrap { margin-bottom: 24px; }
.cm-diff-label { font-size: 14px; color: rgba(255,255,255,0.5); margin-bottom: 10px; }
.cm-diff-btns { display: flex; gap: 8px; justify-content: center; }
.cm-diff-btn {
    padding: 10px 18px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.cm-diff-btn.active {
    border-color: #6C5CE7;
    background: rgba(108,92,231,0.2);
    color: #fff;
}

.cm-btn-start {
    display: inline-block;
    padding: 16px 48px;
    background: #6C5CE7;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.cm-btn-start:active { transform: scale(0.95); }

/* Playing HUD */
.cm-hud {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
    padding: 10px 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 12px;
}
.cm-hud-item { font-size: 15px; color: rgba(255,255,255,0.8); font-weight: 600; }
.cm-hud-val { color: #ffd700; }

/* Card Grid */
.cm-grid {
    display: grid;
    gap: 8px;
    justify-content: center;
    margin: 0 auto;
}
.cm-grid.size-3x4 { grid-template-columns: repeat(4, 1fr); max-width: 320px; }
.cm-grid.size-4x4 { grid-template-columns: repeat(4, 1fr); max-width: 340px; }
.cm-grid.size-4x5 { grid-template-columns: repeat(5, 1fr); max-width: 360px; }

/* Card */
.cm-card {
    aspect-ratio: 1;
    perspective: 600px;
    cursor: pointer;
}
.cm-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.4s;
    transform-style: preserve-3d;
}
.cm-card.flipped .cm-card-inner { transform: rotateY(180deg); }
.cm-card.matched .cm-card-inner { transform: rotateY(180deg); }

.cm-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}
.cm-grid.size-4x5 .cm-card-face { font-size: 26px; }

.cm-card-back {
    background: linear-gradient(135deg, #6C5CE7, #a29bfe);
    color: rgba(255,255,255,0.5);
    font-size: 24px;
    box-shadow: 0 2px 8px rgba(108,92,231,0.3);
}
.cm-card-front {
    background: rgba(255,255,255,0.1);
    transform: rotateY(180deg);
    border: 2px solid rgba(255,255,255,0.15);
}
.cm-card.matched .cm-card-front {
    background: rgba(46,213,115,0.15);
    border-color: rgba(46,213,115,0.4);
}
.cm-card.matched { pointer-events: none; }

@keyframes cardMatchPop {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.12); }
    100% { transform: rotateY(180deg) scale(1); }
}
.cm-card.matched .cm-card-inner {
    animation: cardMatchPop 0.3s ease;
    transform: rotateY(180deg);
}

/* Result */
.cm-result-badge {
    font-size: 64px;
    margin-bottom: 8px;
}
.cm-result-grade {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 4px;
}
.cm-result-grade-label {
    font-size: 16px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 20px;
}

.cm-result-stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255,255,255,0.06);
    border-radius: 14px;
}
.cm-stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 15px;
    color: rgba(255,255,255,0.7);
}
.cm-stat-val { color: #fff; font-weight: 700; }
.cm-stat-best { color: #ffd700; }

.cm-result-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.cm-btn-share {
    padding: 16px 32px;
    background: #FEE500;
    color: #191919;
    border: none;
    border-radius: 12px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(254,229,0,0.3);
    transition: transform 0.1s;
}
.cm-btn-share:active { transform: scale(0.95); }
.cm-btn-retry {
    padding: 16px 32px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.cm-btn-retry:active { transform: scale(0.95); }

/* Ranking */
.cm-ranking-section {
    background: rgba(255,255,255,0.04);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 40px;
}
.cm-ranking-title {
    font-size: 15px;
    font-weight: 700;
    color: rgba(255,255,255,0.6);
    margin-bottom: 12px;
}
.cm-ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}
.cm-ranking-item:last-child { border-bottom: none; }
.cm-ranking-val { color: #ffd700; font-weight: 600; }

/* Toast */
.cm-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.85);
    color: #fff;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.cm-toast-show { opacity: 1; }
