/* Mahjong Solitaire - Arena13 theme. The board keeps its native size
   (see createTiles.js) and is scaled to fit #stage by fitBoard() in main.js. */

* {
    box-sizing: border-box;
}

:root {
    --ink: #14171f;
    --ink-2: #1a1e28;
    --ink-3: #262b38;
    --cream: #ebe5ce;
    --dim: rgba(235, 229, 206, 0.55);
    --line: rgba(235, 229, 206, 0.16);
    --red: #ff1919;
    --amber: #ffb319;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
    --tile-bottom-right-color: #e4dcc0;
    --tile-top-left-color: #fbf8ee;
    --tile-hover-color: #ffd3cc;
    --tile-alert-color: #ffb319;
    --tile-border-color: #3a3f4d;
    --tile-back-color: #b9b196;
}

html,
body {
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    background-color: var(--ink);
    background-image:
        linear-gradient(rgba(235, 229, 206, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(235, 229, 206, 0.035) 1px, transparent 1px);
    background-size: 40px 40px;
    color: var(--cream);
    margin: 0;
    padding: 0;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

strong {
    font-weight: 700;
    color: var(--red);
}

#wrapper {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
        max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

/* header */

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 900;
    letter-spacing: 2px;
    white-space: nowrap;
}

h1 span {
    color: transparent;
    -webkit-text-stroke: 1px var(--cream);
}

#controls {
    display: flex;
    gap: 6px;
}

#statusBar {
    min-height: 22px;
    margin: 6px 0 4px;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--dim);
    text-align: center;
    border-top: 1px solid var(--line);
    padding-top: 6px;
}

/* buttons */

button {
    border: 1px solid var(--line);
    border-radius: 2px;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--cream);
    background-color: var(--ink-3);
    padding: 7px 9px;
    min-height: 34px;
    cursor: pointer;
    transition: background-color 100ms linear, border-color 100ms linear;
    touch-action: manipulation;
}

button:active {
    background-color: var(--ink-2);
}

#restartButton,
#endRestart {
    background-color: var(--red);
    border-color: var(--red);
    color: var(--ink);
}

@media (hover: hover) {
    button:hover {
        border-color: rgba(235, 229, 206, 0.45);
    }
    #restartButton:hover,
    #endRestart:hover {
        background-color: #ff4d3d;
    }
}

/* stage + board */

#stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#game {
    position: absolute;
    left: 0;
    top: 0;
    width: 847px;
    height: 647px;
    transform-origin: 0 0;
    opacity: 0;
}

.tile {
    position: absolute;
}

.tileFront {
    position: absolute;
    background-image: linear-gradient(
        to left top,
        var(--tile-bottom-right-color),
        var(--tile-top-left-color)
    );
    border: 1px solid var(--tile-border-color);
    cursor: pointer;
    touch-action: manipulation;
}

.tileFront img {
    display: block;
    pointer-events: none;
}

@media (hover: hover) {
    .tileFront:hover {
        background-image: linear-gradient(
            to left top,
            var(--tile-hover-color),
            var(--tile-hover-color)
        );
    }
}

.selectedTile {
    background-image: linear-gradient(
        to left top,
        var(--tile-hover-color),
        var(--tile-hover-color)
    );
    box-shadow: inset 0 0 0 3px var(--red);
}

.alertTile {
    background-image: linear-gradient(
        to left top,
        var(--tile-alert-color),
        var(--tile-alert-color)
    );
}

.tileBack {
    position: absolute;
    background-color: var(--tile-back-color);
    border: 1px solid var(--tile-border-color);
}

/* info + end panels (overlay the board) */

#infoText,
#endPanel {
    position: absolute;
    z-index: 1000;
    background: rgba(26, 30, 40, 0.97);
    border: 1px solid var(--line);
}

#infoText {
    display: none;
    inset: 0;
    overflow-y: auto;
    padding: 4px 18px 16px;
    font-size: 15px;
    line-height: 1.5;
    max-width: 720px;
    margin: 0 auto;
}

#infoText h2 {
    font-family: var(--mono);
    font-size: 13px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--red);
}

#infoText img {
    width: 40px;
    border-radius: 4px;
    background-image: linear-gradient(
        to left top,
        var(--tile-bottom-right-color),
        var(--tile-top-left-color)
    );
    border: 1px solid var(--tile-border-color);
    margin: 0 4px;
}

#endPanel {
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(300px, calc(100% - 24px));
    padding: 18px 16px 20px;
    text-align: center;
    background:
        linear-gradient(var(--cream), var(--cream)) top left / 14px 2px no-repeat,
        linear-gradient(var(--cream), var(--cream)) top left / 2px 14px no-repeat,
        linear-gradient(var(--cream), var(--cream)) top right / 14px 2px no-repeat,
        linear-gradient(var(--cream), var(--cream)) top right / 2px 14px no-repeat,
        linear-gradient(var(--cream), var(--cream)) bottom left / 14px 2px no-repeat,
        linear-gradient(var(--cream), var(--cream)) bottom left / 2px 14px no-repeat,
        linear-gradient(var(--cream), var(--cream)) bottom right / 14px 2px no-repeat,
        linear-gradient(var(--cream), var(--cream)) bottom right / 2px 14px no-repeat,
        rgba(26, 30, 40, 0.97);
}

#endPanel[hidden] {
    display: none;
}

#endPanel .eyebrow {
    margin: 0 0 6px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--red);
}

#endTitle {
    margin: 0 0 16px;
    font-size: 20px;
    font-weight: 800;
}

@media (max-width: 420px) {
    h1 {
        font-size: 15px;
        letter-spacing: 1px;
    }
    h1 span {
        display: none;
    }
    #controls {
        gap: 4px;
    }
    button {
        padding: 5px 5px;
        font-size: 12px;
        letter-spacing: 0;
    }
}
