:root {
    --primary-color: #7c3aed;
    --secondary-color: #a78bfa;
    --accent-color: #f43f5e;
    --background-color: transparent;
    --grid-color: rgba(255, 255, 255, 0.06);
    --text-color: #cbd5e1;
    --selection-color: rgba(124, 58, 237, 0.5);
    --persimmon-orange: #FF7518;
    --highlight-color: #a78bfa;
    --timer-color: #f43f5e;
}

body {
    font-family: 'Nanum Myeongjo', 'Noto Sans KR', serif;
    background-color: transparent;
    color: var(--text-color);
    touch-action: pan-x pan-y;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.korean-paper {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.title-brush {
    font-family: 'Nanum Myeongjo', serif;
    font-weight: 800;
    color: var(--et-text-heading, #f1f5f9);
    text-shadow: 0 0 20px rgba(124, 58, 237, 0.35);
    position: relative;
}

.title-brush:after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 10%;
    width: 80%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

.btn-traditional {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5b21b6 100%);
    color: #fff;
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 10px;
    padding: 8px 16px;
    transition: all 0.3s ease;
    font-family: 'Noto Sans KR', 'Nanum Myeongjo', serif;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.btn-traditional:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #4c1d95 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
}

.game-container {
    max-width: 800px;
    margin: 0px auto 0 auto;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    position: relative;
    z-index: 1;
}



.game-title {
    text-align: center;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(124, 58, 237, 0.35);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 2px;
    margin-bottom: 15px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px;
    border-radius: 8px;
    touch-action: none;
    position: relative;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    align-items: center;
    justify-items: center;
}

.persimmon-cell {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: 50%;
    transition: transform 0.1s, opacity 0.3s;
    color: #2D1810;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.8), -1px -1px 3px rgba(255, 255, 255, 0.8);
    z-index: 10;
    touch-action: none;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.persimmon-cell::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwIiBoZWlnaHQ9IjEwMCIgdmlld0JveD0iMCAwIDEwMCAxMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxjaXJjbGUgY3g9IjUwIiBjeT0iNTAiIHI9IjM1IiBmaWxsPSIjRkY2NjAwIiBzdHJva2U9IiNFMjUzMDAiIHN0cm9rZS13aWR0aD0iMiIvPgo8cGF0aCBkPSJNMzUgMjBDMzUgMTUgNDAgMTAgNTAgMTBTNjUgMTUgNjUgMjBWMzBINDVWMjVINDVWMzBIMzVWMjBaIiBmaWxsPSIjNENBRjUwIi8+CjxwYXRoIGQ9Ik00NSAyNUw1NSAyNUw1MCAzMEw0NSAyNVoiIGZpbGw9IiMzODhFM0MiLz4KPGVsbGlwc2UgY3g9IjQ1IiBjeT0iNDgiIHJ4PSI0IiByeT0iNiIgZmlsbD0iI0ZGODUzMyIvPgo8ZWxsaXBzZSBjeD0iNTgiIGN5PSI2MCIgcng9IjMiIHJ5PSI1IiBmaWxsPSIjRkY4NTMzIi8+Cjwvc3ZnPgo=');
    background-size: 80%;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.7;
    z-index: -1;
    border-radius: 50%;
    pointer-events: none;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.persimmon-cell.selected {
    transform: scale(1.05);
}

.persimmon-cell.valid-selection {
    animation: pulse 0.5s infinite alternate;
}

.persimmon-cell.popping {
    animation: pop 0.3s forwards;
}

@keyframes pop {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0px rgba(124, 58, 237, 0.7);
    }
    100% {
        box-shadow: 0 0 0 10px rgba(124, 58, 237, 0);
    }
}

@keyframes newCellAppear {
    0% {
        transform: scale(0);
        opacity: 0;
        background-color: rgba(124, 58, 237, 0.4);
    }
    50% {
        transform: scale(1.1);
        background-color: rgba(124, 58, 237, 0.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
        background-color: transparent;
    }
}

.persimmon-cell.new-cell {
    animation: newCellAppear 0.3s ease-out;
}

.info-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
    flex-wrap: nowrap;
}

.score-container, .timer-container {
    background: rgba(124, 58, 237, 0.3);
    border: 1px solid rgba(124, 58, 237, 0.4);
    color: white;
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: bold;
    display: flex;
    align-items: center;
    box-shadow: 0 3px 12px rgba(124, 58, 237, 0.2);
    font-size: 12px;
    flex-shrink: 0;
}

.timer-container {
    background: rgba(244, 63, 94, 0.3);
    border: 1px solid rgba(244, 63, 94, 0.4);
    box-shadow: 0 3px 12px rgba(244, 63, 94, 0.2);
}

.high-score-badge {
    color: white;
    text-align: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.selection-box {
    position: absolute;
    border: 2px dashed var(--highlight-color);
    background-color: rgba(124, 58, 237, 0.15);
    pointer-events: none;
    z-index: 10;
}

.valid-box {
    background-color: rgba(16, 185, 129, 0.2) !important;
    border: 2px solid #10b981 !important;
}

.invalid-box {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border: 2px dashed #ef4444 !important;
}

.controls {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.controls button {
    background: rgba(124, 58, 237, 0.3);
    color: white;
    border: 1px solid rgba(124, 58, 237, 0.4);
    border-radius: 8px;
    padding: 12px 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    height: 48px;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.controls button:hover {
    background: rgba(124, 58, 237, 0.5);
    border-color: rgba(124, 58, 237, 0.6);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
}

.controls button:disabled {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.25);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.controls button:disabled:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
    transform: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-content {
    background: rgba(15, 12, 40, 0.95);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 2rem;
    max-width: 90%;
    max-height: 80%;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    color: var(--et-text, #cbd5e1);
}

/* Result score box in game-over modal */
.result-score-box {
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
}

/* Stat boxes in game-over modal */
.stat-box {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.difficulty-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--et-text, #cbd5e1);
    padding: 6px 12px;
    border-radius: 6px;
    margin: 0 4px;
    transition: all 0.2s;
    flex: 1;
    min-width: 60px;
    max-width: 80px;
}

.difficulty-btn.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5b21b6 100%);
    color: white;
    border-color: rgba(124, 58, 237, 0.5);
}

.difficulty-selector {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.difficulty-option {
    padding: 8px 15px;
    cursor: pointer;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--et-text, #cbd5e1);
    transition: all 0.2s;
}

.difficulty-option.selected {
    background: linear-gradient(135deg, var(--primary-color) 0%, #5b21b6 100%);
    color: white;
    font-weight: bold;
    border-color: rgba(124, 58, 237, 0.5);
}

/* 난이도 선택 버튼 컨테이너 */
.flex.justify-center {
    flex-wrap: wrap;
    gap: 8px;
}

.combo-display {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #5b21b6 100%);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
}

.tutorial-highlight {
    position: absolute;
    border: 3px solid var(--secondary-color);
    border-radius: 50%;
    animation: tutorialPulse 1.5s infinite;
    pointer-events: none;
    z-index: 15;
}

@keyframes tutorialPulse {
    0% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(167, 139, 250, 0); }
    100% { box-shadow: 0 0 0 0 rgba(167, 139, 250, 0); }
}

.hidden {
    display: none !important;
}

.game-start-highlight {
    background: linear-gradient(135deg, #7c3aed, #6d28d9, #a78bfa) !important;
    color: white !important;
    font-size: 16px !important;
    font-weight: bold !important;
    padding: 12px 20px !important;
    border: 1px solid rgba(124, 58, 237, 0.5) !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4) !important;
    animation: pulse-glow 2s infinite;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
    height: 48px !important;
    min-width: 150px !important;
    margin: 0 !important;
}

.game-start-highlight:hover {
    background: linear-gradient(135deg, #6d28d9, #5b21b6, #7c3aed) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 12px 32px rgba(124, 58, 237, 0.6) !important;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4), 0 0 20px rgba(124, 58, 237, 0.3);
    }
    50% {
        box-shadow: 0 8px 24px rgba(124, 58, 237, 0.6), 0 0 30px rgba(124, 58, 237, 0.5);
    }
}

/* 공유 버튼 - old classes kept for JS compatibility */
.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 25px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    min-width: 80px;
    justify-content: center;
}

.kakao-btn {
    background-color: #FEE500;
    color: #3C1E1E;
}

.kakao-btn:hover {
    background-color: #F7DD02;
    transform: translateY(-2px);
}

.instagram-btn {
    background: linear-gradient(45deg, #833AB4, #C13584, #E1306C);
}

.instagram-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(225, 48, 108, 0.4);
}

.facebook-btn {
    background-color: #1877F2;
}

.facebook-btn:hover {
    background-color: #166FE5;
    transform: translateY(-2px);
}

.link-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.link-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-2px);
}

.share-btn i {
    font-size: 16px;
}

/* 복사 성공 알림 */
.copy-success {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #10B981;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.copy-success.show {
    opacity: 1;
}

@media (max-width: 640px) {
    .persimmon-cell {
        font-size: 14px;
    }

    .info-panel {
        flex-direction: row !important;
        gap: 6px;
    }

    .score-container, .timer-container {
        padding: 5px 10px;
        font-size: 12px;
    }

    .controls {
        gap: 6px;
        margin-bottom: 12px;
        flex-wrap: wrap;
    }

    .controls button {
        padding: 10px 12px;
        font-size: 13px;
        height: 44px;
        min-width: 80px;
        flex: 1;
        max-width: 120px;
    }

    .game-start-highlight {
        font-size: 14px !important;
        padding: 10px 12px !important;
        height: 44px !important;
        min-width: 120px !important;
        flex: 1.2;
        max-width: 140px !important;
    }

    .game-container {
        padding: 10px 10px 20px 10px;
        margin: 130px auto 0 auto;
    }

    .game-board {
        margin-bottom: 20px;
    }

    .share-btn,
    .et-share-btn {
        font-size: 12px;
        padding: 6px 12px;
        min-width: 70px;
    }

    .modal-content {
        padding: 0.75rem !important;
        max-width: 98% !important;
        max-height: 90vh !important;
        overflow-y: auto;
        margin: 1% !important;
        width: 98% !important;
    }

    #game-over-modal .modal-content h3 {
        font-size: 1.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* 메인 점수 표시 영역 컴팩트화 */
    #game-over-modal .result-score-box {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }

    #game-over-modal .result-score-box p:first-child {
        font-size: 1rem !important;
        margin-bottom: 0.3rem !important;
    }

    #game-over-modal .result-score-box p:nth-child(2) {
        font-size: 2.4rem !important;
        margin-bottom: 0.3rem !important;
    }

    #game-over-modal .result-score-box p:last-child {
        font-size: 0.9rem !important;
    }

    /* 상세 통계 그리드 컴팩트화 */
    #game-over-modal .grid-cols-2 {
        gap: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    #game-over-modal .grid-cols-2 > div {
        padding: 0.5rem !important;
    }

    #game-over-modal .grid-cols-2 p:first-child {
        font-size: 1.1rem !important;
    }

    #game-over-modal .grid-cols-2 p:last-child {
        font-size: 0.8rem !important;
    }

    /* 최고 기록 메시지 컴팩트화 */
    #game-over-modal #high-score-message {
        padding: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    #game-over-modal #high-score-message p:first-child {
        font-size: 1.1rem !important;
    }

    #game-over-modal #high-score-message p:last-child {
        font-size: 0.8rem !important;
    }

    /* 기록 비교 영역 컴팩트화 */
    #game-over-modal .stat-box {
        padding: 0.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* 공유 섹션 컴팩트화 */
    #game-over-modal .mb-6:has(.et-share-btn) {
        margin-bottom: 0.75rem !important;
    }

    #game-over-modal .mb-6:has(.et-share-btn) p {
        font-size: 0.9rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* 공유 버튼들 2개씩 한 줄 배치 */
    #game-over-modal .flex.justify-center.gap-3.flex-wrap:has(.et-share-btn) {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 0.4rem !important;
        max-width: 100% !important;
    }

    #game-over-modal .et-share-btn {
        font-size: 0.85rem !important;
        padding: 0.5rem 0.4rem !important;
        min-width: auto !important;
        width: 100% !important;
        justify-content: center !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.25rem !important;
    }

    #game-over-modal .et-share-btn i {
        font-size: 0.95rem !important;
    }

    /* 액션 버튼들 컴팩트화 */
    #game-over-modal .text-center.space-y-3 {
        margin-top: 0.5rem !important;
    }

    #game-over-modal .flex.justify-center.gap-3 {
        gap: 0.4rem !important;
        flex-direction: column !important;
    }

    #game-over-modal .btn-traditional {
        padding: 0.7rem 0.8rem !important;
        font-size: 1.1rem !important;
        width: 100% !important;
        margin-bottom: 0.4rem;
        font-weight: bold !important;
    }

    /* 도전 모드 결과 메시지 컴팩트화 */
    .challenge-result-info {
        margin: 0.5rem 0 !important;
    }

    .challenge-result-info > div {
        padding: 0.5rem !important;
    }

    .challenge-result-info div[style*="font-size: 18px"] {
        font-size: 1.1rem !important;
        margin-bottom: 0.3rem !important;
    }

    .challenge-result-info div[style*="font-size: 14px"] {
        font-size: 0.85rem !important;
    }

    .challenge-result-info div[style*="font-size: 24px"] {
        font-size: 1.3rem !important;
        margin: 0.3rem 0 !important;
    }

    .challenge-result-info div[style*="font-size: 12px"] {
        font-size: 0.75rem !important;
    }


}

