/* =============================================
   매치3 보석 맞추기 게임 스타일
   테마: 다크 + 시안 (#06B6D4)
   ============================================= */

html { background: #0f0f23; }

.m3-body {
    overflow: hidden;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #f0f0f0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.m3-game {
    width: 100%;
    height: 100dvh;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #0f0f23;
}

.m3-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    flex-shrink: 0;
}
.m3-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);
}
.m3-back:hover { color: #fff; }
.m3-info-badge {
    font-size: 13px;
    font-weight: 600;
    color: #06B6D4;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.m3-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 16px 20px;
    overflow-y: auto;
}

/* ===== INTRO ===== */
.state-intro .m3-info-badge { display: none; }
.state-intro .m3-content {
    justify-content: center;
    padding-top: 0;
}

.m3-intro-emoji { font-size: 72px; margin-bottom: 16px; }
.m3-intro-title {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 8px;
}
.m3-intro-desc {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    margin-bottom: 20px;
    text-align: center;
}
.m3-intro-desc strong { color: #06B6D4; }

.m3-best {
    background: rgba(6, 182, 212, 0.1);
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 12px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.m3-challenge {
    background: rgba(6, 182, 212, 0.15);
    border: 1px solid rgba(6, 182, 212, 0.3);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 20px;
    font-size: 16px;
    color: #06B6D4;
    text-align: center;
}
.m3-challenge strong { font-size: 22px; }

.m3-rules {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}
.m3-rule-chip {
    padding: 6px 14px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
}

.m3-btn-start {
    display: inline-block;
    padding: 16px 48px;
    background: linear-gradient(135deg, #06B6D4, #0891B2);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.m3-btn-start:active { transform: scale(0.95); }

/* ===== PLAYING ===== */
.state-playing .m3-content {
    justify-content: flex-start;
    padding-top: 8px;
}

/* Timer bar */
.m3-timer-bar-wrap {
    width: 100%;
    max-width: 340px;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    margin-bottom: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.m3-timer-bar {
    height: 100%;
    background: linear-gradient(90deg, #06B6D4, #0891B2);
    border-radius: 4px;
    transition: width 0.1s linear;
    width: 100%;
}
.m3-timer-bar.m3-timer-low {
    background: linear-gradient(90deg, #EF4444, #DC2626);
}

.m3-hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 340px;
    margin-bottom: 10px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}
.m3-hud strong { color: #06B6D4; }

/* Grid */
.m3-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    width: 100%;
    max-width: 340px;
    flex-shrink: 0;
    touch-action: none;
}

.m3-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.m3-cell.m3-selected {
    transform: scale(1.12);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.5);
    border: 2px solid #06B6D4;
    z-index: 2;
}
.m3-cell.m3-matched {
    animation: m3Pop 0.3s ease forwards;
}
@keyframes m3Pop {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}
.m3-cell.m3-falling {
    animation: m3Fall 0.25s ease;
}
@keyframes m3Fall {
    0% { transform: translateY(-100%); opacity: 0.5; }
    100% { transform: translateY(0); opacity: 1; }
}
.m3-cell.m3-invalid {
    animation: m3Shake 0.3s ease;
}
@keyframes m3Shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Combo display */
.m3-combo {
    font-size: 20px;
    font-weight: 800;
    color: #F59E0B;
    margin-top: 10px;
    min-height: 28px;
    flex-shrink: 0;
    transition: all 0.2s;
}
.m3-combo.m3-combo-big {
    font-size: 26px;
    color: #EC4899;
}

/* Score display */
.m3-score-display {
    margin-top: 8px;
    display: flex;
    gap: 20px;
    flex-shrink: 0;
}
.m3-score-item { text-align: center; }
.m3-score-val {
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    display: block;
}
.m3-score-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}

/* Point effect */
.m3-point-effect {
    position: absolute;
    font-size: 16px;
    font-weight: 800;
    color: #06B6D4;
    pointer-events: none;
    z-index: 10;
    animation: m3PointFloat 0.6s ease-out forwards;
}
@keyframes m3PointFloat {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-40px) scale(1.2); }
}

/* ===== GAMEOVER ===== */
.m3-gameover-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 15, 35, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: m3FadeIn 0.3s ease;
}
@keyframes m3FadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.m3-gameover-text {
    font-size: 32px;
    font-weight: 900;
    color: #06B6D4;
    margin-bottom: 16px;
}
.m3-gameover-score {
    font-size: 48px;
    font-weight: 900;
    color: #fff;
    margin-bottom: 4px;
}
.m3-gameover-score small { font-size: 18px; color: rgba(255,255,255,0.5); }
.m3-gameover-detail {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 24px;
}
.m3-btn-result {
    padding: 16px 48px;
    background: linear-gradient(135deg, #06B6D4, #0891B2);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.m3-btn-result:active { transform: scale(0.95); }

/* ===== RESULT ===== */
.state-result .m3-info-badge { display: none; }
.state-result .m3-content {
    justify-content: flex-start;
    padding-top: 24px;
}

/* Toast */
.m3-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;
}
.m3-toast-show {
    opacity: 1;
    pointer-events: auto;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .m3-intro-title { font-size: 24px; }
    .m3-intro-emoji { font-size: 56px; }
    .m3-cell { font-size: 24px; }
    .m3-gameover-score { font-size: 40px; }
}

@media (max-width: 360px) {
    .m3-top-bar { padding: 10px 12px; }
    .m3-content { padding: 12px 16px; }
    .m3-cell { font-size: 20px; }
    .m3-grid { gap: 2px; }
}
