/* NarkoMania - HTML5 Minesweeper Clone */
/* CSS Variables for theming */

:root {
    --bg-color: #c0c0c0;
    --panel-bg: #c0c0c0;
    --border-light: #ffffff;
    --border-dark: #808080;
    --border-darker: #404040;
    --text-color: #000000;
    --menu-bg: #f0f0f0;
    --menu-hover: #e0e0e0;
    --menu-border: #999;
    --dialog-bg: #f0f0f0;
    --speed-graph-bg: #000000;
}

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

body {
    background: #606060;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 12px;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    overflow-x: auto;
}

@media (max-width: 600px) {
    body {
        align-items: flex-start;
    }
}

/* Footer */
#page-footer {
    margin-top: 12px;
    margin-bottom: 12px;
    color: #aaa;
    font-size: 12px;
    text-align: center;
    align-self: center;
    width: 100vw;
}

#page-footer a {
    color: #ccc;
    text-decoration: none;
}

#page-footer a:hover {
    color: #fff;
    text-decoration: underline;
}

/* Win95 style 3D borders */
.raised-border {
    border-top: 2px solid var(--border-light);
    border-left: 2px solid var(--border-light);
    border-bottom: 2px solid var(--border-dark);
    border-right: 2px solid var(--border-dark);
}

.sunken-border {
    border-top: 2px solid var(--border-dark);
    border-left: 2px solid var(--border-dark);
    border-bottom: 2px solid var(--border-light);
    border-right: 2px solid var(--border-light);
}

/* Title Bar */
#title-bar {
    display: flex;
    align-items: center;
    background: linear-gradient(90deg, #000080, #1084d0);
    color: white;
    padding: 2px 3px;
    font-size: 12px;
    font-weight: bold;
    gap: 4px;
    height: 22px;
}

#title-bar .title-icon {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

#title-text {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-shadow: none;
}

.title-buttons {
    display: flex;
    gap: 2px;
}

.title-btn {
    width: 18px;
    height: 16px;
    font-size: 11px;
    line-height: 10px;
    text-align: center;
    padding: 0;
    border: 1px outset #ccc;
    background: var(--bg-color);
    color: black;
    cursor: default;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    font-weight: bold;
}

.title-btn:active {
    border-style: inset;
}

.title-close:hover {
    background: #c0392b;
    color: white;
}

/* Main game container */
#game-container {
    background: var(--bg-color);
    display: inline-flex;
    flex-direction: column;
    padding: 4px;
    margin-top: 8px;
}

/* Menu bar */
#menu-bar {
    display: flex;
    gap: 0;
    padding: 2px 0;
    background: var(--bg-color);
    margin-bottom: 2px;
}

.menu-item {
    position: relative;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 13px;
}

.menu-item:hover {
    background: var(--menu-hover);
}

.menu-item.active {
    background: var(--menu-hover);
}

.menu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--menu-bg);
    border: 1px solid var(--menu-border);
    box-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    min-width: 200px;
    z-index: 1000;
    padding: 2px 0;
}

.menu-dropdown.show {
    display: block;
}

.menu-dropdown .menu-entry {
    padding: 4px 24px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.menu-dropdown .menu-entry:hover {
    background: #0078d4;
    color: white;
}

.menu-dropdown .menu-entry.checked::before {
    content: '\2713';
    position: absolute;
    left: 6px;
}

.menu-dropdown .menu-entry .shortcut {
    margin-left: auto;
    color: #666;
    font-size: 11px;
}

.menu-dropdown .menu-entry:hover .shortcut {
    color: #ccc;
}

.menu-separator {
    height: 1px;
    background: var(--menu-border);
    margin: 2px 4px;
}

.menu-entry.radio-checked::before {
    content: '\25CF';
    position: absolute;
    left: 7px;
    font-size: 10px;
}

/* Top panel with mine count, face, time */
#top-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 6px;
    margin-bottom: 4px;
    min-height: 40px;
}

#mine-display, #time-display {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#face-button {
    cursor: pointer;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    padding: 2px;
}

#face-button:active {
    border-top: 2px solid var(--border-dark);
    border-left: 2px solid var(--border-dark);
    border-bottom: 2px solid var(--border-light);
    border-right: 2px solid var(--border-light);
}

/* Game board */
#board-wrapper {
    padding: 0;
    display: flex;
    justify-content: center;
    background: #808080;
}

#game-board {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    cursor: default;
}

/* Bottom status bar */
#status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 6px;
    margin-top: 4px;
    font-size: 12px;
    min-height: 22px;
}

#speed-display {
    display: flex;
    align-items: center;
    gap: 4px;
}

#speed-label {
    font-weight: bold;
}

#game-number {
    color: #444;
    font-size: 11px;
}

/* Speed Graph Panel */
#speed-graph-panel {
    display: none;
    margin-top: 4px;
    padding: 4px;
    width: 100%;
}

