* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #0c0c0c;
    color: #cccccc;
    font-family: 'Courier New', Courier, monospace;
    font-size: 14px;
    line-height: 1.4;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.app {
    max-width: 950px;
    width: 100%;
    background: #1a1a1a;
    border: 1px solid #444;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.title {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 4px;
    color: #aaa;
}

.header-controls {
    display: flex;
    gap: 15px;
    align-items: baseline;
}

.timer, .mine-counter {
    font-family: inherit;
    background: #222;
    padding: 5px 10px;
    border: 1px solid #555;
}

.btn {
    background: #2a2a2a;
    color: #ddd;
    border: 1px solid #666;
    padding: 6px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
}

.btn:hover {
    background: #3a3a3a;
    color: #fff;
    border-color: #888;
}

.close-btn {
    background: none;
    border: none;
    color: #aaa;
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
}

.close-btn:hover { color: #fff; }

.game-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.board {
    display: inline-grid;
    grid-template-columns: repeat(18, 1fr);
    gap: 2px;
    background: #2a2a2a;
    border: 2px solid #555;
    padding: 2px;
}

.cell {
    width: 28px;
    height: 28px;
    background: #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    user-select: none;
    border: 1px solid #5a5a5a;
    color: #ccc;
    box-shadow: inset 1px 1px 2px rgba(0,0,0,0.5);
}

.cell:hover:not(.revealed):not(.flag) {
    background: #4e4e4e;
    border-color: #7a7a7a;
}

.cell.revealed {
    background: #252525;
    border: 1px solid #666;
    box-shadow: inset 0 0 3px #000;
    color: #ddd;
}

.cell.flag {
    position: relative;
    background: #3a3a3a;
}

.cell.flag::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 7px;
    width: 2px;
    height: 20px;
    background: #cc3333;
}

.cell.flag::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 9px;
    width: 0;
    height: 0;
    border-left: 10px solid #cc3333;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

.cell.mine.revealed {
    background: #4a1a1a;
}

.cell.mine.revealed::after {
    content: "*";
    color: #ff5555;
    font-weight: bold;
    font-size: 20px;
}

.cell.revealed[data-n="1"] { color: #8ab4f8; }
.cell.revealed[data-n="2"] { color: #7fcf97; }
.cell.revealed[data-n="3"] { color: #ff9a9a; }
.cell.revealed[data-n="4"] { color: #c58aff; }
.cell.revealed[data-n="5"] { color: #ffb86b; }
.cell.revealed[data-n="6"] { color: #5fc9c9; }
.cell.revealed[data-n="7"] { color: #ff79c6; }
.cell.revealed[data-n="8"] { color: #bd93f9; }

.leaderboard-panel {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #1e1e1e;
    border: 1px solid #666;
    width: 550px;            /* увеличена ширина */
    max-width: 90%;
    z-index: 100;
    box-shadow: 0 0 15px rgba(0,0,0,0.7);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #2a2a2a;
    border-bottom: 1px solid #555;
    font-weight: bold;
    text-transform: uppercase;
}

.panel-body {
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
}

#leaderboard-table th,
#leaderboard-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#leaderboard-table th {
    padding-bottom: 10px;
    border-bottom: 1px solid #555;
    font-weight: normal;
    color: #aaa;
    text-transform: uppercase;
    font-size: 12px;
}

#leaderboard-table th:nth-child(1) { width: 10%; }  /* # */
#leaderboard-table th:nth-child(2) { width: 35%; }  /* name */
#leaderboard-table th:nth-child(3) { width: 20%; }  /* time */
#leaderboard-table th:nth-child(4) { width: 35%; }  /* date */

#leaderboard-table tbody tr:hover {
    background: #2a2a2a;
}

.no-records {
    text-align: center;
    color: #888;
    padding: 20px;
}

.dialog-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.dialog {
    background: #1e1e1e;
    border: 1px solid #666;
    width: 350px;
    max-width: 90%;
}

.dialog-header {
    padding: 12px 16px;
    background: #2a2a2a;
    border-bottom: 1px solid #555;
    font-weight: bold;
    text-transform: uppercase;
}

.dialog-body {
    padding: 20px 16px;
}

.dialog-body p { margin-bottom: 15px; }

.dialog-body label {
    display: block;
    margin-bottom: 5px;
    color: #aaa;
    text-transform: uppercase;
    font-size: 12px;
}

.dialog-body input {
    width: 100%;
    padding: 8px 10px;
    background: #111;
    border: 1px solid #555;
    color: #ddd;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.dialog-body input:focus {
    outline: none;
    border-color: #888;
}

.dialog-footer {
    padding: 12px 16px;
    background: #252525;
    border-top: 1px solid #444;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.error-message {
    color: #ff6666;
    font-size: 12px;
    margin-top: 5px;
}

.hidden { display: none !important; }
