/* ========================================================================
   MINESWEEPER - Klassisches Design
   ======================================================================== */

:root {
    --ms-cell-size: 32px;
    --ms-cell-gap: 1px;
    --ms-bg: #1a1a2e;
    --ms-bg-light: #242444;
    --ms-unrevealed: #c0c0c0;
    --ms-unrevealed-light: #e0e0e0;
    --ms-unrevealed-dark: #808080;
    --ms-revealed: #d0d0d0;
    --ms-revealed-border: #b0b0b0;
    --ms-mine-bg: #ff4444;
    --ms-flag-color: #e74c3c;
    --ms-gold: #c8a84e;
    --ms-gold-light: #e8c86e;
}

/* --- Container --- */
.ms-game-container {
    background: radial-gradient(ellipse at center, var(--ms-bg-light) 0%, var(--ms-bg) 100%);
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    align-items: center;
    font-family: 'Segoe UI', 'Consolas', monospace;
}

/* --- Game-specific toolbar additions --- */
.ms-mine-counter {
    color: #ff4444;
    font-weight: 700;
}

/* --- Smiley / Status --- */
.ms-face-btn {
    width: 40px;
    height: 40px;
    border: 2px outset #e0e0e0;
    border-radius: 4px;
    background: var(--ms-unrevealed);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border 0.1s;
}

.ms-face-btn:active {
    border-style: inset;
}

/* --- Grid --- */
.ms-grid-wrapper {
    background: #808080;
    padding: 3px;
    border: 3px solid;
    border-color: #e0e0e0 #808080 #808080 #e0e0e0;
    overflow: auto;
}

.ms-grid {
    display: grid;
    gap: 0;
}

/* --- Cell --- */
.ms-cell {
    width: var(--ms-cell-size);
    height: var(--ms-cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    line-height: 1;
}

/* Unrevealed cell - classic 3D raised look */
.ms-cell.ms-unrevealed {
    background: var(--ms-unrevealed);
    border: 2px solid;
    border-color: var(--ms-unrevealed-light) var(--ms-unrevealed-dark) var(--ms-unrevealed-dark) var(--ms-unrevealed-light);
}

.ms-cell.ms-unrevealed:hover {
    background: #c8c8c8;
}

.ms-cell.ms-unrevealed:active {
    border-color: var(--ms-unrevealed-dark);
    border-width: 1px;
    padding: 1px;
    background: #b8b8b8;
}

/* Revealed cell - flat look */
.ms-cell.ms-revealed {
    background: var(--ms-revealed);
    border: 1px solid var(--ms-revealed-border);
    cursor: default;
}

/* Revealed number cell (clickable for chord) */
.ms-cell.ms-revealed.ms-has-number {
    cursor: pointer;
}

.ms-cell.ms-revealed.ms-has-number:hover {
    background: #c0c0c0;
}

/* Mine cell (game over) */
.ms-cell.ms-mine-hit {
    background: var(--ms-mine-bg) !important;
}

/* Flag */
.ms-flag {
    color: var(--ms-flag-color);
    font-size: 18px;
}

/* Mine */
.ms-mine {
    font-size: 18px;
    color: #1a1a1a;
}

/* Wrong flag (game over) */
.ms-cell.ms-wrong-flag {
    position: relative;
}

.ms-cell.ms-wrong-flag::after {
    content: '\00D7';
    position: absolute;
    font-size: 28px;
    color: var(--ms-mine-bg);
    font-weight: 900;
    line-height: 1;
}

/* Number colors */
.ms-num-1 { color: #0000ff; }
.ms-num-2 { color: #008000; }
.ms-num-3 { color: #ff0000; }
.ms-num-4 { color: #000080; }
.ms-num-5 { color: #800000; }
.ms-num-6 { color: #008080; }
.ms-num-7 { color: #000000; }
.ms-num-8 { color: #808080; }

/* --- Game Over / Win overlay on grid --- */
.ms-status-bar {
    margin-top: 10px;
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.ms-status-lost {
    background: rgba(255, 68, 68, 0.2);
    border: 1px solid rgba(255, 68, 68, 0.4);
    color: #ff6666;
}

.ms-status-won {
    background: rgba(200, 168, 78, 0.2);
    border: 1px solid rgba(200, 168, 78, 0.4);
    color: var(--ms-gold-light);
}

/* --- Flag mode indicator --- */
.ms-flag-mode {
    background: rgba(231, 76, 60, 0.25) !important;
    border-color: var(--ms-flag-color) !important;
    color: #ff8888 !important;
}

/* --- Long-Press Touch-Feedback --- */
.ms-grid {
    -webkit-touch-callout: none;
    touch-action: manipulation;
}

.ms-cell.ms-longpress-active {
    position: relative;
    overflow: hidden;
}

.ms-cell.ms-longpress-active::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(231, 76, 60, 0.25);
    animation: ms-longpress-fill 500ms linear forwards;
    z-index: 1;
    pointer-events: none;
}

@keyframes ms-longpress-fill {
    from { transform: scaleX(0); transform-origin: left; }
    to   { transform: scaleX(1); transform-origin: left; }
}

/* --- Responsive --- */
@media (max-width: 600px) {
    :root {
        --ms-cell-size: 28px;
    }
    .ms-cell { font-size: 14px; }
    .ms-flag { font-size: 15px; }
    .ms-mine { font-size: 15px; }
    .ms-face-btn { width: 34px; height: 34px; font-size: 18px; }
}

@media (max-width: 420px) {
    :root {
        --ms-cell-size: 24px;
    }
    .ms-cell { font-size: 12px; }
    .ms-flag { font-size: 13px; }
    .ms-mine { font-size: 13px; }
}
