/* ── Connect Four 전용 스타일 ── */

* { box-sizing: border-box; }

body {
    color: #f1f5f9;
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    min-height: 100dvh;
}

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

button { font: inherit; }

/* glow 데코 */
.page-glow {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(80px);
    opacity: 0.25;
}
.glow-a { width: 400px; height: 400px; top: -100px; left: -100px; background: #2563eb; }
.glow-b { width: 300px; height: 300px; bottom: 0; right: 0; background: #7c3aed; }
.glow-c { width: 250px; height: 250px; top: 40%; left: 50%; background: #1d4ed8; }

:root {
    --c4-p1: #ef4444;
    --c4-p2: #facc15;
    --c4-board: #1d4ed8;
    --c4-board-dark: #1e3a8a;
    --c4-hole: #0f172a;
    --c4-empty: #1e293b;
    --c4-cell: 58px;
    --c4-gap: 6px;
}

/* ── HUD 헤더 ── */
.c4-hud {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0.55rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.c4-back-btn {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #f1f5f9;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    white-space: nowrap;
    font-family: 'Noto Sans KR', sans-serif;
}
.c4-back-btn:hover { background: rgba(255, 255, 255, 0.18); }
.c4-back-btn:active { transform: scale(0.96); }

.c4-hud-center {
    grid-column: 2;
    justify-self: center;
}

.c4-hud-title {
    font-family: 'Do Hyeon', sans-serif;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.05em;
}

.c4-hud-right {
    grid-column: 3;
}

/* ── 레이아웃 ── */
.play-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    flex-wrap: wrap;
}

.board-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* ── 패널 ── */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 180px;
    max-width: 220px;
}

.panel-block {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-row {
    display: flex;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 6px 4px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.6);
    font-size: 0.78rem;
    font-family: 'Noto Sans KR', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.mode-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.mode-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    font-weight: 700;
}

.action-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    background: transparent;
    color: rgba(255,255,255,0.75);
    font-size: 0.85rem;
    font-family: 'Noto Sans KR', sans-serif;
    cursor: pointer;
    transition: all 0.15s;
}
.action-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.action-btn.primary {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    font-weight: 700;
}
.action-btn.primary:hover { background: #1d4ed8; }
.action-btn.wide { width: 100%; padding: 12px; font-size: 1rem; }

/* ── 점수판 ── */
.score-board {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
}
.score-item {
    flex: 1;
    text-align: center;
}
.score-label {
    display: block;
    font-size: 0.7rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.score-item.p1 .score-val { color: var(--c4-p1); }
.score-item.p2 .score-val { color: var(--c4-p2); }
.score-val {
    display: block;
    font-size: 1.6rem;
    font-family: 'Do Hyeon', sans-serif;
    line-height: 1;
}
.score-sep {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.3);
    padding: 0 2px;
}

/* ── 상태 메시지 ── */
.status-msg {
    font-size: 0.85rem;
    font-family: 'Noto Sans KR', sans-serif;
    color: rgba(255,255,255,0.85);
    text-align: center;
    min-height: 1.4em;
    line-height: 1.4;
}

/* ── 호버 미리보기 행 ── */
.preview-row {
    display: grid;
    grid-template-columns: repeat(7, var(--c4-cell));
    gap: var(--c4-gap);
    padding: 0 var(--c4-gap);
    height: 20px;
    margin-bottom: 2px;
}
.preview-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.preview-disc {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    opacity: 0.7;
    animation: previewPulse 0.8s ease-in-out infinite;
}
@keyframes previewPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.15); opacity: 1; }
}

/* ── 보드 ── */
.cf-board {
    display: grid;
    grid-template-columns: repeat(7, var(--c4-cell));
    grid-template-rows: repeat(6, var(--c4-cell));
    gap: var(--c4-gap);
    background: var(--c4-board);
    border: 4px solid var(--c4-board-dark);
    border-radius: 14px;
    padding: var(--c4-gap);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
}

.cf-cell {
    width: var(--c4-cell);
    height: var(--c4-cell);
    border-radius: 50%;
    background: var(--c4-hole);
    position: relative;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: inset 0 3px 8px rgba(0,0,0,0.6);
}
.cf-cell:hover { transform: scale(1.04); }
.cf-cell.p1 { background: var(--c4-p1); box-shadow: inset 0 -3px 8px rgba(0,0,0,0.3), 0 0 12px rgba(239,68,68,0.3); }
.cf-cell.p2 { background: var(--c4-p2); box-shadow: inset 0 -3px 8px rgba(0,0,0,0.3), 0 0 12px rgba(250,204,21,0.3); }
.cf-cell.ghost { opacity: 0.45; }
.cf-cell.ghost.ghost-p1 { background: var(--c4-p1); }
.cf-cell.ghost.ghost-p2 { background: var(--c4-p2); }

.cf-cell.win-cell {
    animation: winPulse 0.6s ease-in-out infinite alternate;
    z-index: 2;
}
@keyframes winPulse {
    from { transform: scale(1); filter: brightness(1); }
    to   { transform: scale(1.12); filter: brightness(1.4); }
}

/* 낙하 애니메이션 */
@keyframes dropIn {
    from { transform: translateY(calc(-1 * var(--drop-dist, 6) * (var(--c4-cell) + var(--c4-gap)))); }
    to   { transform: translateY(0); }
}
.cf-cell.dropping {
    animation: dropIn 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ── 결과 오버레이 ── */
.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.result-overlay.hidden { display: none; }
.result-card {
    background: #1e293b;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    text-align: center;
    min-width: 240px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}
.result-emoji { font-size: 3rem; line-height: 1; }
.result-title {
    font-size: 1.4rem;
    font-family: 'Do Hyeon', sans-serif;
    color: #fff;
}

/* ── 반응형 ── */
@media (max-width: 600px) {
    :root {
        --c4-cell: 42px;
        --c4-gap: 4px;
    }
    .play-layout {
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
    }
    .side-panel {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 100%;
        min-width: unset;
        width: 100%;
    }
    .panel-block { flex: 1; min-width: 140px; }
}

@media (max-width: 420px) {
    :root {
        --c4-cell: 36px;
        --c4-gap: 3px;
    }
}
