* {
    box-sizing: border-box;
}


html,
body {
    margin: 0;
    padding: 0;
}


body {
    min-height: 100vh;

    background: #202a23;

    font-family:
        Tahoma,
        Geneva,
        Verdana,
        sans-serif;
}


/* =========================================================
   DESKTOP / "BIURKO"
   ========================================================= */

.desktop {
    min-height: 100vh;

    padding: 28px 12px 48px;

    display: flex;

    justify-content: center;
    align-items: flex-start;

    user-select: none;
    -webkit-user-select: none;
}


/* =========================================================
   OKNO PROGRAMU
   ========================================================= */

.app-window {
    /*
        JS zmienia tę szerokość
        zależnie od liczby kolumn.
    */

    --window-width: 150px;

    width: var(--window-width);

    background: #c0c0c0;

    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;

    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;

    zoom: 2;

    -webkit-touch-callout: none;
}


/* =========================================================
   PASEK TYTUŁOWY
   ========================================================= */

.title-bar {
    width: 100%;
    height: 19px;

    padding: 2px 2px 2px 4px;

    display: flex;

    align-items: center;

    gap: 3px;

    background: #29495a;

    color: #ffffff;

    font-size: 9px;
    font-weight: bold;

    line-height: 1;
}


.title-icon {
    flex: 0 0 auto;

    width: 10px;
    height: 10px;

    position: relative;

    background:

        linear-gradient(
            to right,
            transparent 4px,
            #000000 4px,
            #000000 6px,
            transparent 6px
        ),

        linear-gradient(
            to bottom,
            transparent 4px,
            #000000 4px,
            #000000 6px,
            transparent 6px
        ),

        radial-gradient(
            circle,
            #000000 0 3px,
            transparent 3px
        );
}


.window-title {
    min-width: 0;

    flex: 1 1 auto;

    overflow: hidden;

    text-overflow: ellipsis;
    white-space: nowrap;
}


.window-close {
    flex: 0 0 auto;

    width: 16px;
    height: 15px;

    display: flex;

    justify-content: center;
    align-items: center;

    background: #c0c0c0;

    color: #000000;

    text-decoration: none;

    font-family:
        Tahoma,
        Geneva,
        sans-serif;

    font-size: 12px;
    font-weight: bold;

    line-height: 1;

    border-top: 1px solid #ffffff;
    border-left: 1px solid #ffffff;

    border-right: 1px solid #404040;
    border-bottom: 1px solid #404040;
}


.window-close:active {
    border-top: 1px solid #404040;
    border-left: 1px solid #404040;

    border-right: 1px solid #ffffff;
    border-bottom: 1px solid #ffffff;
}


/* =========================================================
   MENU
   ========================================================= */

.menu-bar {
    position: relative;

    width: 100%;
    height: 21px;

    padding: 1px 3px;

    display: flex;

    align-items: center;

    gap: 1px;

    background: #c0c0c0;

    border-bottom: 1px solid #808080;
}


.menu-item {
    position: relative;

    height: 100%;
}


.menu-button {
    height: 100%;

    padding: 0 7px;

    display: flex;
    align-items: center;
    justify-content: center;

    line-height: 1;

    background: transparent;

    color: #000000;

    border: 1px solid transparent;

    font-family:
        Tahoma,
        Geneva,
        Verdana,
        sans-serif;

    font-size: 10px;

    cursor: default;
}


.menu-item.open .menu-button {
    background: #29495a;

    color: #ffffff;

    border-color: #29495a;
}


/* =========================================================
   MENU ROZWIJANE
   ========================================================= */

.dropdown-menu {
    position: absolute;

    top: 100%;
    left: 0;

    z-index: 100;

    min-width: 145px;

    padding: 2px;

    display: none;

    background: #c0c0c0;

    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;

    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;

    box-shadow:
        1px 1px 0 #000000;
}


.menu-item.open .dropdown-menu {
    display: block;
}


/*
    Szerokości poszczególnych menu.
*/
#game-menu {
    min-width: 160px;
}


#view-menu {
    width: 135px;
    min-width: 135px;
}


#help-menu {
    width: 98px;
    min-width: 98px;
}


