/* ============================================================
   Minesweeper — Tactical Indigo Theme
   accent: #6366f1
   ============================================================ */

:root {
    --ms-accent: #6366f1;
    --ms-accent-light: #818cf8;
    --ms-accent-glow: rgba(99, 102, 241, .35);
    --ms-bg: #0c0a14;
    --ms-surface: #1a1730;
    --ms-surface2: #252240;
    --ms-border: #3b3860;
    --ms-text: #f0f0ff;
    --ms-text-dim: #9896b0;
    --ms-cell-hidden: #2d2a4a;
    --ms-cell-hidden-hover: #3a3760;
    --ms-cell-revealed: #1a1830;
    --ms-cell-mine: #dc2626;
    --ms-cell-flag: #f59e0b;
    --ms-num1: #3b82f6;
    --ms-num2: #22c55e;
    --ms-num3: #ef4444;
    --ms-num4: #1d4ed8;
    --ms-num5: #92400e;
    --ms-num6: #0891b2;
    --ms-num7: #1e1e1e;
    --ms-num8: #6b7280;
}

/* ── Layout ── */
.ms-layout {
    display: flex;
    justify-content: center;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: calc(100vh - 60px);
}

.ad-slot { width: 160px; flex-shrink: 0; }
.ad-slot--left, .ad-slot--right { display: flex; align-items: flex-start; }
.ad-placeholder--vertical {
    width: 160px; height: 600px;
    background: var(--ms-surface);
    border: 1px dashed var(--ms-border);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--ms-text-dim); font-size: .75rem;
}

#ms-app {
    flex: 1;
    max-width: 700px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Screens ── */
.screen { display: none; width: 100%; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ── Header ── */
.ms-header {
    text-align: center;
    margin-bottom: 2rem;
}
.ms-header h1 {
    font-family: 'Syne', sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--ms-accent-light);
    letter-spacing: 0.12em;
    text-shadow: 0 0 40px var(--ms-accent-glow);
}
.ms-header .subtitle {
    font-family: 'DM Sans', sans-serif;
    color: var(--ms-text-dim);
    font-size: .95rem;
    margin-top: .25rem;
}

/* ── Cards ── */
.card {
    background: var(--ms-surface);
    border: 1px solid var(--ms-border);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    width: 100%;
    max-width: 440px;
}
.card__title {
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    color: var(--ms-accent-light);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: .75rem;
}

/* ── Difficulty ── */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .5rem;
}
.diff-btn {
    background: var(--ms-surface2);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: .75rem .5rem;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
    color: var(--ms-text);
    font-family: 'DM Sans', sans-serif;
}
.diff-btn:hover { border-color: var(--ms-accent); }
.diff-btn.selected {
    border-color: var(--ms-accent);
    background: rgba(99, 102, 241, .15);
    box-shadow: 0 0 12px var(--ms-accent-glow);
}
.diff-icon { display: block; font-size: 1.2rem; margin-bottom: .25rem; }
.diff-desc { display: block; font-size: .7rem; color: var(--ms-text-dim); margin-top: .2rem; }

/* ── Buttons ── */
.btn {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all .2s;
    font-size: .9rem;
    padding: .6rem 1.2rem;
}
.btn--primary { background: var(--ms-accent); color: #fff; }
.btn--primary:hover { background: var(--ms-accent-light); box-shadow: 0 0 20px var(--ms-accent-glow); }
.btn--lg { padding: .85rem 2.5rem; font-size: 1rem; }
.btn--sm { padding: .4rem .8rem; font-size: .8rem; }
.btn--outline { background: transparent; border: 1px solid var(--ms-border); color: var(--ms-text); }
.btn--outline:hover { border-color: var(--ms-accent); color: var(--ms-accent-light); }
.btn--ghost { background: none; border: none; color: var(--ms-text-dim); text-decoration: underline; font-size: .85rem; }
.btn--ghost:hover { color: var(--ms-accent-light); }

.menu-actions {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
}

/* ── Toolbar ── */
.ms-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 520px;
    padding: .75rem 1rem;
    background: var(--ms-surface);
    border: 1px solid var(--ms-border);
    border-radius: 12px;
    margin-bottom: .75rem;
}

.ms-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    color: #ef4444;
    background: #0a0a0a;
    padding: .25rem .6rem;
    border-radius: 6px;
    min-width: 3.5rem;
    text-align: center;
    letter-spacing: .1em;
    border: 1px solid #333;
}

