/* Out of Mind: standalone page styled to match the portfolio (navy, sky blue, pink, Poppins). */
:root {
    --navy: #0E1E31;
    --slate: #2F3749;
    --ink: #111419;
    --blue: #2BA5E2;
    --blue-deep: #1c72be;
    --pink: #ff60ff;
    --text: #ffffff;
    --muted: #9aa3bd;
    --danger: #ff6b86;
    --warning: #f5c542;
    --panel: rgba(9, 14, 24, 0.92);
    --line: rgba(255, 255, 255, 0.1);
    --radius: 10px;

    /* Vertical space taken by everything except the board, so the board fits one screen. */
    --chrome-height: 220px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: linear-gradient(130deg, var(--navy) 0%, var(--slate) 130%);
    background-attachment: fixed;
    color: var(--text);
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 16px;
}

button {
    font: inherit;
    color: inherit;
    touch-action: manipulation;
}

svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/*#region ----- Top Bar */
.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    max-width: 560px;
    margin: 0 auto;
    padding: 10px 16px 6px;
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    justify-self: start;
    color: var(--muted);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.back:hover,
.back:focus-visible {
    color: var(--blue);
}

.back svg {
    width: 18px;
    height: 18px;
}

.brand {
    color: var(--blue);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.icon-button {
    justify-self: end;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--muted);
}

.icon-button:hover {
    color: var(--blue);
    border-color: var(--blue);
}

.icon-button svg {
    width: 20px;
    height: 20px;
}

.icon-button .icon-sound-off,
.icon-button[data-muted="true"] .icon-sound-on {
    display: none;
}

.icon-button[data-muted="true"] .icon-sound-off {
    display: block;
}
/*#endregion*/

/*#region ----- Game Layout */
.game {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 16px 16px;
}

.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 495px;
    padding: 8px 12px;
    background: rgba(9, 14, 24, 0.55);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.stat svg {
    width: 18px;
    height: 18px;
}

.stat-label {
    color: var(--muted);
}

.stat-hp svg { color: var(--danger); }
.stat-gold svg { color: var(--warning); }
.stat-freeze svg { color: #9ad8ff; }

.light-dot {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 10px var(--blue);
    transition: background 0.15s, box-shadow 0.15s;
}

.stat-light[data-state="warn"] .light-dot {
    background: var(--warning);
    box-shadow: 0 0 10px var(--warning);
    animation: waver 0.5s steps(2) infinite;
}

.stat-light[data-state="off"] .light-dot {
    background: #333a4a;
    box-shadow: none;
}

@keyframes waver {
    50% { opacity: 0.4; }
}

.stage {
    position: relative;
    width: min(100%, 495px, calc((100vh - var(--chrome-height)) * 9 / 11));
    width: min(100%, 495px, calc((100dvh - var(--chrome-height)) * 9 / 11));
    aspect-ratio: 9 / 11;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid transparent;
    border-image: linear-gradient(90deg, var(--blue), var(--pink)) 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#board {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: pointer;
}

.message {
    min-height: 1.5em;
    margin: 0;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}

.message[data-tone="danger"] { color: var(--danger); }
.message[data-tone="warning"] { color: var(--warning); }
.message[data-tone="celebrate"] { color: #ff8a1f; font-weight: 700; }

.hint {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}
/*#endregion*/

/*#region ----- Overlays */
.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    background: rgba(5, 8, 14, 0.55);
    overflow-y: auto;
}

.panel {
    width: 100%;
    max-width: 380px;
    margin: auto;
    padding: 20px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    text-align: center;
}

.panel h1 {
    margin: 0 0 4px;
    font-size: 30px;
    color: var(--blue);
    letter-spacing: 0.03em;
}

.panel h2 {
    margin: 0 0 4px;
    font-size: 24px;
    color: var(--blue);
}

.panel p {
    margin: 0 0 12px;
}

.tagline {
    color: var(--pink);
    font-size: 15px;
}

.rules {
    margin: 0 0 16px;
    padding-left: 18px;
    text-align: left;
    font-size: 14px;
    line-height: 1.5;
    color: #d5dbea;
}

.rules li + li {
    margin-top: 6px;
}

.muted,
.best {
    color: var(--muted);
    font-size: 14px;
}

.panel .best {
    margin: 10px 0 0;
}

.panel button {
    padding: 8px 16px;
    background: var(--ink);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.panel button:hover,
.panel button:focus-visible {
    border-color: var(--blue);
}

.panel button.primary {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(90deg, var(--blue) 0%, var(--blue-deep) 100%);
    border: none;
    font-weight: 700;
}

.panel button.primary:hover,
.panel button.primary:focus-visible {
    filter: brightness(1.1);
}

.shop-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    text-align: left;
    font-size: 15px;
}

.shop-row button {
    min-width: 84px;
}

.shop-row button.toss {
    border-color: var(--warning);
    color: var(--warning);
}

.shop-row button.toss:active {
    transform: scale(0.94);
}

.fx {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.panel .shop-message {
    min-height: 1.4em;
    margin: 6px 0 12px;
    font-size: 14px;
    color: var(--muted);
}

.shop-message[data-tone="danger"] {
    color: var(--danger);
}
/*#endregion*/

/*#region ----- Touch Controls */
.dpad {
    display: none;
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(2, 54px);
    grid-template-areas:
        ".    up    ."
        "left down  right";
    gap: 8px;
}

.dpad button {
    display: grid;
    place-items: center;
    background: rgba(9, 14, 24, 0.7);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.dpad button:active {
    border-color: var(--blue);
    background: var(--navy);
}

.dpad svg {
    width: 26px;
    height: 26px;
}

.dpad-up { grid-area: up; }
.dpad-left { grid-area: left; }
.dpad-down { grid-area: down; }
.dpad-right { grid-area: right; }

@media (pointer: coarse) {
    :root {
        --chrome-height: 330px;
    }

    .dpad {
        display: grid;
    }

    .hint {
        display: none;
    }
}
/*#endregion*/

@media (prefers-reduced-motion: reduce) {
    .stat-light[data-state="warn"] .light-dot {
        animation: none;
    }
}