.dropdown-item {
    width: 100%;
    min-height: 20px;

    padding: 3px 8px 3px 22px;

    position: relative;

    display: flex;

    align-items: center;

    gap: 5px;

    background: transparent;

    color: #000000;

    border: 0;

    font-family:
        Tahoma,
        Geneva,
        Verdana,
        sans-serif;

    font-size: 10px;

    text-align: left;

    white-space: nowrap;

    cursor: default;
}


.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: #29495a;

    color: #ffffff;

    outline: 0;
}


.menu-check {
    position: absolute;

    left: 6px;
    top: 4px;

    width: 10px;

    visibility: hidden;

    font-weight: bold;
}


.menu-choice.active .menu-check {
    visibility: visible;
}


.menu-detail {
    margin-left: auto;

    opacity: 0.7;
}


.menu-separator {
    height: 1px;

    margin: 2px 3px;

    background: #808080;

    border-bottom: 1px solid #ffffff;
}




/* =========================================================
   WNĘTRZE GRY
   ========================================================= */

.game-body {
    width: 100%;

    padding: 6px;

    background: #c0c0c0;
}


/* =========================================================
   GÓRNY PANEL
   ========================================================= */

.top-panel {
    width: 100%;
    height: 39px;

    margin-bottom: 6px;
    padding: 4px 5px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    background: #c0c0c0;

    border-top: 3px solid #808080;
    border-left: 3px solid #808080;

    border-right: 3px solid #ffffff;
    border-bottom: 3px solid #ffffff;
}


/* =========================================================
   LICZNIKI
   ========================================================= */

.counter {
    width: 42px;
    height: 25px;

    display: flex;

    align-items: center;
    justify-content: center;

    background: #000000;

    color: #ff0000;

    font-family:
        "Courier New",
        monospace;

    font-size: 20px;
    font-weight: bold;

    line-height: 1;

    letter-spacing: 1px;

    overflow: hidden;
}


/* =========================================================
   PRZYCISK BUŹKI
   ========================================================= */

.reset-button {
    width: 26px;
    height: 26px;

    padding: 0;

    display: flex;

    justify-content: center;
    align-items: center;

    background: #c0c0c0;

    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;

    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;

    cursor: pointer;
}


.reset-button:active {
    border-top: 2px solid #404040;
    border-left: 2px solid #404040;

    border-right: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
}


/* =========================================================
   BUŹKA - PODSTAWA
   ========================================================= */

.face {
    position: relative;

    width: 17px;
    height: 17px;

    display: block;

    background: #ffff00;

    border: 1px solid #000000;
    border-radius: 50%;
}


.face-eye {
    position: absolute;

    top: 4px;

    width: 2px;
    height: 2px;

    background: #000000;
}


.face-eye-left {
    left: 4px;
}


.face-eye-right {
    right: 4px;
}


.face-mouth {
    position: absolute;

    left: 4px;
    top: 8px;

    width: 7px;
    height: 4px;

    border-bottom: 1px solid #000000;

    border-radius:
        0 0 7px 7px;
}


/* =========================================================
   BUŹKA - MYŚLENIE / NAPIĘCIE
   ========================================================= */

.face.state-thinking .face-eye {
    top: 5px;

    width: 4px;
    height: 1px;

    background: #000000;

    border: 0;
    border-radius: 0;
}


.face.state-thinking .face-eye-left {
    left: 2px;
    transform: rotate(18deg);
}


.face.state-thinking .face-eye-right {
    right: 2px;
    transform: rotate(-18deg);
}


.face.state-thinking .face-mouth {
    left: 50%;
    top: 10px;

    width: 5px;
    height: 1px;

    background: #000000;

    border: 0;
    border-radius: 0;

    transform: translateX(-50%);
}


/* =========================================================
   BUŹKA - "O!"
   ========================================================= */

.face.state-surprised .face-eye {
    top: 4px;

    width: 3px;
    height: 3px;

    background: #000000;

    border: 0;
    border-radius: 50%;
}


.face.state-surprised .face-eye-left {
    left: 3px;
}


.face.state-surprised .face-eye-right {
    right: 3px;
}


