/* =============================================
   지뢰찾기 게임 스타일
   테마: 다크 네이비 + 네온
   ============================================= */

html { background: #0f0f23; }

.ms-body {
    overflow: hidden;
    height: 100dvh;
    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;
}

/* Game Area */
.ms-game {
    width: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color 0.15s;
    background: #0f0f23;
}

/* Top Bar */
.ms-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.3);
}
.ms-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);
}
.ms-back:hover { color: #fff; }
.ms-info {
    display: flex;
    gap: 16px;
    font-size: 15px;
    font-weight: 700;
}
#msMines { color: #EF4444; }
#msTimer { color: #3B82F6; }

/* Content */
.ms-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
}

/* ===== INTRO ===== */
.state-intro { background: #0f0f23; }
.state-intro .ms-content {
    justify-content: flex-start;
    padding-top: 32px;
}

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

.ms-best {
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    padding: 10px 18px;
    margin-bottom: 16px;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* Difficulty Buttons */
.ms-diff-btns {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
    max-width: 400px;
}
.ms-diff-btn {
    flex: 1;
    min-width: 110px;
    padding: 20px 12px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
}
.ms-diff-btn:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}
.ms-diff-btn:active { transform: scale(0.97); }
.ms-diff-emoji { font-size: 36px; display: block; margin-bottom: 8px; }
.ms-diff-label {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}
.ms-diff-detail {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
}

.ms-diff-btn[data-diff="easy"] { border-color: rgba(34, 197, 94, 0.3); }
.ms-diff-btn[data-diff="easy"]:hover { border-color: #22C55E; background: rgba(34, 197, 94, 0.1); }
.ms-diff-btn[data-diff="medium"] { border-color: rgba(234, 179, 8, 0.3); }
.ms-diff-btn[data-diff="medium"]:hover { border-color: #EAB308; background: rgba(234, 179, 8, 0.1); }
.ms-diff-btn[data-diff="hard"] { border-color: rgba(239, 68, 68, 0.3); }
.ms-diff-btn[data-diff="hard"]:hover { border-color: #EF4444; background: rgba(239, 68, 68, 0.1); }

/* ===== PLAYING ===== */
.state-playing { background: #0f0f23; }
.state-playing .ms-content {
    justify-content: flex-start;
    padding-top: 8px;
}

/* Board */
.ms-board-wrap {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
}
.ms-board {
    display: grid;
    gap: 1px;
    background: #1e1e3a;
    padding: 4px;
    border-radius: 8px;
    margin: 0 auto;
}

/* Cells */
.ms-cell {
    aspect-ratio: 1 / 1;
    min-width: 28px;
    min-height: 28px;
    background: #374151;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: background 0.08s;
    line-height: 1;
}
.ms-cell:hover { background: #4B5563; }

.ms-cell-revealed {
    background: #1a1a2e;
    cursor: default;
}
.ms-cell-revealed:hover { background: #1a1a2e; }

.ms-cell-mine {
    background: #EF4444 !important;
    cursor: default;
}
.ms-cell-flagged {
    background: #374151;
    font-size: 16px;
}
.ms-cell-flagged:hover { background: #4B5563; }

/* Exploded mine (the one you clicked) */
.ms-cell-exploded {
    background: #B91C1C !important;
    animation: msPulse 0.3s ease;
}

/* Number colors */
.ms-n1 { color: #3B82F6; }
.ms-n2 { color: #22C55E; }
.ms-n3 { color: #EF4444; }
.ms-n4 { color: #7C3AED; }
.ms-n5 { color: #F59E0B; }
.ms-n6 { color: #06B6D4; }
.ms-n7 { color: #000; }
.ms-n8 { color: #6B7280; }

/* ===== WON / GAMEOVER ===== */
.state-won { background: #0f0f23; }
.state-gameover { background: #0f0f23; }

.ms-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    animation: msFadeIn 0.3s ease;
}
.ms-overlay-won { background: rgba(34, 197, 94, 0.15); }
.ms-overlay-lose { background: rgba(239, 68, 68, 0.15); }
.ms-overlay-msg {
    text-align: center;
}
.ms-overlay-emoji { font-size: 64px; margin-bottom: 8px; }
.ms-overlay-text {
    font-size: 28px;
    font-weight: 800;
}
.ms-overlay-won .ms-overlay-text { color: #22C55E; }
.ms-overlay-lose .ms-overlay-text { color: #EF4444; }

/* ===== RESULT ===== */
.state-result { background: #0f0f23; }
.state-result .ms-content {
    justify-content: flex-start;
    padding-top: 24px;
}

.ms-result-badge {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    background: rgba(59, 130, 246, 0.08);
}
.ms-result-emoji { font-size: 40px; }
.ms-result-grade {
    font-size: 28px;
    font-weight: 900;
    margin-top: 2px;
}
.ms-result-label {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}
.ms-result-pct {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

.ms-result-stats {
    display: flex;
    gap: 32px;
    margin-bottom: 16px;
}
.ms-stat { text-align: center; }
.ms-stat-val {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
}
.ms-stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.ms-new-record {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #3B82F6;
    padding: 8px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.ms-result-diff {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 16px;
}

/* Lose result */
.ms-lose-msg {
    font-size: 20px;
    font-weight: 700;
    color: #EF4444;
    margin-bottom: 8px;
}
.ms-lose-emoji {
    font-size: 64px;
    margin-bottom: 12px;
}
.ms-lose-time {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 20px;
}

/* Buttons */
.ms-result-btns {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    justify-content: center;
}
.ms-btn-share, .ms-btn-retry, .ms-btn-submit {
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s;
}
.ms-btn-share:active, .ms-btn-retry:active, .ms-btn-submit:active { transform: scale(0.95); }

.ms-btn-share {
    padding: 16px 32px;
    background: #FEE500;
    color: #191919;
    font-size: 17px;
    box-shadow: 0 4px 16px rgba(254, 229, 0, 0.3);
    flex: 1;
    min-width: 160px;
    border-radius: 12px;
}
.ms-btn-retry {
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Ranking */
.ms-ranking-section {
    width: 100%;
    max-width: 400px;
    padding-bottom: 40px;
}
.ms-ranking-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    text-align: center;
}

.ms-ranking-tabs {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 12px;
}
.ms-ranking-tab {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.ms-ranking-tab:hover { border-color: rgba(255, 255, 255, 0.3); color: #fff; }
.ms-ranking-tab.active {
    background: rgba(59, 130, 246, 0.2);
    border-color: #3B82F6;
    color: #3B82F6;
}

.ms-ranking-form {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.ms-nickname-input {
    flex: 1;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    outline: none;
}
.ms-nickname-input::placeholder { color: rgba(255, 255, 255, 0.3); }
.ms-nickname-input:focus { border-color: rgba(59, 130, 246, 0.5); }

.ms-btn-submit {
    padding: 10px 20px;
    background: #3B82F6;
    color: #fff;
    font-size: 14px;
    border-radius: 10px;
}

.ms-rankings-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ms-rank-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    font-size: 13px;
}
.ms-rank-pos {
    width: 28px;
    text-align: center;
    font-weight: 700;
}
.ms-rank-name {
    flex: 1;
    color: #fff;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ms-rank-time {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    min-width: 60px;
    text-align: right;
}
.ms-no-ranking {
    text-align: center;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
    padding: 16px;
}

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

/* Animations */
@keyframes msFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes msPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
@keyframes msPopIn {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .ms-diff-btns {
        flex-direction: column;
        align-items: center;
    }
    .ms-diff-btn {
        width: 100%;
        max-width: 280px;
        padding: 16px 12px;
    }
    .ms-diff-emoji { font-size: 28px; }

    .ms-cell {
        min-width: 24px;
        min-height: 24px;
        font-size: 12px;
    }

    .ms-result-stats { gap: 20px; }
    .ms-stat-val { font-size: 24px; }
}

/* Hard mode horizontal scroll */
.ms-board-wrap.ms-hard-mode {
    overflow-x: auto;
    padding-bottom: 8px;
}
.ms-board-wrap.ms-hard-mode::-webkit-scrollbar {
    height: 4px;
}
.ms-board-wrap.ms-hard-mode::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}
.ms-board-wrap.ms-hard-mode::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Pinch-zoom hint for hard mode */
.ms-zoom-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 8px;
    text-align: center;
}
