html {
    zoom: 0.8;
}

/* 다크 테마 변수 설정 */
:root {
    --bg-dark: hsl(132, 6%, 65%);
    --bg-white: #ffffff;
    --text-main: #000000;
    --accent: #ffffff;
    --orange: #000000;
    /* Changed from olive to strict black */
    --cell-size: 50px;
    /* Increased for better visibility */
    --board-border: 5px;
    --line-color: rgba(0, 0, 0, 0.2);
}

/* --- Theme Colors --- */
.theme-tomato {
    --bg-dark: #FF6347;
}

.theme-yellowgreen {
    --bg-dark: #9ACD32;
}

.theme-steelblue {
    --bg-dark: #4682B4;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-snow {
    --bg-dark: #FFFAFA;
}

.theme-tan {
    --bg-dark: #D2B48C;
}

.theme-slateblue {
    --bg-dark: #6A5ACD;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-navajowhite {
    --bg-dark: #FFDEAD;
}

.theme-slategrey {
    --bg-dark: #708090;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-mediumpurple {
    --bg-dark: #9370DB;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-orangered {
    --bg-dark: #FF4500;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-lightsteelblue {
    --bg-dark: #B0C4DE;
    --line-color: rgba(0, 0, 0, 0.15);
}

.theme-lightcoral {
    --bg-dark: #F08080;
}

.theme-khaki {
    --bg-dark: #F0E68C;
}

.theme-dimgrey {
    --bg-dark: #696969;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-gold {
    --bg-dark: #FFD700;
    --line-color: rgba(0, 0, 0, 0.15);
}

.theme-darkseagreen {
    --bg-dark: #8FBC8F;
}

.theme-darkkhaki {
    --bg-dark: #BDB76B;
}

.theme-darkorange {
    --bg-dark: #FF8C00;
}

.theme-darkcyan {
    --bg-dark: #008B8B;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-darkgrey {
    --bg-dark: #A9A9A9;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-beige {
    --bg-dark: #F5F5DC;
    --line-color: rgba(0, 0, 0, 0.15);
}

.theme-cadetblue {
    --bg-dark: #5F9EA0;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-chocolate {
    --bg-dark: #D2691E;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-peru {
    --bg-dark: #CD853F;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-goldenrod {
    --bg-dark: #DAA520;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-sienna {
    --bg-dark: #A0522D;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-coral {
    --bg-dark: #FF7F50;
}

.theme-indianred {
    --bg-dark: #CD5C5C;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-rosybrown {
    --bg-dark: #BC8F8F;
}

.theme-mediumseagreen {
    --bg-dark: #3CB371;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-mediumorchid {
    --bg-dark: #BA55D3;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-palevioletred {
    --bg-dark: #DB7093;
}

.theme-mediumvioletred {
    --bg-dark: #C71585;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-mediumturquoise {
    --bg-dark: #48D1CC;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-lightslategray {
    --bg-dark: #778899;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-royalblue {
    --bg-dark: #4169E1;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-cornflowerblue {
    --bg-dark: #6495ED;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-olive {
    --bg-dark: #808000;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-darkolivegreen {
    --bg-dark: #556B2F;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-olivedrab {
    --bg-dark: #6B8E23;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-firebrick {
    --bg-dark: #B22222;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-mediumslateblue {
    --bg-dark: #7B68EE;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-darkslateblue {
    --bg-dark: #483D8B;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-darkslategray {
    --bg-dark: #2F4F4F;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-slategray {
    --bg-dark: #708090;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-dimgray {
    --bg-dark: #696969;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-brown {
    --bg-dark: #A52A2A;
    --line-color: rgba(255, 255, 255, 0.3);
}

.theme-lavender {
    --bg-dark: #E6E6FA;
    --line-color: rgba(0, 0, 0, 0.15);
}

.theme-wheat {
    --bg-dark: #F5DEB3;
    --line-color: rgba(0, 0, 0, 0.15);
}

