* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --cell-size: 60px;
}

body {
    font-family: 'Segoe UI', -apple-system, sans-serif;
    background: #000;
    color: #fff;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.game-wrapper {
    width: 100%;
    max-width: 1100px;
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    margin-bottom: 8px;
    color: #fff;
}

.game-header p {
    font-size: 14px;
    color: #888;
    letter-spacing: 2px;
}

.game-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* 왼쪽 영역 */
.left-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 오른쪽 영역 */
.right-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 전적 패널 */
.stats-panel {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 20px;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #222;
}

.stats-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.reset-stats-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #888;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.reset-stats-btn:hover {
    background: #222;
    color: #fff;
    border-color: #444;
}

.stats-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.total-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stat-item {
    background: #0a0a0a;
    padding: 12px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: 1px solid #1a1a1a;
}

.stat-item.win {
    border-color: #2d5016;
}

.stat-item.draw {
    border-color: #3a3a3a;
}

.stat-item.lose {
    border-color: #5a1a1a;
}

.stat-label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
}

.stat-item.win .stat-value {
    color: #4ade80;
}

.stat-item.draw .stat-value {
    color: #888;
}

.stat-item.lose .stat-value {
    color: #f87171;
}

.win-rate {
    background: #0a0a0a;
    padding: 16px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #1a1a1a;
}

.win-rate-label {
    font-size: 14px;
    color: #888;
    font-weight: 600;
}

.win-rate-value {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.recent-games {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.recent-label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.recent-results {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.no-games {
    font-size: 13px;
    color: #444;
    font-style: italic;
}

.result-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    border: 1px solid;
}

.result-badge.win {
    background: #1a3a1a;
    border-color: #2d5016;
    color: #4ade80;
}

.result-badge.draw {
    background: #1a1a1a;
    border-color: #2a2a2a;
    color: #888;
}

.result-badge.lose {
    background: #3a1a1a;
    border-color: #5a1a1a;
    color: #f87171;
}

/* 정보 패널 */
.info-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.score-board {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    gap: 15px;
}

.score {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #0a0a0a;
    border-radius: 6px;
}

.score-icon {
    font-size: 32px;
}

.score-info {
    display: flex;
    flex-direction: column;
}

.score-info .label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    letter-spacing: 1px;
}

.score-info .value {
    font-size: 32px;
    font-weight: 700;
    color: #fff;
}

.status-area {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 20px;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.status {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
}

.ai-status {
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #888;
}

.ai-status.visible {
    display: flex;
}

/* AI 상태 오버레이 (보드 위에 표시) */
.ai-status-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 20px 32px;
    border-radius: 12px;
    border: 2px solid #333;
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #fff;
    font-weight: 600;
    z-index: 10;
    pointer-events: none;
}

.ai-status-overlay.visible {
    display: flex;
}

.loader {
    width: 16px;
    height: 16px;
    border: 2px solid #333;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.difficulty-selector {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 20px;
}

.difficulty-selector label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: 1px;
}

.diff-btns {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.diff-btns button {
    background: #0a0a0a;
    border: 1px solid #222;
    color: #666;
    font-size: 14px;
    font-weight: 700;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btns button:hover:not(:disabled) {
    background: #1a1a1a;
    border-color: #444;
    color: #fff;
}

.diff-btns button.active {
    background: #fff;
    border-color: #fff;
    color: #000;
}

.diff-btns button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.restart-btn {
    background: #fff;
    color: #000;
    border: none;
    padding: 16px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.restart-btn:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.restart-btn:active {
    transform: translateY(0);
}

/* 보드 */
.board-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: calc(var(--cell-size) * 8 + 20px);
    height: 100%;
}

.board {
    display: grid;
    grid-template-columns: repeat(8, var(--cell-size));
    grid-template-rows: repeat(8, var(--cell-size));
    gap: 1px;
    background: #222;
    padding: 1px;
    border: 2px solid #222;
    border-radius: 4px;
}

.cell {
    background: #0a0a0a;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.cell:hover {
    background: #111;
}

.cell.hint::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #4a4a4a;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
    }
}

.piece {
    width: calc(var(--cell-size) * 0.8);
    height: calc(var(--cell-size) * 0.8);
    border-radius: 50%;
    position: absolute;
    animation: drop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes drop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.piece.black {
    background: linear-gradient(145deg, #5a5a5a, #3a3a3a);
    border: 2px solid #4a4a4a;
}

.piece.white {
    background: linear-gradient(145deg, #fff, #e0e0e0);
    border: 2px solid #ddd;
}

/* 상태 패널 */
.status-panel {
    background: #111;
    border: 1px solid #222;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
}

.status-text {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 2px;
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: #111;
    border: 2px solid #333;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid #222;
    text-align: center;
}

.modal-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin: 0;
    letter-spacing: 1px;
}

.modal-body {
    padding: 40px 24px;
    text-align: center;
}

.result-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.result-text {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 32px;
    letter-spacing: 1px;
}

.result-text.win {
    color: #4ade80;
}

.result-text.lose {
    color: #f87171;
}

.result-text.draw {
    color: #888;
}

.difficulty-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #333;
    margin-bottom: 24px;
}

.badge-label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-level {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    min-width: 24px;
    text-align: center;
}

.difficulty-badge.level-1 .badge-level,
.difficulty-badge.level-2 .badge-level {
    color: #4ade80;
}

.difficulty-badge.level-3 .badge-level,
.difficulty-badge.level-4 .badge-level {
    color: #fbbf24;
}

.difficulty-badge.level-5 .badge-level,
.difficulty-badge.level-6 .badge-level {
    color: #f87171;
}

.difficulty-badge.level-7 .badge-level {
    color: #a855f7;
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.5);
}

.score-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: #0a0a0a;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #1a1a1a;
}

.score-summary .score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.score-summary .score-label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    letter-spacing: 1px;
}

.score-summary .score-number {
    font-size: 48px;
    font-weight: 700;
    color: #fff;
}

.score-divider {
    font-size: 36px;
    color: #333;
    font-weight: 700;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid #222;
    display: flex;
    gap: 12px;
}

.modal-btn {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-btn.primary {
    background: #fff;
    color: #000;
}

.modal-btn.primary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.modal-btn.secondary {
    background: #1a1a1a;
    color: #888;
    border: 1px solid #333;
}

.modal-btn.secondary:hover {
    background: #222;
    color: #fff;
    border-color: #444;
}

/* 반응형 */
@media (min-width: 1200px) {
    :root {
        --cell-size: 65px;
    }
}

@media (max-width: 1024px) {
    .game-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .right-section {
        order: -1;
    }
}

@media (max-width: 768px) {
    :root {
        --cell-size: 45px;
    }

    .game-container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .game-header h1 {
        font-size: 36px;
        letter-spacing: 4px;
    }

    .total-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .info-panel {
        display: grid;
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .score-board {
        flex-direction: column;
    }

    .score-board,
    .difficulty-selector {
        padding: 16px;
    }

    .restart-btn {
        width: 100%;
    }

    .ai-status-overlay {
        padding: 16px 24px;
        font-size: 13px;
    }

    .status-panel {
        padding: 16px;
    }

    .status-text {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    :root {
        --cell-size: 38px;
    }

    .game-header h1 {
        font-size: 28px;
    }

    .info-panel {
        flex-direction: column;
    }

    .diff-btns {
        grid-template-columns: repeat(7, 1fr);
        gap: 6px;
    }

    .diff-btns button {
        padding: 8px 4px;
        font-size: 12px;
    }
}


