/* ═══════════════════════════════════════════════════════════════════
   app.css — Bomberman (Minesweeper) game styles
   Mobile-first, brutalist black/white
   ═══════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
}

/* === GRAIN === */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.025;
    pointer-events: none;
    z-index: var(--z-grain);
}

/* === LAYOUT (fullscreen game) === */
.game-page {
    overflow: hidden;
    height: 100dvh;
}

.game-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 100%;
    margin: 0 auto;
    padding: var(--space-xs) var(--space-sm);
}

.game-controls {
    flex-shrink: 0;
}

/* === RANKING PAGE === */
.ranking-container {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-sm) var(--space-md);
}

/* === HEADER === */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-sm);
}

.game-title {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    line-height: 1;
    letter-spacing: var(--tracking-wider);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* === DIFFICULTY TABS === */
.difficulty-tabs {
    display: flex;
    border: var(--border-width) solid var(--color-border);
    margin-bottom: var(--space-sm);
}

.diff-btn {
    flex: 1;
    background: transparent;
    border: none;
    border-right: var(--border-width) solid var(--color-border);
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    padding: var(--space-xs) var(--space-sm);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    transition: all 150ms;
}

.diff-btn:last-child { border-right: none; }
.diff-btn.active { background: var(--color-text); color: var(--color-bg); }
.diff-btn:not(.active):hover { color: var(--color-text); background: var(--color-bg-surface); }

/* === GAME BAR (mines | smiley | timer) === */
.game-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: var(--border-width) solid var(--color-border);
    padding: var(--space-xs) var(--space-sm);
    margin-bottom: var(--space-sm);
    background: var(--color-bg-surface);
}

.mine-counter, .timer {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    color: var(--color-accent);
    min-width: 48px;
    text-align: center;
    letter-spacing: 0.1em;
}

.smiley-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
    transition: transform 100ms;
}

.smiley-btn:active { transform: scale(0.9); }

/* === GAME GRID === */
.game-grid {
    display: grid;
    gap: 1px;
    background: var(--color-border);
    border: var(--border-width) solid var(--color-border);
    flex: 1;
    min-height: 0;
    overflow: auto;
    touch-action: manipulation;
    align-content: center;
    justify-content: center;
}

/* === CELL === */
.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: var(--cell-font, 0.75rem);
    font-weight: 700;
    cursor: pointer;
    transition: background 80ms;
    -webkit-tap-highlight-color: transparent;
}

.cell-unrevealed {
    background: #2a2a2a;
    border: 1px solid #444;
}

.cell-unrevealed:hover { background: #333; }
.cell-unrevealed:active { background: #1a1a1a; }

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

.cell-mine {
    background: #331111;
}

.cell-mine-hit {
    background: var(--color-accent);
}

.cell-flagged {
    background: #2a2a2a;
    border: 1px solid #444;
}

/* Number colors */
.cell-1 { color: #4488ff; }
.cell-2 { color: #44bb44; }
.cell-3 { color: #ff4444; }
.cell-4 { color: #4444cc; }
.cell-5 { color: #aa4422; }
.cell-6 { color: #44aaaa; }
.cell-7 { color: #444444; }
.cell-8 { color: #888888; }

/* === SCORE MODAL === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: var(--color-bg);
    border: var(--border-width) solid var(--color-text);
    padding: var(--space-xl);
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.modal-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    letter-spacing: var(--tracking-wider);
    margin-bottom: var(--space-md);
    text-align: center;
}

.modal-score {
    text-align: center;
    font-size: var(--text-2xl);
    font-family: var(--font-display);
    color: var(--color-accent);
    margin-bottom: var(--space-lg);
}

.modal-input {
    width: 100%;
    background: var(--color-bg-input);
    border: var(--border-width) solid var(--color-border);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-sm);
}

.modal-input::placeholder { color: var(--color-text-muted); }
.modal-input:focus { outline: none; border-color: var(--color-border-focus); }

.modal-btn {
    width: 100%;
    background: var(--color-text);
    color: var(--color-bg);
    border: var(--border-width) solid var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-base);
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    margin-top: var(--space-sm);
    transition: all 150ms;
}

.modal-btn:hover { background: var(--color-bg); color: var(--color-text); }

.modal-skip {
    display: block;
    text-align: center;
    margin-top: var(--space-sm);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}

.modal-skip:hover { color: var(--color-text); }

/* === LEADERBOARD === */
.leaderboard {
    margin-top: var(--space-md);
    border-top: var(--border-width) solid var(--color-border);
    padding-top: var(--space-md);
}

.lb-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    letter-spacing: var(--tracking-wider);
    margin-bottom: var(--space-sm);
}

.lb-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}

.lb-table th {
    text-align: left;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    padding: var(--space-xs) var(--space-sm);
    border-bottom: var(--border-width) solid var(--color-border);
    font-weight: 400;
}

.lb-table td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
}

.lb-table tr:first-child td { color: var(--color-text); }

.lb-rank { color: var(--color-text-muted); min-width: 24px; }
.lb-name { color: var(--color-text); }
.lb-score { color: var(--color-accent); text-align: right; }
.lb-time { text-align: right; }
.lb-city { color: var(--color-text-muted); }

.lb-empty {
    text-align: center;
    padding: var(--space-lg);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
}

/* === NAV LINK === */
.nav-link {
    color: var(--color-text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    border: var(--border-width) solid var(--color-border);
    padding: var(--space-xs) var(--space-sm);
    transition: all 150ms;
}

.nav-link:hover { color: var(--color-text); border-color: var(--color-text); }

/* === ANIMATIONS === */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* === RESPONSIVE === */
@media (min-width: 768px) {
    .ranking-container { padding: var(--space-lg) var(--space-xl); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
