* {
    box-sizing: border-box;
}

:root {
    --bg: #111214;
    --panel: #191b20;
    --text: #f5f7fb;
    --muted: #a7afbd;
    --line: rgba(255, 255, 255, 0.12);
    --lime: #b6f24a;
    --pink: #ff4f86;
    --red: #ff2f6d;
    --board: #d7a85d;
    --board-edge: #9c672f;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
    font: inherit;
}

.omok-app {
    width: min(1040px, calc(100% - 24px));
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem) 0;
}

.game-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.2rem;
}

.eyebrow {
    margin: 0 0 0.7rem;
    color: var(--lime);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.65rem;
    font-size: clamp(2.1rem, 6vw, 3.8rem);
    line-height: 1;
}

h2 {
    margin-bottom: 0.75rem;
    font-size: 1.15rem;
}

.game-header p,
.status-card p,
.rules-card li {
    color: var(--muted);
    line-height: 1.65;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1rem;
    align-items: start;
}

.board-card,
.side-panel > *,
.score-board {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.board-card {
    display: grid;
    place-items: center;
    padding: clamp(0.75rem, 2.5vw, 1.4rem);
}

.board {
    --cell: min(5.2vw, 38px);
    display: grid;
    grid-template-columns: repeat(15, var(--cell));
    grid-template-rows: repeat(15, var(--cell));
    padding: calc(var(--cell) * 0.48);
    background:
        linear-gradient(90deg, transparent calc(50% - 1px), rgba(72, 43, 16, 0.72) calc(50% - 1px), rgba(72, 43, 16, 0.72) calc(50% + 1px), transparent calc(50% + 1px)),
        linear-gradient(transparent calc(50% - 1px), rgba(72, 43, 16, 0.72) calc(50% - 1px), rgba(72, 43, 16, 0.72) calc(50% + 1px), transparent calc(50% + 1px)),
        var(--board);
    background-size: var(--cell) var(--cell);
    background-position: calc(var(--cell) * 0.5) calc(var(--cell) * 0.5);
    border: 10px solid var(--board-edge);
    border-radius: 8px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.18);
}

.cell {
    position: relative;
    display: grid;
    width: var(--cell);
    height: var(--cell);
    place-items: center;
    padding: 0;
    color: var(--text);
    background: transparent;
    border: 0;
    cursor: pointer;
}

.cell::before {
    content: "";
    width: 74%;
    height: 74%;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 120ms ease, transform 120ms ease;
}

.cell:hover::before,
.cell:focus-visible::before {
    opacity: 0.24;
    transform: scale(0.9);
    background: currentColor;
}

.cell.black,
.cell.white {
    cursor: default;
}

.cell.black::before,
.cell.white::before,
.cell.foul::before {
    opacity: 1;
    transform: scale(1);
}

.cell.black::before {
    background: radial-gradient(circle at 32% 28%, #626a76, #070809 68%);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.28);
}

.cell.white::before {
    background: radial-gradient(circle at 30% 25%, #ffffff, #d9dde5 70%);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.22);
}

.cell.win::after {
    content: "";
    position: absolute;
    width: 42%;
    height: 42%;
    border: 3px solid var(--pink);
    border-radius: 50%;
}

.cell.foul::before {
    background: radial-gradient(circle at 32% 28%, #ff9bb7, var(--red) 58%, #68001e 100%);
    box-shadow:
        0 0 0 3px rgba(255, 47, 109, 0.32),
        0 0 24px rgba(255, 47, 109, 0.82),
        0 8px 14px rgba(0, 0, 0, 0.34);
}

.cell.foul::after {
    content: "!";
    position: absolute;
    display: grid;
    width: 50%;
    height: 50%;
    place-items: center;
    color: #fff;
    background: rgba(255, 47, 109, 0.92);
    border: 2px solid rgba(255, 255, 255, 0.72);
    border-radius: 50%;
    font-size: 0.85rem;
    font-weight: 900;
    box-shadow: 0 0 18px rgba(255, 47, 109, 0.8);
}

.shake {
    animation: shake 120ms ease-in-out 0s 6;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-3px);
    }

    75% {
        transform: translateX(3px);
    }
}

.side-panel {
    display: grid;
    gap: 1rem;
}

.status-card,
.rules-card {
    padding: 1.1rem;
}

.status-label {
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 800;
}

.turn-view {
    display: flex;
    gap: 0.7rem;
    align-items: center;
    margin: 0.7rem 0 0.5rem;
    font-size: 1.45rem;
}

.turn-stone {
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.turn-stone.black {
    background: radial-gradient(circle at 32% 28%, #626a76, #070809 68%);
}

.turn-stone.white {
    background: radial-gradient(circle at 30% 25%, #ffffff, #d9dde5 70%);
}

.message-error {
    color: var(--pink);
    font-weight: 900;
    text-shadow: 0 0 18px rgba(255, 47, 109, 0.52);
}

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.button {
    min-height: 46px;
    padding: 0.8rem 1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 900;
}

.button.primary {
    color: #111214;
    background: var(--lime);
}

.button.ghost {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--line);
}

.rules-card ul {
    display: grid;
    gap: 0.55rem;
    margin: 0;
    padding-left: 1.15rem;
}

.score-board {
    display: grid;
    grid-template-columns: repeat(2, 90px);
    gap: 0.7rem;
    padding: 0.8rem;
}

.score-board div {
    display: grid;
    gap: 0.25rem;
}

.score-board span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.score-board strong {
    font-size: 1.7rem;
}

@media (max-width: 820px) {
    .game-header,
    .game-layout {
        grid-template-columns: 1fr;
    }

    .game-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .side-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rules-card {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .side-panel {
        grid-template-columns: 1fr;
    }

    .rules-card {
        grid-column: auto;
    }

    .score-board {
        width: 100%;
        grid-template-columns: repeat(2, 1fr);
    }

    .board {
        --cell: calc((100vw - 86px) / 15);
        border-width: 8px;
    }
}
