body {
    margin: 0;
    padding: 0;
    background-color: #dceddf;
    font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    color: #4a7c59;
    
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent; 
}

#landscape-warning {
    display: none; 
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #4a7c59;
    color: white;
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.warning-icon {
    font-size: 60px;
    margin-bottom: 20px;
    display: block;
    animation: rotatePhone 2s ease-in-out infinite;
}

#landscape-warning h2 {
    font-size: 24px;
    margin: 0 0 10px 0;
}

#landscape-warning p {
    font-size: 14px;
    color: #dceddf;
    line-height: 1.5;
}

@keyframes rotatePhone {
    0% { transform: rotate(-90deg); }
    50% { transform: rotate(0deg); }
    100% { transform: rotate(-90deg); }
}

#main-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; 
    width: 100%;
    min-height: 100vh;
    padding: 30px 20px;
    box-sizing: border-box;
    overflow-x: hidden; 
}

#game-layout-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
}

#game-area {
    display: flex;
    flex-direction: column;
    align-items: center; 
    width: 410px;
    max-width: 100%; 
}

#top-bar {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

#lang-btn, #sound-btn {
    background-color: white;
    color: #4a7c59;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(74, 124, 89, 0.15);
    transition: all 0.2s ease;
}

#lang-btn:hover, #sound-btn:hover {
    background-color: #eaf6ec;
    transform: translateY(-1px);
}

#sound-btn.sound-off {
    background-color: rgba(255, 255, 255, 0.5);
    color: #8dae97;
    box-shadow: none;
}

#game-container {
    position: relative;
    box-shadow: 0 10px 30px rgba(74, 124, 89, 0.15);
    border-radius: 24px;
    overflow: hidden;
    border: 4px solid white;
}

canvas {
    background-color: #eaf6ec; 
    background-image: url('images/테마배경.jpg'); 
    background-size: cover;
    background-position: center;
    display: block;
    touch-action: none; 
}

#ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#scoreDisplay {
    position: absolute;
    top: 15px;
    left: 20px;
    text-shadow: 1px 1px 3px rgba(255, 255, 255, 0.9);
}

.score-line {
    font-size: 22px;
    font-weight: 800;
}
.best-line {
    font-size: 14px;
    color: #5c8b6a;
    margin-top: 3px;
    font-weight: 700;
}

/* 💡 캡쳐 시 바깥 여백(margin)이 무시되는 버그를 막기 위해 안쪽 여백(padding)으로 물리적 공간 확보! */
#score, #bestScore {
    display: inline-block;
    padding-left: 8px; 
}

#countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 70px;
    font-weight: 900;
    text-shadow: 0px 4px 15px rgba(255,255,255,0.9);
}

#initialScreen, #gameOver {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    padding: 25px 25px;
    border-radius: 20px;
    text-align: center;
    pointer-events: auto;
    box-shadow: 0 8px 25px rgba(74, 124, 89, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center; 
    width: 270px;
}

#initialScreen h2 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 1px;
}

#initialScreen p {
    font-size: 14px;
    color: #6a9c79;
    margin-bottom: 25px;
    font-weight: 600;
    line-height: 1.4;
}

#start-btn {
    background-color: #4a7c59;
    color: white;
    border: none;
    padding: 12px 35px;
    font-size: 16px;
    font-weight: 800;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

#start-btn:hover {
    background-color: #335940;
    transform: scale(1.05);
}

.share-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 15px;
}

.share-btn-group button {
    border: 1px solid #b7d8c0;
    background-color: #f4faf5;
    color: #4a7c59;
    padding: 8px 0;
    font-size: 13px;
    font-weight: 700;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-btn-group button:hover {
    background-color: #4a7c59;
    color: white;
    border-color: #4a7c59;
}

#restart-game-btn {
    background-color: #4a7c59 !important;
    color: white !important;
    border-color: #4a7c59 !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    padding: 10px 0 !important;
    box-shadow: 0 3px 10px rgba(74, 124, 89, 0.3);
}

#restart-game-btn:hover {
    background-color: #335940 !important;
    transform: scale(1.02);
}

#gameOverPlaceholder {
    width: 90px;
    height: 90px;
    background-color: #e28d8d; 
    border-radius: 20px;
    margin-bottom: 12px;
    display: none; 
}