.face.state-surprised .face-mouth {
    left: 50%;
    top: 10px;

    width: 4px;
    height: 4px;

    background: #000000;

    border: 0;
    border-radius: 50%;

    transform: translateX(-50%);
}


/* =========================================================
   BUŹKA - WYGRANA
   ========================================================= */

.face.state-won .face-eye {
    top: 4px;

    width: 5px;
    height: 4px;

    background: #000000;

    border: 1px solid #000000;
    border-radius: 2px;
}


.face.state-won .face-eye-left {
    left: 2px;
}


.face.state-won .face-eye-right {
    right: 2px;
}


/* Zauszniki */

.face.state-won .face-eye-left::before,
.face.state-won .face-eye-right::before {
    content: "";

    position: absolute;

    top: 0;

    width: 2px;
    height: 1px;

    background: #000000;
}


.face.state-won .face-eye-left::before {
    right: 100%;
}


.face.state-won .face-eye-right::before {
    left: 100%;
}


/* Mostek */

.face.state-won::before {
    content: "";

    position: absolute;

    left: 6px;
    top: 5px;

    width: 3px;
    height: 1px;

    background: #000000;
}


/* Uśmiech */

.face.state-won .face-mouth {
    left: 3px;
    top: 9px;

    width: 9px;
    height: 4px;

    background: transparent;

    border: 0;
    border-bottom: 2px solid #000000;

    border-radius:
        0 0 8px 8px;
}


/* =========================================================
   BUŹKA - PRZEGRANA
   ========================================================= */

.face.state-lost .face-eye {
    top: 3px;

    width: 5px;
    height: 5px;

    background: transparent;

    border: 0;
}


.face.state-lost .face-eye-left {
    left: 2px;
}


.face.state-lost .face-eye-right {
    right: 2px;
}


.face.state-lost .face-eye::before,
.face.state-lost .face-eye::after {
    content: "";

    position: absolute;

    left: 2px;
    top: 0;

    width: 1px;
    height: 5px;

    background: #000000;
}


.face.state-lost .face-eye::before {
    transform: rotate(45deg);
}


.face.state-lost .face-eye::after {
    transform: rotate(-45deg);
}


.face.state-lost .face-mouth {
    left: 4px;
    top: 10px;

    width: 7px;
    height: 4px;

    background: transparent;

    border: 0;
    border-top: 1px solid #000000;

    border-radius:
        7px 7px 0 0;
}


/* =========================================================
   PLANSZA
   ========================================================= */

.board {
    display: grid;

    width: max-content;

    background: #808080;

    border-top: 3px solid #808080;
    border-left: 3px solid #808080;

    border-right: 3px solid #ffffff;
    border-bottom: 3px solid #ffffff;

    /*
        Jednym palcem gramy, ale przeglądarka może przejąć
        gest przewijania / pinch zoomu.
    */
    touch-action: manipulation;
}


/* =========================================================
   POLE
   ========================================================= */

.cell {
    position: relative;

    width: 16px;
    height: 16px;

    padding: 0;
    margin: 0;

    display: flex;

    justify-content: center;
    align-items: center;

    background: #c0c0c0;

    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;

    border-right: 2px solid #808080;
    border-bottom: 2px solid #808080;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 12px;
    font-weight: bold;

    line-height: 1;

    cursor: default;
}


.cell.revealed {
    border: 1px solid #808080;

    background: #c0c0c0;
}


.cell.pressed {
    border: 1px solid #808080;

    background: #c0c0c0;
}


/* =========================================================
   CYFRY
   ========================================================= */

.cell.number-1 {
    color: #0000ff;
}


.cell.number-2 {
    color: #008000;
}


.cell.number-3 {
    color: #ff0000;
}


.cell.number-4 {
    color: #000080;
}


.cell.number-5 {
    color: #800000;
}


.cell.number-6 {
    color: #008080;
}


.cell.number-7 {
    color: #000000;
}


.cell.number-8 {
    color: #808080;
}


/* =========================================================
   FLAGA
   ========================================================= */

/*
    Mały, lekki symbol budowany względem środka pola.
*/

