:root {
    color-scheme: dark;
    --panel: rgba(8, 20, 38, 0.84);
    --line: rgba(255, 255, 255, 0.16);
    --text: #f6fbff;
    --muted: #b6c7d8;
    --accent: #52e2ff;
}

* { box-sizing: border-box; }
html, body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at 18% 16%, rgba(82, 226, 255, 0.16), transparent 28%),
        linear-gradient(180deg, #06101e 0%, #11172f 54%, #050917 100%);
    color: var(--text);
    font-family: Arial, "Noto Sans KR", sans-serif;
}

body {
    display: grid;
    place-items: start center;
    padding: 18px;
}

.layout {
    width: min(100%, 1030px);
    display: grid;
    grid-template-columns: minmax(400px, 470px) 280px 240px;
    gap: 18px;
    align-items: stretch;
    justify-content: center;
}

.board-wrap,
.panel,
.stat {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 22px 58px rgba(0, 0, 0, 0.34);
}

.board-wrap {
    position: relative;
    display: grid;
    place-items: center;
    padding: 14px;
    min-height: 100%;
}

canvas {
    display: block;
    border-radius: 6px;
    background: #060b16;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

#board {
    width: auto;
    height: 100%;
    max-width: 100%;
    max-height: calc(100vh - 72px);
    aspect-ratio: 1 / 2;
}

.overlay {
    position: absolute;
    inset: 14px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: rgba(3, 8, 18, 0.78);
    backdrop-filter: blur(8px);
    text-align: center;
}

.overlay[hidden] { display: none; }
.overlay-card { display: grid; gap: 12px; width: min(320px, calc(100% - 24px)); padding: 20px; }
.overlay-title { font-size: 32px; font-weight: 900; line-height: 1; }
.overlay-text { color: var(--muted); line-height: 1.6; }

.side,
.ranking-side { display: grid; gap: 12px; align-content: start; }
.side { width: 100%; }
.ranking-side { width: 100%; }
.side,
.ranking-side {
    align-self: stretch;
}
.panel { padding: 16px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1; }
h2 { margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.subtitle { margin-top: 8px; color: var(--muted); line-height: 1.6; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { padding: 12px; background: rgba(255,255,255,0.06); }
.label { color: var(--muted); font-size: 12px; font-weight: 700; }
.value { margin-top: 6px; font-size: 26px; font-weight: 900; }

.next-canvas { width: 132px; height: 132px; }
.controls { display: grid; gap: 7px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.ranking-panel {
    display: grid;
    gap: 12px;
}

.ranking-list {
    display: grid;
    gap: 8px;
}

.ranking-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
}

.ranking-rank {
    color: #ffd166;
    font-weight: 900;
    text-align: center;
}

.ranking-name {
    color: var(--text);
    font-weight: 700;
}

.ranking-score {
    color: var(--accent);
    font-weight: 900;
}

.ranking-empty {
    padding: 14px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: rgba(255,255,255,0.04);
    text-align: center;
}

.buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.buttons.left { justify-content: flex-start; }
.action-grid { display: grid; gap: 10px; }

.key {
    display: inline-flex;
    min-width: 34px;
    min-height: 28px;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255,255,255,0.08);
    color: var(--text);
    font-weight: 800;
}

button,
a.button {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 15px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #03111c;
    font-weight: 900;
    text-decoration: none;
    cursor: pointer;
}

button.secondary,
a.button.secondary {
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.1);
    color: var(--text);
}

@media (max-width: 980px) {
    .layout {
        width: min(100%, 760px);
        grid-template-columns: minmax(360px, 470px) minmax(220px, 270px);
    }

    .ranking-side {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .layout { grid-template-columns: 1fr; }
    .side { order: -1; }
    .ranking-side { order: 2; }
}

@media (max-width: 560px) {
    body { padding: 10px; }
    .value { font-size: 20px; }
}