#gameOverImg {
    width: 90px;
    height: 90px;
    object-fit: contain;
    margin-bottom: 12px;
    display: none;
}

#gameOver h2 {
    margin: 0 0 8px 0;
    color: #e28d8d;
    font-size: 24px;
    font-weight: 900;
}

.result-line {
    margin: 3px 0;
    font-size: 16px;
    font-weight: 800;
}

/* 💡 게임오버 화면 결과들도 패딩으로 여백 강제 */
#finalScore, #finalBestScore, #finalTime {
    display: inline-block;
    padding-left: 8px; 
}

.blink-text {
    margin-top: 10px !important;
    font-size: 12px !important;
    color: #8dae97 !important;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.hidden {
    display: none !important;
}

#mobile-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 15px;
    box-sizing: border-box;
}

#mobile-controls button {
    width: 48%;
    height: 65px; 
    background-color: white;
    color: #4a7c59;
    border: 2px solid #b7d8c0;
    border-radius: 15px;
    font-size: 24px; 
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(74, 124, 89, 0.15);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; 
    transition: all 0.1s ease;
}

#mobile-controls button:active {
    background-color: #4a7c59;
    color: white;
    transform: scale(0.96);
}

#character-selection {
    position: absolute;
    right: 100%; 
    margin-right: 20px; 
    top: 42px; 
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 20px 15px;
    border-radius: 24px;
    border: 3px solid #ffffff;
    box-shadow: 0 8px 20px rgba(74, 124, 89, 0.1);
}

#t-selectChar {
    margin: 0 0 15px 0;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-align: center;
    line-height: 1.3;
}

.character-options {
    display: flex;
    flex-direction: column; 
    gap: 15px;
}

.char-btn {
    border: 3px solid transparent;
    border-radius: 16px;
    background-color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    padding: 12px;
    transition: all 0.2s ease;
}

.char-btn:hover {
    background-color: rgba(255, 255, 255, 1);
}

.char-btn.selected {
    border-color: #4a7c59;
    background-color: white;
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.2);
    transform: translateX(2px);
}

.char-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.char-btn img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    display: block;
    transition: filter 0.3s ease;
}

.censored {
    filter: blur(10px) contrast(1.2); 
    transform: scale(0.95);
}

.mode-toggle-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px dashed #b7d8c0;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#t-filterText {
    margin: 0 0 10px 0;
    font-size: 13px;
    font-weight: 800;
    color: #4a7c59;
    letter-spacing: 0.5px;
    text-align: center;
}

#social-links {
    margin-top: 25px;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#social-links a {
    color: #6a9c79;
    text-decoration: none;
    transition: color 0.2s ease;
    letter-spacing: 0.5px;
}

#social-links a:hover {
    color: #4a7c59;
}

#social-links .divider {
    color: #b7d8c0;
    margin: 0 15px;
}

@media (max-width: 750px) {
    #main-wrapper {
        justify-content: flex-start; 
        padding-top: 20px;
    }
    
    #game-layout-wrapper {
        flex-direction: column;
        align-items: center;
    }
    
    #character-selection {
        position: relative; 
        right: auto;
        top: auto;
        margin-right: 0;
        margin-bottom: 20px; 
        padding: 10px 15px;
        flex-direction: row; 
        justify-content: center;
        align-items: center;
        width: auto;
    }
    
    #t-selectChar {
        display: none; 
    }
    
    .character-options {
        flex-direction: row; 
        gap: 10px;
    }
    
    .mode-toggle-section {
        margin-top: 0;
        padding-top: 0;
        border-top: none;
        border-left: 2px dashed #b7d8c0; 
        margin-left: 12px;
        padding-left: 12px;
        flex-direction: column;
        width: auto;
    }
    
    #t-filterText {
        font-size: 11px;
        margin-bottom: 5px;
    }
    
    .char-btn {
        padding: 8px; 
    }
    
    .char-btn img {
        width: 38px;
        height: 38px;
    }
}

@media screen and (max-width: 950px) and (orientation: landscape) {
    #main-wrapper { display: none; }
    #landscape-warning { display: flex; }
}

@media (max-width: 440px) {
    #main-wrapper { padding: 10px; }
    #game-area { transform: scale(0.9); transform-origin: top center; }
}
@media (max-width: 380px) {
    #game-area { transform: scale(0.8); transform-origin: top center; }
}