.cell.flagged::before {
    content: "";

    position: absolute;

    left: calc(50% - 3px);
    top: calc(50% - 4px);

    width: 4px;
    height: 4px;

    background: #ff0000;

    clip-path:
        polygon(
            0 0,
            100% 25%,
            100% 75%,
            0 100%
        );
}


.cell.flagged::after {
    content: "";

    position: absolute;

    left: 50%;
    top: 50%;

    width: 7px;
    height: 8px;

    transform:
        translate(-50%, -50%);

    background:

        linear-gradient(
            #000000,
            #000000
        )
        4px 1px / 1px 5px
        no-repeat,

        linear-gradient(
            #000000,
            #000000
        )
        2px 5px / 5px 1px
        no-repeat,

        linear-gradient(
            #000000,
            #000000
        )
        1px 6px / 6px 1px
        no-repeat;
}


/* =========================================================
   MINA
   ========================================================= */

.cell.mine {
    background-color: #c0c0c0;
}


.cell.mine::before {
    content: "";

    position: absolute;

    width: 12px;
    height: 12px;

    background:

        linear-gradient(
            to right,
            transparent 5px,
            #000000 5px,
            #000000 7px,
            transparent 7px
        ),

        linear-gradient(
            to bottom,
            transparent 5px,
            #000000 5px,
            #000000 7px,
            transparent 7px
        ),

        linear-gradient(
            45deg,
            transparent 44%,
            #000000 44%,
            #000000 56%,
            transparent 56%
        ),

        linear-gradient(
            -45deg,
            transparent 44%,
            #000000 44%,
            #000000 56%,
            transparent 56%
        ),

        radial-gradient(
            circle,
            #000000 0 4px,
            transparent 4px
        );
}


.cell.exploded {
    background-color: #ff0000;
}


/* =========================================================
   OKNO DIALOGOWE
   ========================================================= */

.dialog-overlay {
    position: fixed;

    inset: 0;

    z-index: 1000;

    padding: 20px;

    display: flex;

    justify-content: center;
    align-items: center;

    background:
        rgba(0, 0, 0, 0.45);
}


.dialog-window {
    width: min(
        440px,
        calc(100vw - 30px)
    );

    max-height:
        calc(100vh - 24px);

    max-height:
        calc(100dvh - 24px);

    overflow-y: auto;

    background: #c0c0c0;

    border-top: 2px solid #ffffff;
    border-left: 2px solid #ffffff;

    border-right: 2px solid #404040;
    border-bottom: 2px solid #404040;

    box-shadow:
        2px 2px 0 #000000;
}


.dialog-title-bar {
    height: 28px;

    padding: 3px 3px 3px 7px;

    display: flex;

    align-items: center;
    justify-content: space-between;

    background: #29495a;

    color: #ffffff;

    font-weight: bold;
}


.dialog-close {
    width: 22px;
    height: 20px;

    padding: 0;

    background: #c0c0c0;

    color: #000000;

    border-top: 1px solid #ffffff;
    border-left: 1px solid #ffffff;

    border-right: 1px solid #404040;
    border-bottom: 1px solid #404040;

    font-weight: bold;
}


.dialog-close:active {
    border-top: 1px solid #404040;
    border-left: 1px solid #404040;

    border-right: 1px solid #ffffff;
    border-bottom: 1px solid #ffffff;

    padding-top: 1px;
    padding-left: 1px;
}


.dialog-body {
    padding: 16px;

    color: #000000;

    font-size: 14px;
    line-height: 1.5;

    user-select: text;
    -webkit-user-select: text;
}


.dialog-body p {
    margin:
        0 0 12px;
}


.dialog-body p:last-child {
    margin-bottom: 0;
}


.dialog-body strong {
    font-weight: bold;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 600px) {

    .desktop {
        padding:
            16px 8px 32px;
    }


    .dialog-overlay {
        padding: 12px;

        align-items: flex-start;
    }

    .dialog-overlay[data-help-type="about"] {
        align-items: center;
    }
    
    .dialog-body {
        font-size: 13px;
    }

}


/* =========================================================
   HIDDEN
   ========================================================= */

[hidden] {
    display: none !important;
}