:root {
    --bg: #050505;
    --panel: rgba(0, 0, 0, 0.62);
    --panel-strong: rgba(0, 0, 0, 0.78);
    --line: rgba(255, 255, 255, 0.13);
    --line-strong: rgba(255, 255, 255, 0.22);
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.72);
    --accent: #ff6b6b;
    --accent-hover: #ff5252;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    overflow-x: hidden;
}

#ambientCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.96));
}

.content {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.container {
    width: min(1200px, calc(100% - 40px));
    margin: 0 auto;
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background-color: rgba(0, 0, 0, 0.72);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(5px);
}

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 0;
}

.logo {
    color: #fff;
    font-size: 24px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 24px;
    color: var(--muted);
    font-weight: 500;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 12px 24px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    background-color: var(--accent);
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.3s, box-shadow 0.3s, transform 0.3s;
}

.btn:hover,
.btn:focus-visible {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.28);
    outline: none;
}

.btn:disabled {
    color: rgba(255, 255, 255, 0.58);
    background-color: rgba(255, 255, 255, 0.12);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn.is-active {
    color: #111;
    background-color: #fff;
}

.btn.compact {
    min-height: 38px;
    padding: 9px 18px;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 96px 20px 32px;
}

.game-section {
    width: 100%;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(220px, 286px) minmax(300px, 520px);
    align-items: start;
    justify-content: center;
    gap: 28px;
}

.hud-panel,
.board-frame {
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: var(--panel);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(5px);
}

.hud-panel {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 24px;
}

.hud-block {
    display: grid;
    gap: 2px;
}

.primary-score {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.hud-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.hud-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
}

.hud-block strong {
    min-height: 32px;
    color: #fff;
    font-size: 28px;
    line-height: 1.15;
}

.primary-score strong {
    min-height: 56px;
    font-size: 52px;
    line-height: 1.05;
}

.points-block {
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.next-panel {
    display: grid;
    grid-template-columns: 1fr 96px;
    align-items: center;
    gap: 18px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

#nextCanvas {
    width: 96px;
    height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.06);
}

.board-frame {
    position: relative;
    width: min(520px, calc((100vh - 240px) * 0.6667), 100%);
    min-width: 300px;
    padding: 12px;
    background-color: var(--panel-strong);
    transition: transform 0.1s ease-out;
}

.board-frame.is-jiggling {
    animation: board-jiggle 280ms ease-in-out;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    background-color: #070707;
    touch-action: none;
}

#gameCanvas.is-removing {
    cursor: crosshair;
}

.board-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 14px;
    margin-top: 12px;
}

.board-actions .btn {
    min-height: 42px;
}

.board-actions span {
    grid-column: 1 / -1;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    text-align: center;
}

.canvas-status {
    position: absolute;
    inset: 12px 12px 92px;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 28px;
    border-radius: 6px;
    color: #fff;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.82);
}

.canvas-status[hidden] {
    display: none;
}

@keyframes board-jiggle {
    0% {
        transform: translateX(0);
    }

    18% {
        transform: translate(-9px, -2px) rotate(-0.65deg);
    }

    36% {
        transform: translate(9px, 1px) rotate(0.65deg);
    }

    54% {
        transform: translate(-6px, -1px) rotate(-0.4deg);
    }

    72% {
        transform: translate(6px, 1px) rotate(0.4deg);
    }

    100% {
        transform: translateX(0);
    }
}

@media (max-width: 860px) {
    .app-shell {
        align-items: flex-start;
        padding-top: 88px;
    }

    .game-layout {
        grid-template-columns: minmax(280px, 520px);
    }

    .board-frame {
        order: 1;
        width: min(520px, 100%);
        min-width: 0;
        justify-self: center;
    }

    .hud-panel {
        order: 2;
        width: min(520px, 100%);
        justify-self: center;
    }
}

@media (max-width: 560px) {
    .container {
        width: min(100% - 28px, 1200px);
    }

    .top-nav {
        padding: 14px 0;
    }

    .logo {
        font-size: 21px;
    }

    .nav-links {
        gap: 12px;
    }

    .nav-links span {
        display: none;
    }

    .hud-panel {
        padding: 18px;
    }

    .primary-score strong {
        font-size: 42px;
    }

    .hud-block strong {
        font-size: 24px;
    }

    .board-actions {
        gap: 10px;
    }
}
