* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: background 1s ease;
}

body.level-2 {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
}

body.level-3 {
    background: linear-gradient(135deg, #eb5757 0%, #f2994a 100%);
}

body.level-4 {
    background: linear-gradient(135deg, #8b0000 0%, #eb5757 100%);
}

body.level-5 {
    background: linear-gradient(135deg, #1a0a1a 0%, #4a0a4a 100%);
}

body.level-6 {
    background: linear-gradient(135deg, #000000 0%, #1a0a0a 100%);
}

.game-container {
    text-align: center;
    max-width: 600px;
    width: 100%;
}

.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.language-selector select {
    padding: 8px 15px;
    font-size: 1rem;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* 타이틀 화면 */
.title-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.main-title {
    font-size: 3.5rem;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 60px;
}

.title-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.title-btn {
    padding: 20px 60px;
    font-size: 1.5rem;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.start-btn {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
    color: white;
}

.ranking-btn {
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
}

.blog-btn {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.title-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* 가이드 화면 */
.guide-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.guide-screen.show {
    display: flex;
}

.guide-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.guide-content h2 {
    color: #333;
    margin-bottom: 30px;
    font-size: 2rem;
}

.guide-body {
    text-align: left;
    margin-bottom: 30px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 10px;
}

.guide-icon {
    font-size: 1.5rem;
}

.guide-item p {
    color: #333;
    font-size: 1rem;
    margin: 0;
}

.confirm-btn {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 15px 50px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* 카운트다운 화면 */
.countdown-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    justify-content: center;
    align-items: center;
    z-index: 300;
}

.countdown-screen.show {
    display: flex;
}

.countdown-number {
    font-size: 15rem;
    color: white;
    font-weight: bold;
    text-shadow: 0 0 50px rgba(255, 255, 255, 0.5);
    animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* 랭킹 화면 */
.ranking-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.ranking-screen-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ranking-screen.show {
    display: flex;
}

.ranking-screen h2 {
    color: #333;
    font-size: 2rem;
    margin-bottom: 20px;
}

.ranking-screen ol {
    list-style: none;
    padding: 0;
    width: 100%;
    margin-bottom: 20px;
}

.ranking-screen li {
    padding: 15px 20px;
    margin: 10px 0;
    background: white;
    border-radius: 10px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 1.1rem;
}

.ranking-screen li:first-child {
    background: linear-gradient(145deg, #ffd700, #ffed4a);
}

.ranking-screen li:nth-child(2) {
    background: linear-gradient(145deg, #c0c0c0, #e8e8e8);
}

.ranking-screen li:nth-child(3) {
    background: linear-gradient(145deg, #cd7f32, #daa06d);
}

.back-btn {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    transform: translateY(-2px);
}

/* 게임 컨테이너 숨기기 */
.game-container {
    display: none;
}

.game-container.show {
    display: block;
}

/* 홈 버튼 */
.home-btn {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    margin-left: 10px;
    display: none;
}

.home-btn:hover {
    transform: translateY(-2px);
}

.game-title {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 15px 25px;
    border-radius: 15px;
    margin-bottom: 20px;
    color: white;
    font-size: 1.2rem;
}

.combo {
    color: #ffd700;
    font-weight: bold;
    min-width: 100px;
}

.lives {
    font-size: 1.5rem;
}

/* 칠판 스타일 */
.chalkboard {
    background: #2d5016;
    border: 20px solid #8B4513;
    border-radius: 5px;
    padding: 10px;
    margin-bottom: 20px;
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 10px 30px rgba(0, 0, 0, 0.4);
    position: relative;
}

.chalkboard::before {
    content: '';
    position: absolute;
    top: -20px;
    left: -20px;
    right: -20px;
    bottom: -20px;
    border: 5px solid #5d3a1a;
    border-radius: 8px;
    pointer-events: none;
}

.chalkboard-inner {
    background: linear-gradient(
        to bottom,
        #1a3d0c 0%,
        #2d5016 50%,
        #1a3d0c 100%
    );
    padding: 40px 20px;
    border-radius: 3px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.expression {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-size: clamp(1.2rem, 5vw, 3rem);
    color: #f5f5dc;
    text-shadow:
        1px 1px 0 rgba(255, 255, 255, 0.1),
        -1px -1px 0 rgba(0, 0, 0, 0.3);
    letter-spacing: 3px;
    opacity: 0.95;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 10px;
    max-width: 100%;
}

.question {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 20px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* 버튼 스타일 */
.buttons-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.game-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.2), 0 8px 20px rgba(0, 0, 0, 0.3);
}

.game-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 9px 0 rgba(0, 0, 0, 0.2), 0 12px 25px rgba(0, 0, 0, 0.3);
}

.game-btn:active {
    transform: translateY(3px);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.2), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.game-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.less-btn {
    background: linear-gradient(145deg, #3498db, #2980b9);
}

.equal-btn {
    background: linear-gradient(145deg, #9b59b6, #8e44ad);
}

.greater-btn {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
}

.game-btn .arrow {
    font-size: 2.5rem;
    color: white;
}

.game-btn .number {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
}

.game-btn .label {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-top: 5px;
}

/* 피드백 애니메이션 */
@keyframes correct {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); background: #27ae60; }
    100% { transform: scale(1); }
}

@keyframes wrong {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

.game-btn.correct {
    animation: correct 0.5s ease;
}

.game-btn.wrong {
    animation: wrong 0.5s ease;
    background: #7f8c8d !important;
}

.chalkboard.correct {
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 0 30px rgba(39, 174, 96, 0.6);
}

.chalkboard.wrong {
    box-shadow:
        inset 0 0 30px rgba(0, 0, 0, 0.3),
        0 0 30px rgba(231, 76, 60, 0.6);
}

/* 타이머 바 */
.timer-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 3px 3px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #2ecc71);
    transition: width 0.1s linear;
    border-radius: 0 0 3px 3px;
}

.timer-fill.warning {
    background: linear-gradient(90deg, #e74c3c, #f39c12);
}

.timer-fill.danger {
    background: #e74c3c;
    animation: pulse 0.3s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* 다시 시작 버튼 */
.restart-btn {
    background: linear-gradient(145deg, #1abc9c, #16a085);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    display: none;
}

.restart-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* 모달 스타일 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal h2 {
    color: #e74c3c;
    font-size: 2.5rem;
    margin-bottom: 20px;
}

.final-score {
    font-size: 1.5rem;
    color: #333;
    margin-bottom: 20px;
}

.final-score span {
    color: #9b59b6;
    font-weight: bold;
}

.name-input-section {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.name-input-section input {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 10px;
    width: 150px;
}

.name-input-section input:focus {
    outline: none;
    border-color: #9b59b6;
}

.name-input-section button {
    padding: 10px 20px;
    font-size: 1rem;
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.name-input-section button:hover {
    background: #8e44ad;
}

.ranking-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.ranking-section h3 {
    color: #333;
    margin-bottom: 15px;
}

.ranking-section ol {
    list-style: none;
    padding: 0;
}

.ranking-section li {
    padding: 10px 15px;
    margin: 5px 0;
    background: white;
    border-radius: 8px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.ranking-section li:first-child {
    background: linear-gradient(145deg, #ffd700, #ffed4a);
}

.ranking-section li:nth-child(2) {
    background: linear-gradient(145deg, #c0c0c0, #e8e8e8);
}

.ranking-section li:nth-child(3) {
    background: linear-gradient(145deg, #cd7f32, #daa06d);
}

.rank-position {
    font-size: 1.2rem;
    min-width: 35px;
    text-align: center;
}

.rank-flag {
    min-width: 35px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flag-img {
    width: 28px;
    height: 28px;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.rank-name {
    font-weight: bold;
    flex: 1;
    text-align: left;
    margin-left: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rank-score {
    color: #9b59b6;
    font-weight: bold;
    min-width: 80px;
    text-align: right;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.play-again-btn, .modal-home-btn {
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.1rem;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.play-again-btn {
    background: linear-gradient(145deg, #27ae60, #2ecc71);
}

.modal-home-btn {
    background: linear-gradient(145deg, #95a5a6, #7f8c8d);
}

.play-again-btn:hover, .modal-home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* 반응형 디자인 */
@media (max-width: 500px) {
    .game-title {
        font-size: 1.8rem;
    }

    .expression {
        font-size: 2.5rem;
        letter-spacing: 5px;
    }

    .game-btn {
        width: 90px;
        height: 90px;
    }

    .game-btn .arrow,
    .game-btn .number {
        font-size: 1.8rem;
    }

    .game-btn .label {
        font-size: 0.8rem;
    }

    .status-bar {
        flex-direction: column;
        gap: 10px;
        font-size: 1rem;
    }

    .chalkboard {
        border-width: 12px;
    }

    .chalkboard-inner {
        padding: 30px 15px;
        min-height: 100px;
    }
}
