/**
 * ============================================================================
 * TTEUM ghost-grid: 다크 네온 논리 퍼즐 스타일시트 (ghost-grid.css) - v1.2.0
 * 화려한 네온 X 마커, 구역별 컬러 매칭 유령, 생명 하트 HUD, 시작/게임오버 오버레이
 * ============================================================================
 */

:root {
    --bg-main: #05070e;
    --card-bg: #0b1120;
    --border-color: #1e293b;
    --border-bright: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --neon-cyan: #00f5d4;
    --neon-yellow: #fee440;
    --neon-magenta: #f72585;
    --neon-purple: #7209b7;
    --neon-blue: #4cc9f0;
    --neon-orange: #ff5400;
    --danger-red: #ef4444;
    --success-green: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, 'Pretendard', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

/* ========================================================
   상단 글로벌 헤더 & 네비게이션
   ======================================================== */
.game-header {
    width: 100%;
    max-width: 380px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-badge {
    background: rgba(0, 245, 212, 0.12);
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-size: 10.5px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.header-title {
    font-size: 14px;
    font-weight: 900;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.header-lobby-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #1e293b;
    border: 1px solid #334155;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 5px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.header-lobby-btn:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

/* ========================================================
   메인 게임 레이아웃 (한눈에 쏙 들어오는 콤팩트 핏)
   ======================================================== */
.game-main-wrap {
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 6px 10px 18px;
}

/* 보드 크기 선택 탭 바 (8단계 5x5~12x12 완벽 수용) */
.size-selector-bar {
    width: 100%;
    max-width: 360px;
    display: flex;
    gap: 2px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 2.5px;
    border-radius: 6px;
}

.size-tab-btn {
    flex: 1;
    background: #131b2e;
    border: 1px solid #1e293b;
    color: var(--text-muted);
    font-size: 8.5px;
    font-weight: 800;
    padding: 4px 0;
    border-radius: 3px;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.size-tab-btn:hover {
    border-color: var(--neon-cyan);
    color: #ffffff;
}

.size-tab-btn.active {
    background: rgba(0, 245, 212, 0.15);
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
    font-weight: 900;
    box-shadow: 0 0 6px rgba(0, 245, 212, 0.35);
}

/* 상단 HUD 바 */
.game-hud-bar {
    width: 100%;
    max-width: 350px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 7px;
    padding: 4px 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    flex-shrink: 0;
}

.hud-time-box {
    color: var(--neon-yellow);
    font-family: monospace;
    font-weight: 900;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.hud-lives-box {
    font-size: 12px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 1px;
    white-space: nowrap;
}

.hud-ghost-counter {
    font-size: 11px;
    font-weight: 800;
    color: var(--neon-cyan);
    display: flex;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

.btn-hud-tool {
    background: #1e293b;
    border: 1px solid #334155;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    padding: 3px 5px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.btn-hud-tool:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

.btn-hud-tool:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    border-color: #1e293b;
}

/* ========================================================
   메인 퍼즐 그리드 보드 (350x350 콤팩트 아케이드 핏)
   ======================================================== */
.ghost-board-wrap {
    position: relative;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1 / 1;
    background: #04060c;
    border: 2px solid #334155;
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 0 25px rgba(0, 245, 212, 0.1), 0 10px 30px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ghost-board-grid {
    width: 100%;
    height: 100%;
    display: grid;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #080c16;
}

/* 개별 셀 스타일 */
.ghost-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.08s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ghost-cell:hover {
    filter: brightness(1.28);
}

.ghost-cell:active {
    transform: scale(0.94);
}

/* 굵은 구역 외곽 경계선 */
.ghost-cell.border-top-thick { border-top: 3.5px solid var(--zone-border-color, #00f5d4) !important; }
.ghost-cell.border-bottom-thick { border-bottom: 3.5px solid var(--zone-border-color, #00f5d4) !important; }
.ghost-cell.border-left-thick { border-left: 3.5px solid var(--zone-border-color, #00f5d4) !important; }
.ghost-cell.border-right-thick { border-right: 3.5px solid var(--zone-border-color, #00f5d4) !important; }

/* 패턴 텍스처 */
.ghost-cell.pattern-dots {
    background-image: radial-gradient(rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 8px 8px;
}
.ghost-cell.pattern-diagonal {
    background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.07) 2px, transparent 2px, transparent 8px);
}
.ghost-cell.pattern-cross {
    background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1.5px, transparent 1.5px), radial-gradient(rgba(255, 255, 255, 0.12) 1.5px, transparent 1.5px);
    background-position: 0 0, 4px 4px;
    background-size: 8px 8px;
}
.ghost-cell.pattern-grid {
    background-image: linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px);
    background-size: 8px 8px;
}

/* 👻 유령 아이콘 렌더링 (구역 네온 컬러 완벽 연동) */
.ghost-icon-wrap {
    width: 68%;
    height: 68%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ghostPopIn 0.24s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
    filter: drop-shadow(0 0 10px var(--ghost-color, #00f5d4));
}

.ghost-icon-wrap svg {
    width: 100%;
    height: 100%;
}

/* ✕ 배경 어디서나 뚜렷하게 식별되는 세련된 실버/화이트 봉인 마커 */
.marker-neon-x {
    width: 76%;
    height: 76%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: xPopIn 0.12s ease-out forwards;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.95));
    opacity: 0.95;
}

.marker-neon-x svg {
    width: 100%;
    height: 100%;
}

/* 오답 에러 쉐이크 애니메이션 */
.cell-mistake-shake {
    animation: mistakeShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both !important;
    background-color: rgba(239, 68, 68, 0.5) !important;
}

@keyframes mistakeShake {
    10%, 90% { transform: translate3d(-2px, 0, 0); }
    20%, 80% { transform: translate3d(3px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* 충돌/규칙 위반 셀 (붉은색 네온 펄스) */
.ghost-cell.violation {
    background-color: rgba(239, 68, 68, 0.42) !important;
    animation: violationPulse 0.8s ease infinite alternate;
}

.ghost-cell.violation .ghost-icon-wrap {
    filter: drop-shadow(0 0 12px #ef4444) !important;
}

@keyframes violationPulse {
    from { box-shadow: inset 0 0 10px rgba(239, 68, 68, 0.4); }
    to { box-shadow: inset 0 0 22px rgba(239, 68, 68, 0.95); }
}

@keyframes ghostPopIn {
    from { transform: scale(0.2) rotate(-18deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes xPopIn {
    from { transform: scale(0.3) rotate(45deg); opacity: 0; }
    to { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* 퍼즐 클리어 시 승리 글로우 */
.board-completed {
    border-color: var(--neon-cyan) !important;
    box-shadow: 0 0 45px rgba(0, 245, 212, 0.55), 0 0 80px rgba(0, 245, 212, 0.25) !important;
}

/* ========================================================
   하단 조작 가이드 안내 바
   ======================================================== */
.game-controls-bar {
    width: 100%;
    max-width: 350px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    padding: 2px 2px;
}

.guide-badge-box {
    display: flex;
    align-items: center;
    gap: 4px;
}

.guide-pill {
    background: #1e293b;
    border: 1px solid #334155;
    padding: 2px 5px;
    border-radius: 4px;
    font-weight: 800;
    color: #e2e8f0;
    font-size: 10px;
}

/* ========================================================
   모달 오버레이 공통 (시작, 클리어, 게임오버, 설정)
   ======================================================== */
.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(4, 7, 14, 0.88);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: overlayFadeIn 0.3s ease forwards;
}

@keyframes overlayFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.overlay-content-card {
    background: var(--card-bg);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 20px 24px;
    text-align: center;
    max-width: 340px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
}

.overlay-title {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: -0.5px;
}

.btn-overlay-action-main {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, var(--neon-cyan), #00b4d8);
    color: #04070e;
    font-size: 13px;
    font-weight: 900;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 0 15px rgba(0, 245, 212, 0.4);
}

.btn-overlay-action-main:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(0, 245, 212, 0.7);
}

.btn-overlay-action-sub {
    width: 100%;
    padding: 8px;
    background: #1e293b;
    border: 1px solid #334155;
    color: var(--text-main);
    font-size: 11.5px;
    font-weight: 800;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-overlay-action-sub:hover {
    border-color: var(--neon-cyan);
    color: var(--neon-cyan);
}

/* 토글 스위치 */
.toggle-switch-row {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid #1e293b;
}

.toggle-switch-input {
    width: 36px;
    height: 20px;
    accent-color: var(--neon-cyan);
    cursor: pointer;
}
