:root {
    --canvas: #f3f8f6;
    --surface: rgba(255, 255, 255, 0.94);
    --line: rgba(40, 73, 113, 0.16);
    --text: #1e2f4a;
    --muted: #64748b;
    --blue: #2563eb;
    --green: #16a34a;
    --gold: #f59e0b;
    --rose: #e11d48;
    --tile: #ffffff;
    --tile-alt: #eef6ff;
}

* { box-sizing: border-box; }

/* body는 .game-shell-body (공유 CSS)에서 100dvh flex column 처리. 여기서는 배경만. */
body {
    font-family: 'Noto Sans KR', sans-serif;
    color: var(--text);
    background: #eef7f4;
}

button {
    font: inherit;
}

/* ───── 메인 레이아웃: 슬림 HUD + 보드 프레임 ───── */
.game-main {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem 0.75rem;
    gap: 0.5rem;
}

.game-hud {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.5rem 1rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}
.game-hud .hud-group:first-of-type {
    grid-column: 2;
    justify-self: center;
}
.game-hud .hud-group.right {
    grid-column: 3;
    justify-self: end;
}
.hud-group {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.hud-stat {
    display: inline-flex;
    align-items: baseline;
    gap: 0.4rem;
    font-size: 0.85rem;
}
.hud-label {
    color: var(--muted);
    font-weight: 700;
}
.hud-stat strong {
    font-family: 'Jua', sans-serif;
    font-size: 1.4rem;
    line-height: 1;
    font-weight: 400;
    color: var(--text);
}
.hud-msg {
    font-size: 0.82rem;
    color: var(--muted);
    min-height: 1em;
}
.hud-btn {
    border: 1px solid var(--line);
    background: var(--blue);
    color: #fff;
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    font-weight: 800;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.14s ease;
    white-space: nowrap;
}
.hud-btn:hover { background: #1d4ed8; }

/* ───── 보드 프레임: 남는 공간을 정사각형으로 ───── */
.board-frame {
    flex: 1 1 0;
    min-height: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.board-panel {
    position: relative;
    width: var(--board-size, 100%);
    height: var(--board-size, 100%);
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 12px;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: var(--canvas);
    touch-action: manipulation;
}

/* ───── 결과 오버레이 ───── */
.result-overlay {
    position: absolute;
    inset: 12px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(248, 250, 252, 0.85);
    backdrop-filter: blur(2px);
}
.result-overlay.hidden { display: none; }

.result-card {
    width: min(360px, calc(100% - 28px));
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.96);
    padding: 22px;
    text-align: center;
}
.result-card .eyebrow {
    margin: 0 0 6px;
    color: var(--blue);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.result-card h2 {
    margin: 0;
    font-family: 'Jua', sans-serif;
    font-size: 2.4rem;
    font-weight: 400;
    color: var(--green);
}
.result-card p {
    margin: 8px 0 0;
    color: var(--muted);
}
.action-btn {
    min-height: 44px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
    border-radius: 10px;
    cursor: pointer;
    font-weight: 800;
    transition: background 0.14s ease, border-color 0.14s ease;
}
.action-btn:hover {
    background: #f5faf8;
    border-color: rgba(40, 73, 113, 0.28);
}
.action-btn.primary {
    background: var(--blue);
    color: #ffffff;
    border-color: var(--blue);
}
.action-btn.wide {
    width: 100%;
    margin-top: 14px;
}

/* ───── 반응형 ───── */
@media (max-width: 560px) {
    .game-main { padding: 0.4rem 0.5rem 0.5rem; gap: 0.4rem; }
    .game-hud { padding: 0.45rem 0.7rem 0.45rem 5rem; gap: 0.6rem; }
    .hud-group { gap: 0.8rem; }
    .hud-stat strong { font-size: 1.15rem; }
    .hud-stat { font-size: 0.78rem; }
    .hud-msg { display: none; }
    .hud-btn { font-size: 0.78rem; padding: 0.35rem 0.7rem; }
    .board-panel { padding: 8px; border-radius: 14px; }
}