.theme-ivory {
    --bg-dark: #FFFFF0;
    --line-color: rgba(0, 0, 0, 0.15);
}

.theme-gainsboro {
    --bg-dark: #DCDCDC;
    --line-color: rgba(0, 0, 0, 0.15);
}

/* Light background text overrides */
html.bg-light {
    color: #000;
}
html.bg-light .icon-btn { color: rgba(0,0,0,0.6); }
html.bg-light .icon-btn:hover { color: #000; }
html.bg-light #register-panel input,
html.bg-light #register-panel select,
html.bg-light #login-panel input,
html.bg-light #login-panel select { color: #000 !important; }
html.bg-light #register-panel input::placeholder,
html.bg-light #login-panel input::placeholder { color: rgba(0,0,0,0.4); }
html.bg-light .live-matches-title { color: #000; }
html.bg-light .match-players,
html.bg-light .match-players span { color: #000; }
html.bg-light .no-matches { color: #000; }
html.bg-light .live-match-item { border-color: rgba(0,0,0,0.3); }
html.bg-light .onboarding-list li.done { color: rgba(0,0,0,0.5); }
/* 인라인 흰색 텍스트 → 검정 (오렌지 배경 버튼 제외) */
html.bg-light [style*="color:#fff"]:not([style*="background:var(--orange)"]) { color: #000 !important; }
html.bg-light [style*="color: #fff"]:not([style*="background:var(--orange)"]) { color: #000 !important; }
html.bg-light [style*="color:rgba(255,255,255"] { color: #000 !important; }
html.bg-light [style*="color: rgba(255,255,255"] { color: #000 !important; }
/* 버튼 텍스트 흰색 유지 */
html.bg-light .btn-match-start,
html.bg-light .btn-cancel-match { color: #fff !important; }
html.bg-light .icon-btn::after { color: #fff !important; }
html.bg-light .onboarding-list li.done .check { color: #fff !important; }
/* 밝은 배경에서 백돌 테두리 강조 */
.theme-lavender .stone.white,
.theme-gold .stone.white,
.theme-lightsteelblue .stone.white,
.theme-wheat .stone.white,
.theme-ivory .stone.white,
.theme-beige .stone.white,
.theme-gainsboro .stone.white {
    box-shadow: 0 4px 4px rgba(0,0,0,0.2), 0 0 0 1.5px rgba(0,0,0,0.35);
}
/* 인라인 배경색 조정 */
html.bg-light [style*="background:rgba(255,255,255,0.1)"] { background: rgba(0,0,0,0.06) !important; }
html.bg-light [style*="background:rgba(255,255,255,0.15)"] { background: rgba(0,0,0,0.08) !important; }
/* 인라인 흰색 테두리 조정 */
html.bg-light [style*="border:1px solid rgba(255,255,255"] { border-color: rgba(0,0,0,0.2) !important; }
html.bg-light [style*="border-bottom:1px solid rgba(255,255,255"] { border-bottom-color: rgba(0,0,0,0.15) !important; }
html.bg-light [style*="border-top:1px solid rgba(255,255,255"] { border-top-color: rgba(0,0,0,0.1) !important; }

/* icon-btn이 grid/flex에서 세로로 늘어나더라도 툴팁이 항상 아이콘 바로 위에 오도록 */
.icon-btn {
    align-self: start !important;
    height: fit-content !important;
}
html .icon-btn::after {
    bottom: auto !important;
    top: 0 !important;
    transform: translateX(-50%) translateY(calc(-100% - 4px)) !important;
}

/* ── 공통 CSS 클래스 오버라이드 ── */
html.bg-light .user-stat,
html.bg-light .user-name,
html.bg-light .vs-label { color: #000 !important; }

/* 테마 이름 라벨 (옵션 패널) */
.theme-name-label { font-size: 0.7rem; color: rgba(255,255,255,0.6); }
html.bg-light .theme-name-label { color: rgba(0,0,0,0.6) !important; }

/* rule-btn done 상태 (명시도 높게) */
html.bg-light .icon-btn.rule-btn.done { color: rgba(0,0,0,0.45) !important; }

/* 좌표 레이블 (rules/game 페이지) */
html.bg-light .coord-nums span,
html.bg-light .coord-letters span { color: rgba(0,0,0,0.6) !important; }

/* 아이콘 버튼 (모든 페이지) */
html.bg-light .icon-btn { color: rgba(0,0,0,0.6) !important; }
html.bg-light .icon-btn:hover,
html.bg-light .icon-btn:active { color: #000 !important; }

/* 상태바 (rules/game 페이지) */
html.bg-light #status-bar { color: #000 !important; }

/* records 페이지 */
html.bg-light .record-header { color: #000 !important; }
html.bg-light .record-date { color: rgba(0,0,0,0.55) !important; }
html.bg-light .rec-name { color: #000 !important; }
html.bg-light .rec-vs { color: rgba(0,0,0,0.45) !important; }
html.bg-light .rec-moves { color: rgba(0,0,0,0.6) !important; }
html.bg-light .btn-page { color: #000 !important; background: rgba(0,0,0,0.06) !important; border-color: rgba(0,0,0,0.2) !important; }
html.bg-light .record-item { border-bottom-color: rgba(0,0,0,0.1) !important; }

/* ranking 페이지 */
html.bg-light .ranking-table th { color: #000 !important; }
html.bg-light .ranking-table td { color: #000 !important; border-bottom-color: rgba(0,0,0,0.1) !important; }
html.bg-light .ranking-table tr:hover td { background: rgba(0,0,0,0.04) !important; }
html.bg-light .my-rank-bar { color: #000 !important; }

/* Original Default Theme: hsl(132, 6%, 65%) = --bg-dark */


html {
    /* 스크롤바 공간 항상 예약 → 페이지 이동 시 레이아웃 이동 방지 */
    overflow-y: scroll;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* 수직 중앙 정렬(center) 대신 상단 정렬(flex-start)로 변경 */
    justify-content: flex-start;
    min-height: 100vh;
    margin: 0;
    padding-top: 30px;
    /* 모든 페이지 상단에 동일한 기본 여백 부여 */
    background-color: var(--bg-dark);
    /* ... 나머지 동일 ... */
}

.logo-container {
    width: 100%;
    margin-bottom: 20px;
}

.login-btn,
.logout-btn {
    font-size: 0.9rem;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 5px;
    font-weight: bold;
    width: 100%;
    text-align: center;
    box-sizing: border-box;
    display: block;
}
.login-btn {
    color: white;
    background: var(--orange);
}
.logout-btn {
    color: #666;
    border: 1px solid #ddd;
    background: #fff;
}
.login-btn:hover { filter: brightness(1.1); }
.logout-btn:hover { background: #f5f5f5; }

.main-logo {
    max-width: 450px;
    height: auto;
}

/* Layout Grid System */
.main-grid {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 40px;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 20px;
    box-sizing: border-box;
}

.grid-left,
.grid-right {
    display: flex;
    flex-direction: column;
    width: 300px;
    flex-shrink: 0;
    gap: 20px;
}

.grid-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    flex-grow: 1;
}

/* Mobile Responsiveness */
@media (max-width: 1100px) {
    .main-grid {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        padding: 10px;
    }

    .grid-left,
    .grid-right {
        width: 100%;
        max-width: 500px;
    }

    .grid-center {
        width: 100%;
    }
}

.vertical-controls {
    display: flex;
    flex-direction: column;
    grid-template-columns: none !important;
    gap: 15px;
    width: 100% !important;
}

.vertical-controls button,
.vertical-controls a.btn-orange,
.vertical-controls span.btn-orange {
    width: 100%;
    padding: 15px 5px;
    text-align: center;
    box-sizing: border-box;
}
/* icon-btn은 vertical-controls 안에서도 기본 패딩 유지 (툴팁 위치 정확도) */
.vertical-controls .icon-btn {
    padding: 1px;
}



/* 상단 상태 표시창 수정: width: 100%를 제거하고 보드 너비에 맞춤 */
#status {
    font-size: 1.0rem;
    font-weight: bold;
    background: var(--bg-white);
    color: var(--text-main);
    margin: 20px auto;
    padding: 10px;
    text-align: center;
    width: 90%;
    max-width: 100%;
    box-sizing: border-box;
}


/* game.php 전용 */


.vs-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: 95%;
    max-width: 400px;
    margin-bottom: 10px;
}

.user-card {
    flex: 1;
    padding: 5px;
    text-align: center;
    transition: all 0.3s;
}

.user-name {
    font-weight: bold;
    font-size: 1.2rem;
    display: block;
}

.user-stat {
    font-size: 1.0rem;
    color: #fff;
}


.vs-label {
    font-weight: bold;
    color: #fff;
    font-size: 1.2rem;
}


.status-container {
    display: flex;
    /* 가로 정렬 */
    justify-content: center;
    /* 내부 요소들을 가로 방향 중앙으로 모음 */
    align-items: center;
    /* 수직 방향 가운데 정렬 */
    gap: 15px;
    /* 두 텍스트 사이의 간격 */
    background: rgba(255, 255, 255, 0.5) !important;
    width: 100%;
    max-width: 100%;
    /* 보드판 너비와 맞춤 */
    margin: 15px auto;
    /* 위아래 여백을 주고 화면 중앙 배치 */
    padding: 8px 15px;
    /* 안쪽 여백 */
    border-radius: 5px;
    /* 부드러운 모서리 */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* 상태바: width를 제거하고 flex를 사용하여 자동으로 늘어나게 합니다. */
#status-bar {
    font-size: 1.0rem;
    font-weight: bold;
    color: var(--text-main);
    margin: 0;
    /* 중요: 기존의 auto margin 제거 */
    text-align: right;
    /* 글자를 오른쪽으로 밀어 타이머와 붙임 */
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: break-word;
}

/* 타이머바: 반응형 설정 */
#timer-bar {
    width: 100%;
    height: 30px;
    line-height: 30px;
    margin-bottom: 25px;
    /* Increased interval for desktop */

    font-size: 1.0rem;
    color: #e74c3c;
    font-weight: bold;
    letter-spacing: 0.2em;
    /* Adjusted for longer text */
    text-align: center;
    /* Center text relative to bar */
    white-space: nowrap;
    box-sizing: border-box;
    /* overflow: hidden;  Already set in JS but good to have default */
}

@media (max-width: 600px) {
    #timer-bar {
        font-size: 0.75rem;
        /* Slightly smaller for longer sentence */
        letter-spacing: 0.05em;
        /* Tight spacing for mobile fitting */
        height: 25px;
        line-height: 25px;
        margin-bottom: 20px;
        /* Increased interval for mobile */
    }
}

/* Board Wrapper to isolate grid/stones from external layout (Timer) */
.board-wrapper {
    position: relative;
    display: inline-block;
    /* Fits content */
}

/* When inside wrapper, reset absolute positioning to 0 */
.board-wrapper #hit-layer {
    top: 0 !important;
    left: 0 !important;
    /* transform is kept from original rule */
}

/* 검은 돌 색상 설정 */
.stone.black {
    /*    background-color: #000000;*/
    background: radial-gradient(circle at 60% 60%, #444, #000);
    color: #ffffff;
    /* 순서 숫자가 보일 경우 흰색으로 */
}

/* 흰 돌 색상 설정 */
.stone.white {
    /*   background-color: #ffffff;*/
    background: radial-gradient(circle at 60% 60%, #fff, #ccc);
    color: #000000;
    /* 순서 숫자가 보일 경우 검은색으로 */
}



#game-container {
    position: relative;
    padding: 20px;
    /* Consistent padding for all sides */
    background: var(--bg-dark);
    display: block;
    width: fit-content;
    margin: 0 auto;
    /* Remove Flexbox centering to prevent board/hit-layer mismatch */
}

@keyframes danger-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
    50%  { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0.7); }
    100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

#game-container.danger-pulse {
    animation: danger-pulse 1.2s ease-in-out infinite;
    border: 2px solid rgba(231, 76, 60, 0.8);
}

#board {
    display: grid;
    grid-template-columns: repeat(10, var(--cell-size));
    grid-template-rows: repeat(10, var(--cell-size));
    outline: var(--board-border) solid var(--line-color);
    box-sizing: content-box;
    background-color: var(--bg-dark);
}

#board .cell:nth-child(10n) {
    border-right: 1px solid var(--line-color);
}
#board .cell:nth-child(n+91) {
    border-bottom: 1px solid var(--line-color);
}

/* Settings Switcher - Modern Dropdown */
.settings-switcher {
    display: none !important;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 5000;
}

.settings-dropdown {
    position: relative;
    display: inline-block;
}

.settings-trigger {
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    cursor: pointer;
    box-shadow: none;
}

.settings-trigger:hover {
    background: transparent;
    transform: rotate(30deg);
}

.settings-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-icon svg {
    width: 32px;
    height: 32px;
}

.settings-menu {
    display: none;
    position: absolute;
    top: 55px;
    /* Offset from the trigger */
    right: 0;
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
    min-width: 220px;
    padding: 18px;
    z-index: 5001;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.settings-menu.open {
    display: block;
    animation: langFadeIn 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.settings-section {
    margin-bottom: 12px;
}

.settings-section:last-child {
    margin-bottom: 0;
}

.settings-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.label-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.lang-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.lang-item {
    display: block;
    padding: 8px;
    border-radius: 8px;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border: 1px solid #eee;
    text-align: center;
}

.lang-item:hover {
    background: #f8f9fa;
    border-color: #ddd;
}

.lang-item.active {
    background: #f0f7ff;
    border-color: #007bff;
    color: #007bff;
    font-weight: 600;
}

.settings-separator {
    height: 1px;
    background: #eee;
    margin: 12px 0;
}

.theme-select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Custom Theme Picker UI */
.theme-picker-container {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 5px;
    background: #fafafa;
}

.theme-option-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    margin-bottom: 4px;
}

.theme-option-item:hover {
    background: #f1f1f1;
    border-color: #ddd;
}

.theme-option-item.active {
    background: #eef6ff;
    border-color: #007bff;
    font-weight: 600;
}

.color-preview-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.theme-name-label {
    font-size: 0.85rem;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lang-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.lang-item:hover {
    background: rgba(255, 165, 0, 0.1);
    color: #e67e22;
}

.lang-item.active {
    background: rgba(255, 165, 0, 0.05);
    color: #e67e22;
    font-weight: 600;
}

.lang-flag {
    font-size: 1.25rem;
    line-height: 1;
}

@keyframes langFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Mobile adjustments for lang switcher */
@media (max-width: 600px) {
    .lang-switcher {
        top: 10px;
        right: 10px;
    }

    .lang-trigger {
        padding: 6px 12px;
        font-size: 0.85rem;
    }
}

.cell {
    border-top: 1px solid var(--line-color);
    border-left: 1px solid var(--line-color);
    box-sizing: border-box;
}

#hit-layer {
    position: absolute;
    top: 20px;
    left: 20px;
    display: grid;
    grid-template-columns: repeat(11, var(--cell-size));
    grid-template-rows: repeat(11, var(--cell-size));
    transform: translate(calc(var(--cell-size) / -2), calc(var(--cell-size) / -2));
    pointer-events: none;
    z-index: 10;
}

.hit-point {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    /* Extremely high to avoid masking */
    pointer-events: auto;
    touch-action: manipulation; /* 더블탭 줌 방지, 300ms 탭 지연 제거 */
    -webkit-tap-highlight-color: transparent; /* iOS 탭 시 파란 깜빡임 제거 */
}

.stone {
    width: 88%;
    height: 88%;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: all 0.2s;
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.3);
}

/* 마지막 수 표시 및 하이라이트 공통 설정 */
.last-move,
.highlight,
.highlight-blue {
    z-index: 4;
    position: relative;
}



/* 돌 안쪽에 그리는 작은 원 (공통 가상 요소) */
.last-move::after,
.highlight::after,
.highlight-blue::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    /* 크기 설정: 돌(90%)보다 작고 숫자보다 크게 (약 12~14px 정도) */
    width: 30px;
    height: 30px;
    pointer-events: none;
}

/* 돌 착수 애니메이션 */
@keyframes stoneAppear {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}
.stone.place-anim {
    animation: stoneAppear 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
    transform-origin: center;
}

/* 1. 마지막 수 표시 (검은돌엔 흰색 원, 흰돌엔 검은색 원) */
.stone.black.last-move::after {
    border: 1.5px solid rgba(255, 255, 255);
    /* 반투명 흰색 원 */
}

.stone.white.last-move::after {
    border: 1.5px solid rgba(0, 0, 0);
    /* 반투명 검은색 원 */
}





.stone.highlight::after {
    border: 1.5px solid #ff0000 !important;
    /* 원의 두께 강화 */
    width: 30px;
    height: 30px;
}

.stone.highlight-blue::after {
    border: 1.5px solid #007BFF !important;
    /* 원의 두께 강화 */
    width: 30px;
    height: 30px;
}

/* AI 패턴 매칭 하이라이트: 돌 안쪽에 노란색 원 */
.stone.pattern-match {
    box-shadow: none;
    border: none;
}

.stone.pattern-match::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 1.5px solid #3498db;
    /* 파란색으로 변경 */
    z-index: 10;
}

/* AI 연결 위협 하이라이트: 청록색/파란색 글로우 */
.stone.connection-danger {
    box-shadow: 0 0 15px #3498db, 0 0 5px #3498db;
    border: 2px solid #3498db;
}



/* 잔상(Ghost) 효과: 대국판에 없는 돌을 반투명하게 표시 */
/* 잔상(Ghost) 효과: 대국판에 없는 돌을 반투명하게 표시 */
.stone.ghost {
    opacity: 0.25;
    /* Reduced from 0.4 */
    width: 80% !important;
    /* Set directly to 80% as requested */
    height: 80% !important;
    filter: grayscale(0.2);
    box-shadow: none;
    border: 2px dotted rgba(255, 255, 255, 0.4);
    /* Slightly thinner/fainter border */
}

.stone.black.ghost {
    background: rgba(0, 0, 0, 0.5);
    /* Keep consistent */
}

.stone.white.ghost {
    background: rgba(255, 255, 255, 0.6);
    /* Keep consistent */
}

/* 수순 숫자와 겹치지 않게 숫자의 우선순위 조정 */
.stone span,
.stone {
    position: relative;
    z-index: 1;
    /* 돌 자체의 숫자나 텍스트가 원 위에 오도록 설정 */
}

/* 🛠️ 추가된 하이라이트 효과: 승리/포획 시 빨간색 테두리 */

.controls {
    margin: 15px auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: calc(var(--cell-size) * 10 + var(--board-border) * 2);
    width: 90%;
    box-sizing: border-box;
}

button,
a.btn-orange {
    padding: 14px 5px;
    font-size: 1.0rem;
    font-weight: bold;
    border: 2px solid #000;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    background: #000;
    /* Default background is now black */
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
}

button:hover:not(:disabled) {
    background: #333;
    border-color: #000;
    filter: none;
}

button:active {
    transform: scale(0.95);
}

.btn-orange {
    background: var(--orange);
    border: none;
    transition: background 0.2s, color 0.2s;
}

.btn-orange:hover {
    background: #000000 !important;
    color: #ffffff !important;
    border-color: #000000 !important;
}

/* Right column buttons: index.php .btn-menu 기준 통일 */
.grid-right .btn-orange {
    background: #f5f5f5 !important;
    color: #333 !important;
    border: none !important;
    padding: 15px !important;
    font-size: 1rem !important;
    font-weight: bold !important;
    width: 100%;
    box-sizing: border-box;
    border-radius: 5px;
}
.grid-right .btn-orange:hover {
    background: #eee !important;
    color: #333 !important;
}
.grid-right .btn-disabled {
    background: #ddd !important;
    color: #aaa !important;
    cursor: not-allowed !important;
    pointer-events: none;
    display: block !important;
    text-align: center !important;
}
/* AI Lesson Note UI */
#ai-lesson-note {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    /* Pure black background */
    border: 2px solid #ffffff;
    /* High contrast white border */
    border-radius: 12px;
    padding: 20px;
    color: white;
    z-index: 2000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
    text-align: center;
    backdrop-filter: blur(10px);
    animation: fadeInNote 0.3s ease-out;
}

.note-header {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 15px;
    color: #ffffff;
}

.note-body {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 15px;
}

@keyframes fadeInNote {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }

    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.btn-lobby {
    background: #333;
    /* Darker gray for differentiation from main black buttons */
    color: #fff;
    grid-column: span 3;
    margin-top: 5px;
    border: none;
}

.btn-lobby:hover {
    background: #444;
}

/* --- Responsive Design (Mobile & Tablet) --- */

@media (max-width: 1200px) {
    .main-grid {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .grid-left {
        order: 1;
        width: 100%;
        max-width: 500px;
    }

    .grid-center {
        order: 2;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .grid-right {
        order: 3;
        width: 100%;
        max-width: 500px;
    }

    .logo-container {
        margin-bottom: 10px;
    }
}

@media (max-width: 600px) {
    .main-grid {
        padding: 10px;
        /* Reduced padding on mobile */
    }

    :root {
        --cell-size: 8.5vw;
        /* 11x11 보드: 10칸 × 8.5vw = 85vw */
    }

    #game-container {
        padding: 2vw;
        display: block;
        /* Use block to rely on margin: auto for centering the whole wrapper */
        width: fit-content;
        margin: 0 auto;
    }

    #board {
        margin: 0;
        /* Revert padding: internal borders should rely on grid placement */
        /* Ensure no internal margins offset the board */
        /* Hardware acceleration to help with sub-pixel rendering lines */
        transform: translateZ(0);
    }

    .cell {
        border-top: 1px solid #515c58;
        border-left: 1px solid #515c58;
    }
    #board .cell:nth-child(10n) {
        border-right: 1px solid #515c58;
    }
    #board .cell:nth-child(n+91) {
        border-bottom: 1px solid #515c58;
    }

    #hit-layer {
        top: 2vw;
        left: 2vw;
    }

    .main-logo {
        max-width: 280px;
    }

    button {
        padding: 12px 10px;
        font-size: 0.95rem;
    }

    .last-move::after,
    .highlight::after {
        width: 5vw;
        height: 5vw;
    }

    .stone.highlight::after,
    .stone.highlight-blue::after {
        width: 5vw;
        height: 5vw;
    }

    #ai-lesson-note {
        padding: 15px;
        width: 85%;
    }
}

/* Very Small Devices */
@media (max-width: 350px) {
    :root {
        --cell-size: 30px;
    }
}

/* Shared Header Styles (Re-added) */
.header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: none !important;
    padding-bottom: 5px;
    margin-bottom: 20px;
    position: relative;
}

.turn-text {
    margin-top: 10px;
    font-size: 0.75rem;
    color: #444;
    letter-spacing: 0.5rem;
    text-transform: uppercase;
    text-align: center;
    width: 100%;
    font-weight: bold;
    opacity: 0.9;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    margin-bottom: 10px;
}