/* 색깔 맞추기 게임 스타일 */
.game-container {
    max-width: 520px;
    margin: 0 auto;
    padding: 40px 20px;
    padding-bottom: calc(var(--fixed-banner-height, 50px) + 24px);
    min-height: 100vh;
}

.game-header {
    text-align: center;
    margin-bottom: 28px;
}

.game-title {
    font-size: 38px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(255,255,255,0.8), 0 0 10px rgba(255,182,193,0.5);
}

.game-subtitle {
    font-size: 16px;
    color: var(--text-medium);
    font-weight: 500;
}

/* 게임 영역 */
.game-area {
    background: white;
    border-radius: var(--radius-xl);
    padding: 24px 20px 28px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    /* 오버레이 콘텐츠가 잘리지 않을 충분한 높이 확보 */
    min-height: 440px;
}

/* 상태바 */
.cm-status {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 20px;
}

.cm-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #FFF0F5 0%, #F0E6FF 100%);
    border-radius: var(--radius-sm);
    padding: 10px 4px;
}

.cm-stat-label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 500;
}

.cm-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.1;
}

.lives-stat .cm-stat-value {
    font-size: 14px;
    letter-spacing: 1px;
}

/* 그리드 래퍼 */
.cm-grid-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0 12px;
}

/* 그리드 */
.cm-grid {
    display: grid;
    gap: 8px;
    width: 100%;
    max-width: 360px;
}

/* 타일 */
.cm-tile {
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    border: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    aspect-ratio: 1;
    /* 모바일 더블탭 줌 방지 + 300ms 딜레이 제거 */
    touch-action: manipulation;
    /* 버튼 기본 스타일 제거 */
    padding: 0;
    outline: none;
    display: block;
    width: 100%;
}

.cm-tile:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.cm-tile:focus-visible {
    outline: 3px solid rgba(255,182,193,0.8);
    outline-offset: 2px;
}

.cm-tile:active {
    transform: scale(0.95);
}

/* 정답 타일 */
.cm-tile.correct {
    animation: correctPop 0.35s ease-out;
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.6), 0 6px 20px rgba(0,0,0,0.2);
}

@keyframes correctPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.18); }
    70%  { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* 오답 타일 */
.cm-tile.wrong {
    animation: wrongShake 0.35s ease;
    box-shadow: 0 0 0 4px rgba(244, 67, 54, 0.6);
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* 피드백 */
.cm-feedback {
    text-align: center;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

.cm-feedback-msg {
    font-size: 16px;
    font-weight: 600;
    padding: 6px 20px;
    border-radius: 20px;
    animation: feedIn 0.25s ease-out;
}

@keyframes feedIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cm-feedback-msg.correct-msg {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    color: #2E7D32;
}

.cm-feedback-msg.wrong-msg {
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    color: #C62828;
}

/* 오버레이 */
.cm-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.93);
    backdrop-filter: blur(6px);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: opacity 0.3s ease;
}

.cm-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.cm-overlay-box {
    text-align: center;
    padding: 20px 24px;
}

.cm-ov-icon {
    font-size: 60px;
    margin-bottom: 12px;
    display: block;
}

.cm-ov-title {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.cm-ov-desc {
    font-size: 15px;
    color: var(--text-medium);
    line-height: 1.7;
    margin-bottom: 20px;
}

.cm-ov-score {
    font-size: 52px;
    font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: block;
    line-height: 1;
    margin-bottom: 4px;
}

.cm-ov-score-label {
    font-size: 14px;
    color: var(--text-light);
    display: block;
    margin-bottom: 4px;
}

.cm-ov-level {
    font-size: 15px;
    color: var(--text-medium);
    margin-bottom: 20px;
}

.cm-ov-best {
    font-size: 14px;
    color: var(--text-medium);
    margin-bottom: 20px;
}

.cm-start-btn {
    padding: 14px 44px;
    background: var(--gradient-1);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    letter-spacing: 0.3px;
}

.cm-start-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.cm-start-btn:active {
    transform: translateY(0);
}

/* 신기록 뱃지 */
.new-record-badge {
    display: inline-block;
    background: linear-gradient(135deg, #FFB6C1, #DDA0DD);
    color: white;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    margin-top: 6px;
}

/* ─── 기록 섹션 ─────────────────────────────────────────── */
.ranking-section {
    margin-top: 24px;
    animation: fadeInUp 0.5s ease 0.1s both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ranking-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 28px 24px;
    box-shadow: var(--shadow-lg);
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ranking-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.reset-ranking-btn {
    padding: 7px 14px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-medium);
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-ranking-btn:hover {
    background: #ffebee;
    border-color: #f44336;
    color: #f44336;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: var(--radius-sm);
    border: 1px solid #f0f0f0;
    transition: all 0.2s ease;
}

.ranking-item:hover {
    background: #f5f5f5;
    transform: translateX(3px);
}

.ranking-item.top-1 {
    background: linear-gradient(135deg, #fff8e1, #fff3cd);
    border-color: #ffd54f;
}

.ranking-item.top-2 {
    background: linear-gradient(135deg, #f5f5f5, #eeeeee);
    border-color: #bdbdbd;
}

.ranking-item.top-3 {
    background: linear-gradient(135deg, #fbe9e7, #ffe0b2);
    border-color: #ffab91;
}

.ranking-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-light);
    min-width: 28px;
    text-align: center;
}

.top-1 .ranking-rank { color: #f9a825; }
.top-2 .ranking-rank { color: #757575; }
.top-3 .ranking-rank { color: #bf360c; }

.ranking-info {
    flex: 1;
    margin-left: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ranking-score {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
}

.ranking-score-unit {
    font-size: 13px;
    color: var(--text-light);
}

.ranking-level-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    background: linear-gradient(135deg, #FFF0F5, #F0E6FF);
    color: var(--text-medium);
    white-space: nowrap;
}

.ranking-date {
    font-size: 12px;
    color: var(--text-light);
    margin-left: auto;
}

.no-ranking {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-light);
    font-size: 15px;
}

/* 반응형 */
@media (max-width: 480px) {
    .game-container {
        padding: 20px 14px;
        padding-bottom: calc(var(--fixed-banner-height, 50px) + 20px);
    }

    .game-title { font-size: 30px; }

    .game-area { padding: 18px 14px 22px; }

    .cm-grid { gap: 6px; }
}