.ms-face {
    font-size: 1.8rem;
    background: var(--ms-surface2);
    border: 2px solid var(--ms-border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    line-height: 1;
}
.ms-face:hover { border-color: var(--ms-accent); transform: scale(1.05); }
.ms-face:active { transform: scale(0.95); }

/* ── Board ── */
.ms-board-wrap {
    overflow: auto;
    max-width: 100%;
    padding: .25rem;
    -webkit-overflow-scrolling: touch;
}

.ms-board {
    display: inline-grid;
    gap: 1px;
    background: var(--ms-border);
    border: 2px solid var(--ms-border);
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
}

.ms-cell {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: background .1s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.ms-cell--hidden {
    background: var(--ms-cell-hidden);
}
.ms-cell--hidden:hover {
    background: var(--ms-cell-hidden-hover);
}

.ms-cell--revealed {
    background: var(--ms-cell-revealed);
    cursor: default;
}

.ms-cell--flagged {
    background: var(--ms-cell-hidden);
}
.ms-cell--flagged::after {
    content: '🚩';
    font-size: .9rem;
}

.ms-cell--mine {
    background: var(--ms-cell-mine);
}
.ms-cell--mine::after {
    content: '💣';
    font-size: .9rem;
}

.ms-cell--mine-hit {
    background: #b91c1c;
    animation: mine-explode .3s ease-out;
}

@keyframes mine-explode {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.ms-cell--wrong-flag {
    background: var(--ms-cell-revealed);
}
.ms-cell--wrong-flag::after {
    content: '❌';
    font-size: .8rem;
}

/* Number colors */
.ms-cell[data-num="1"] { color: var(--ms-num1); }
.ms-cell[data-num="2"] { color: var(--ms-num2); }
.ms-cell[data-num="3"] { color: var(--ms-num3); }
.ms-cell[data-num="4"] { color: var(--ms-num4); }
.ms-cell[data-num="5"] { color: var(--ms-num5); }
.ms-cell[data-num="6"] { color: var(--ms-num6); }
.ms-cell[data-num="7"] { color: var(--ms-num7); }
.ms-cell[data-num="8"] { color: var(--ms-num8); }

/* Reveal animation */
.ms-cell--reveal-anim {
    animation: cell-reveal .15s ease-out;
}
@keyframes cell-reveal {
    0% { transform: scale(0.8); opacity: .5; }
    100% { transform: scale(1); opacity: 1; }
}

/* ── Mobile Controls ── */
.ms-controls-mobile {
    margin-top: .75rem;
}
.ms-flag-toggle {
    font-size: .85rem;
}
.ms-flag-toggle.active {
    border-color: var(--ms-cell-flag);
    color: var(--ms-cell-flag);
    background: rgba(245, 158, 11, .1);
}

/* ── Actions ── */
.ms-actions {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* ── Result / Leaderboard ── */
.result-card, .lb-card {
    background: var(--ms-surface);
    border: 1px solid var(--ms-border);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    width: 100%;
    max-width: 440px;
}
.result-card h2, .lb-card h2 {
    font-family: 'Syne', sans-serif;
    font-size: 1.8rem;
    color: var(--ms-accent-light);
    margin-bottom: 1rem;
}
.result-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--ms-accent-light);
    text-shadow: 0 0 20px var(--ms-accent-glow);
    margin-bottom: .5rem;
}
.result-detail {
    color: var(--ms-text-dim);
    font-size: .9rem;
    margin-bottom: 1rem;
}
#nickname {
    width: 100%;
    max-width: 280px;
    padding: .6rem;
    border: 1px solid var(--ms-border);
    border-radius: 8px;
    background: var(--ms-surface2);
    color: var(--ms-text);
    font-family: 'DM Sans', sans-serif;
    text-align: center;
    margin-bottom: 1rem;
}
#nickname::placeholder { color: var(--ms-text-dim); }
.result-actions {
    display: flex;
    gap: .75rem;
    justify-content: center;
    margin-bottom: .75rem;
}

/* Leaderboard */
#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}
#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    padding: .5rem .75rem;
    border-bottom: 1px solid var(--ms-border);
    font-family: 'JetBrains Mono', monospace;
    font-size: .85rem;
}
#leaderboard-list li:last-child { border-bottom: none; }
.lb-rank { color: var(--ms-accent-light); font-weight: 700; width: 2rem; }
.lb-name { flex: 1; text-align: left; color: var(--ms-text); margin-left: .5rem; }
.lb-score { color: var(--ms-accent-light); font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .ad-slot--left, .ad-slot--right { display: none; }
    .ms-layout { padding: .5rem; }
}

@media (max-width: 480px) {
    .ms-header h1 { font-size: 1.8rem; }
    .ms-cell { width: 28px; height: 28px; font-size: .75rem; }
    .ms-cell--flagged::after,
    .ms-cell--mine::after { font-size: .75rem; }
}
