﻿:root {
    --bg-top: #f0fdf4;
    --bg-bottom: #f8fafc;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: rgba(255, 255, 255, 0.96);
    --line: rgba(226, 232, 240, 0.8);
    --text: #1e293b;
    --muted: #64748b;
    --accent: #22c55e;
    --accent-strong: #16a34a;
    --shadow-soft: 0 18px 42px rgba(100, 116, 139, 0.12);
    --shadow-strong: 0 20px 32px rgba(100, 116, 139, 0.18);
}

* {
    box-sizing: border-box;
}

/* body는 .game-shell-body (공유 CSS)에서 100dvh flex column 처리 */
body {
    color: var(--text);
    font-family: 'Noto Sans KR', sans-serif;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 30%),
        linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

#app {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

button {
    font: inherit;
}

.page-glow {
    position: fixed;
    border-radius: 999px;
    filter: blur(18px);
    opacity: 0.45;
    pointer-events: none;
    z-index: 0;
    animation: drift 14s ease-in-out infinite;
}

.glow-a {
    top: 110px;
    left: -50px;
    width: 220px;
    height: 220px;
    background: rgba(134, 239, 172, 0.45);
}

.glow-b {
    top: 280px;
    right: -60px;
    width: 240px;
    height: 240px;
    background: rgba(34, 197, 94, 0.18);
    animation-delay: -6s;
}

.glow-c {
    bottom: 50px;
    left: 18%;
    width: 180px;
    height: 180px;
    background: rgba(16, 185, 129, 0.18);
    animation-delay: -9s;
}

.game-shell {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.5rem 0.75rem 0.5rem;
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.board-card,
.panel-block {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 28px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-soft);
}

.hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1.2rem;
    margin-bottom: 1rem;
}

.eyebrow,
.toolbar-label,
.overlay-eyebrow {
    margin: 0 0 0.35rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-size: 0.76rem;
    color: var(--accent);
}

.hero-panel h1,
.overlay-card h2 {
    margin: 0;
    font-family: 'Do Hyeon', sans-serif;
    font-weight: 400;
    line-height: 1;
}

.hero-panel h1 {
    font-size: clamp(1.5rem, 2.5vw, 2rem);
}

.hero-copy,
.status-detail,
.thinking-indicator,
.control-list,
.move-list,
.info-label {
    color: var(--muted);
}

.hero-copy,
.status-detail,
.thinking-indicator,
.control-list li,
.move-list li {
    line-height: 1.6;
}

.hero-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.hero-divider {
    width: 1px;
    height: 1.4em;
    background: var(--line);
    margin: 0 0.2rem;
}

.hero-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: nowrap;
}

.play-layout {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(200px, 0.4fr) minmax(0, 1.6fr);
    gap: 0.75rem;
    align-items: stretch;
    padding-left: 6rem; /* back-pill 공간 */
}

.side-panel {
    overflow-y: auto;
    max-height: 100%;
}

.board-card {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

.board-frame {
    height: 100%;
    aspect-ratio: 1;
    max-width: 100%;
}

@media (max-width: 760px) {
    .play-layout {
        grid-template-columns: 1fr;
        padding-left: 0;
        padding-top: 3.5rem; /* back-pill 공간 (모바일은 위) */
    }
    .side-panel {
        max-height: none;
        overflow: visible;
    }
}

.board-card {
    overflow: hidden;
}

#status-headline {
    display: block;
    font-size: 1.1rem;
    margin: 0.2rem 0 0.5rem;
}

.board-frame {
    position: relative;
    padding: 1rem;
}

.board-frame::before {
    content: '';
    position: absolute;
    inset: 1rem;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.board-frame.thinking::after {
    content: '';
    position: absolute;
    inset: 1rem;
    border-radius: 30px;
    border: 2px solid rgba(34, 197, 94, 0.35);
    animation: pulseOutline 1.4s ease-in-out infinite;
    pointer-events: none;
}

#board-canvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    aspect-ratio: 1;
    border-radius: 30px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
    touch-action: none;
}

.board-overlay {
    position: absolute;
    inset: 1rem;
    display: grid;
    place-items: center;
    z-index: 3;
    background: rgba(15, 23, 42, 0.22);
    border-radius: 30px;
}

.board-overlay.hidden {
    display: none;
}

.overlay-card {
    width: min(92%, 360px);
    padding: 1.4rem;
    border-radius: 24px;
    text-align: center;
    background: var(--panel-strong);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-strong);
}

.overlay-card h2 {
    font-size: 2.4rem;
    margin-bottom: 0.5rem;
}

.overlay-card p:last-of-type {
    margin: 0 0 1rem;
    color: var(--muted);
}