#speed-graph-panel.visible {
    display: block;
}

#speed-graph-container {
    padding: 2px;
}

#speed-graph {
    width: 100%;
    height: 80px;
    background: var(--speed-graph-bg);
    display: block;
}

/* Tile size selector */
#tile-size-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 6px;
    font-size: 11px;
    margin-top: 2px;
}

#tile-size-bar label {
    cursor: pointer;
}

#tile-size-bar input[type="radio"] {
    cursor: pointer;
    margin: 0 2px;
}

/* Dialogs / Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-dialog {
    background: var(--dialog-bg);
    border: 2px outset #ccc;
    padding: 0;
    min-width: 300px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-titlebar {
    background: linear-gradient(90deg, #0078d4, #00a4ef);
    color: white;
    padding: 4px 8px;
    font-weight: bold;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    background: none;
    border: none;
    color: white;
    font-weight: bold;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 12px;
    overflow-y: auto;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #ccc;
}

.btn {
    padding: 4px 16px;
    cursor: pointer;
    font-size: 12px;
    border: 2px outset #ccc;
    background: var(--bg-color);
}

.btn:active {
    border-style: inset;
}

/* Custom Level Dialog */
.custom-form {
    display: grid;
    grid-template-columns: auto auto;
    gap: 8px;
    align-items: center;
}

.custom-form label {
    text-align: right;
}

.custom-form input[type="number"] {
    width: 80px;
    padding: 2px 4px;
    border: 2px inset #ccc;
}

#difficulty-label {
    grid-column: 1 / -1;
    text-align: center;
    margin-top: 4px;
    font-weight: bold;
}

/* High Scores Dialog */
#highscores-dialog .modal-dialog {
    min-width: 520px;
    max-width: 640px;
    max-height: 80vh;
}

@media (max-width: 600px) {
    #highscores-dialog .modal-dialog {
        min-width: 0;
        width: 95vw;
    }

    .hs-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .hs-level-group {
        margin-left: 0;
        flex-wrap: wrap;
    }

    .hs-table thead { display: none; }

    .hs-table,
    .hs-table tbody,
    .hs-table tr,
    .hs-table td {
        display: block;
        width: auto;
        text-align: left;
    }

    .hs-table tr {
        display: flex;
        flex-wrap: wrap;
        gap: 2px 8px;
        padding: 4px;
        border-bottom: 1px solid #ccc;
    }

    .hs-table td {
        white-space: normal;
    }

    .hs-table td::before {
        font-weight: bold;
        margin-right: 3px;
    }

    .hs-table .col-rank::before { content: "#"; }
    .hs-table .col-name::before { content: ""; }
    .hs-table .col-time::before { content: "Time: "; }
    .hs-table .col-mines::before { content: "Mines: "; }
    .hs-table .col-speed::before { content: "Speed: "; }
    .hs-table .col-date::before { content: "Date: "; }
    .hs-table .col-game::before { content: "Game: "; }
}

.hs-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.hs-controls .mode-btn {
    padding: 3px 10px;
    cursor: pointer;
    font-size: 11px;
    border: 2px outset #ccc;
    background: var(--bg-color);
}

.hs-controls .mode-btn.active {
    border-style: inset;
    background: #d0d0d0;
}

.hs-level-group {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

.hs-level-group label {
    cursor: pointer;
    font-size: 11px;
}

.hs-level-group input {
    margin-right: 2px;
}

.hs-level-name {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 6px;
}

.hs-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    border: 2px inset #ccc;
}

.hs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    table-layout: fixed;
}

.hs-table th {
    position: sticky;
    top: 0;
    background: #d0d0d0;
    border-bottom: 1px solid #999;
    padding: 3px 4px;
    text-align: left;
    font-weight: bold;
}

.hs-table td {
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hs-table tr.most-recent td {
    color: red;
    font-weight: bold;
}

.hs-table .col-rank { width: 30px; text-align: right; }
.hs-table .col-name { width: 100px; color: navy; }
.hs-table .col-time { width: 45px; text-align: right; color: green; }
.hs-table .col-mines { width: 45px; text-align: right; color: maroon; }
.hs-table .col-speed { width: 50px; text-align: right; color: purple; }
.hs-table .col-date { width: 140px; color: navy; }
.hs-table .col-game { width: 90px; cursor: pointer; }

.hs-table .col-game:hover {
    text-decoration: underline;
}

/* Game Number Input Dialog */
#gameno-dialog .modal-dialog {
    min-width: 320px;
}

#gameno-input {
    width: 100%;
    padding: 4px;
    border: 2px inset #ccc;
    font-size: 13px;
}

/* Name Input Dialog */
#name-dialog .modal-dialog {
    min-width: 350px;
}

#name-input {
    width: 100%;
    padding: 4px;
    border: 2px inset #ccc;
    font-size: 13px;
    max-length: 16;
}

#name-message {
    margin-bottom: 8px;
    font-size: 13px;
}