/* 추가: 더 작은 화면 (스마트폰 세로 모드) */
@media (max-width: 480px) {
    .game-container {
        margin: 150px auto 0 auto;
    }

    .controls button {
        padding: 8px 10px;
        font-size: 12px;
        height: 40px;
        min-width: 70px;
        max-width: 100px;
    }

    .game-start-highlight {
        font-size: 13px !important;
        padding: 8px 10px !important;
        height: 40px !important;
        min-width: 100px !important;
        max-width: 120px !important;
    }

    .difficulty-btn {
        margin: 2px 2px;
        padding: 8px 6px;
        font-size: 12px;
        min-width: auto;
        max-width: none;
        flex: 1;
    }

    /* 4개 버튼을 한 줄로 배치 */
    .flex.justify-center {
        justify-content: center;
        gap: 4px;
        flex-wrap: nowrap !important;
    }
}

/* 추가: 매우 작은 화면 */
@media (max-width: 360px) {
    .game-container {
        margin: 100px auto 0 auto;
    }

    .controls button {
        padding: 6px 8px;
        font-size: 11px;
        height: 36px;
        min-width: 60px;
        max-width: 90px;
    }

    .game-start-highlight {
        font-size: 12px !important;
        padding: 6px 8px !important;
        height: 36px !important;
        min-width: 90px !important;
        max-width: 110px !important;
    }

    .difficulty-btn {
        margin: 1px 1px;
        padding: 6px 4px;
        font-size: 11px;
        min-width: auto;
        max-width: none;
        flex: 1;
    }

    .flex.justify-center {
        gap: 2px;
        flex-wrap: nowrap !important;
    }
}