.side-panel {
    display: grid;
    gap: 0.65rem;
    /* 그리드 기본 align-content:stretch가 각 블록을 세로로 늘려 빈 공간을 만들었음 → 필요한 높이만 사용 */
    align-content: start;
}

.panel-block {
    padding: 0.9rem;
}

.panel-block h2 {
    margin: 0 0 0.65rem;
    font-size: 1rem;
}

.info-grid,
.action-grid {
    display: grid;
    gap: 0.5rem;
}

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

.info-card {
    padding: 0.6rem 0.75rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.info-label {
    display: block;
    font-size: 0.82rem;
    margin-bottom: 0.2rem;
}

.thinking-indicator {
    margin: 0.6rem 0 0;
    min-height: 1.6em;
}

.action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-btn,
.action-btn {
    border: 1px solid rgba(24, 95, 99, 0.16);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.76);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.btn-row {
    display: flex;
    gap: 0.5rem;
}

#difficulty-group .btn-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.btn-row > * {
    flex: 1 1 0;
    min-width: 0;
}

.mode-btn {
    padding: 0.55rem 0.45rem;
    font-size: 0.84rem;
    font-weight: 600;
}

.action-btn {
    padding: 0.7rem 0.8rem;
    box-shadow: 0 10px 20px rgba(74, 75, 54, 0.08);
}

.mode-btn:hover,
.action-btn:hover,
.mode-btn:focus-visible,
.action-btn:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-strong);
}

.mode-btn.active {
    color: var(--accent-strong);
    background: rgba(34, 197, 94, 0.12);
    border-color: var(--accent);
}

.action-btn.primary {
    color: #fff;
    background: linear-gradient(135deg, #22c55e 0%, #10b981 100%);
    border-color: transparent;
}

.action-btn:disabled {
    cursor: default;
    opacity: 0.55;
    transform: none;
    box-shadow: none;
}

.control-list,
.move-list {
    margin: 0;
    padding-left: 1.1rem;
}

.move-list {
    max-height: 260px;
    overflow: auto;
}

.move-list li {
    padding: 0.18rem 0;
}

.move-list .empty {
    list-style: none;
    margin-left: -1.1rem;
}

kbd {
    display: inline-block;
    min-width: 1.6rem;
    padding: 0.08rem 0.35rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(42, 36, 29, 0.12);
    box-shadow: inset 0 -2px 0 rgba(42, 36, 29, 0.06);
    color: var(--text);
    text-align: center;
    font-size: 0.92rem;
}

@keyframes drift {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-18px) scale(1.05); }
}

@keyframes pulseOutline {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.008); }
}

@media (max-width: 1024px) {
    .play-layout {
        grid-template-columns: 1fr;
    }

    .board-card {
        order: -1;
    }

    /* 모바일: 보드가 먼저(order:-1), 사이드패널은 아래
       헤더60 + 게임쉘패딩24 + board-frame패딩16 + 여유20 = 120px */
    #board-canvas {
        width: min(100%, calc(100dvh - 120px));
        margin: 0 auto;
    }
}

/* 데스크탑: 좌우 2컬럼 — 헤더60 + 게임쉘패딩(상24+하48) + 프레임패딩(상하32) = 164px */
@media (min-width: 1025px) {
    #board-canvas {
        width: min(100%, calc(100dvh - 164px));
    }
}

@media (max-width: 720px) {
    .game-shell {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .hero-panel {
        flex-wrap: wrap;
    }

    .hero-controls {
        flex-wrap: wrap;
    }

    .board-toolbar,
    .info-grid,
    .action-grid {
        grid-template-columns: 1fr;
    }

    .board-toolbar {
        display: grid;
        padding-bottom: 0.25rem;
    }
}

/* ===== 온라인 대전 패널 (online.js) ===== */
.hidden {
    display: none !important;
}

.online-input {
    width: 100%;
    padding: 0.55rem 0.7rem;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 10px;
    font: inherit;
    background: rgba(255, 255, 255, 0.9);
}

.online-input:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.online-join-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.online-join-row .online-input {
    margin-bottom: 0;
}

#online-create-btn {
    width: 100%;
}

.online-room-code {
    display: block;
    font-size: 2rem;
    letter-spacing: 0.35em;
    text-align: center;
    color: #2563eb;
    margin: 0.25rem 0 0.5rem;
}

.online-members {
    list-style: none;
    margin: 0 0 0.6rem;
    padding: 0;
    font-size: 0.92rem;
}

.online-members li {
    padding: 0.2rem 0;
}

.online-members li.muted {
    opacity: 0.6;
    font-size: 0.85rem;
}

.online-message {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    min-height: 1.2em;
    color: #16a34a;
}

.online-message.error {
    color: #dc2626;
}
