@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700&display=swap');

body {
    background-color: #12121c;
    background-image: radial-gradient(circle at top right, #1e2a4a, #12121c 70%);
    color: #f0f0f0;
    font-family: 'Nunito', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    text-align: center;
}

.container {
    max-width: 800px;
    width: 90%;
    padding: 30px;
    border: 1px solid rgba(74, 144, 226, 0.3);
    background-color: rgba(26, 26, 46, 0.7);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 10px;
}

h1 {
    font-size: 2.8em;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(74, 144, 226, 0.5);
    margin-bottom: 15px;
}

p {
    font-size: 1.2em;
    margin-bottom: 25px;
    line-height: 1.6;
    color: #c0c0c0;
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
}

label {
    text-align: left;
    font-size: 1.1em;
    font-weight: 700;
    text-transform: uppercase;
    color: #a0a0a0;
}

input[type="text"],
input[type="password"] {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid #4a90e2;
    color: #f0f0f0;
    padding: 12px;
    font-family: inherit;
    font-size: 1.1em;
    border-radius: 5px;
    transition: all 0.3s ease;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    background-color: rgba(0, 0, 0, 0.5);
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.7);
    border-color: #63a4ff;
}

input[type="file"] {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid #4a90e2;
    color: #f0f0f0;
    padding: 10px;
    font-family: inherit;
    font-size: 1em;
    border-radius: 5px;
}

button, .button {
    background: linear-gradient(45deg, #4a90e2, #2a6ab8);
    color: #fff;
    border: none;
    padding: 15px 20px;
    font-family: inherit;
    font-size: 1.2em;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    border-radius: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px 0 rgba(74, 144, 226, 0.4);
}

button:hover, .button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(74, 144, 226, 0.6);
    background: linear-gradient(45deg, #5aa1f2, #3a7ac8);
}

button:disabled, .button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: #6c757d;
}

.game-options-container {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    padding: 20px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    border: 1px solid rgba(74, 144, 226, 0.2);
}
.option-group {
    display: flex;
    align-items: center;
    gap: 10px;
}
.option-group label {
    font-size: 1.2em;
    color: #c0c0c0;
}
.game-option-select {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid #4a90e2;
    color: #f0f0f0;
    padding: 8px;
    font-family: inherit;
    font-size: 1.1em;
    border-radius: 5px;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 1.1em;
    border-bottom: 1px solid rgba(74, 144, 226, 0.3);
    padding-bottom: 10px;
    align-items: center;
}

#timer-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #ffc107;
    min-width: 40px;
    text-align: center;
}

#quiz-content {
    margin: 25px 0;
    min-height: 315px; /* iframe height */
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    overflow: hidden;
}

#quiz-content img, #quiz-content iframe {
    border-radius: 8px;
}

#result-screen h1 {
    color: #50e3c2; /* A nice success green/teal color */
    text-shadow: 0 0 10px rgba(80, 227, 194, 0.5), 0 0 20px rgba(80, 227, 194, 0.2);
    animation: pulse-glow 2s infinite alternate;
}

#result-screen {
    animation: fadeIn 0.5s ease-in-out;
}

#result-screen #final-score {
    font-size: 2.2em;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 5px #fff, 0 0 15px #50e3c2, 0 0 25px #50e3c2;
    margin: 30px 0;
    animation: slideUp 0.5s ease-out 0.2s;
    animation-fill-mode: backwards; /* Start invisible before animation begins */
}

#result-screen #result-message {
    font-style: italic;
    animation: slideUp 0.5s ease-out 0.4s;
    animation-fill-mode: backwards;
}

#result-screen .form-container, #result-screen #restart-btn {
    animation: slideUp 0.5s ease-out 0.6s;
    animation-fill-mode: backwards;
}

/* '일부 보기' 퀴즈를 위한 스타일 */
.partial-view-container {
    width: 100%;
    height: 350px;
    overflow: hidden;
    border-radius: 8px;
    position: relative; /* For absolute positioning of the child */
    background-color: #000;
}

.partial-view-container img {
    position: absolute;
    /* Zoom level (e.g., 4x). Adjust as needed. */
    width: 400%;
    height: 400%;
    object-fit: cover; /* Maintain aspect ratio */
    /* 'top' and 'left' will be set by JavaScript */
}

/* Leaderboard Styles */
.leaderboard-container {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid rgba(74, 144, 226, 0.3);
}

.leaderboard-container h2 {
    font-size: 1.8em;
    color: #fff;
    text-transform: uppercase;
    margin-bottom: 15px;
    letter-spacing: 1px;
}

.counters {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(74, 144, 226, 0.3);
    color: #a0a0a0;
    font-size: 1.1em;
}

.leaderboard-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
    background-color: rgba(0,0,0,0.2);
    border-radius: 5px;
    overflow: hidden;
    text-align: left;
}

.leaderboard-container th, .leaderboard-container td {
    padding: 12px 15px;
    border-bottom: 1px solid #2a3a5a;
}

.leaderboard-container th {
    background-color: #1e2a4a;
    color: #4a90e2;
    text-transform: uppercase;
}

.leaderboard-container td {
    color: #c0c0c0;
}

.leaderboard-container tr:last-child td {
    border-bottom: none;
}

.leaderboard-container tr:nth-child(even) {
    background-color: rgba(0,0,0,0.1);
}

.leaderboard-container td:nth-child(5) { /* Style for the 'message' column */
    max-width: 200px; /* On large screens, don't let it get too wide */
    white-space: normal; /* Allow text to wrap */
    word-break: break-word; /* Break long words to prevent overflow */
}

/* Answer Feedback Animations */
@keyframes flash-green-shadow {
    50% { box-shadow: 0 0 40px 10px rgba(80, 227, 194, 0.7); }
}
@keyframes flash-red-shadow {
    50% { box-shadow: 0 0 40px 10px rgba(233, 69, 96, 0.7); }
}

body.correct-feedback .container {
    animation: flash-green-shadow 1s;
}
body.incorrect-feedback .container {
    animation: flash-red-shadow 1s;
}

@keyframes pulse-glow {
    from {
        text-shadow: 0 0 10px rgba(80, 227, 194, 0.5), 0 0 20px rgba(80, 227, 194, 0.2);
    }
    to {
        text-shadow: 0 0 20px rgba(80, 227, 194, 0.8), 0 0 35px rgba(80, 227, 194, 0.5);
    }
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Button Group for Confirm/Pass */
.button-group {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.button-group > .button {
    flex: 1;
}

/* BGM Player and Button */
#bgm-player {
    position: absolute;
    top: -9999px;
    left: -9999px;
}

#bgm-toggle-btn {
    padding: 8px 12px;
    font-size: 0.9em;
    background: rgba(26, 26, 46, 0.8);
    border: 2px solid #6c757d;
    color: #a0a0a0; /* OFF 상태 글자색 변경 */
    box-shadow: none;
    flex-grow: 1;
    min-width: 120px;
}

#bgm-controls {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    gap: 5px;
    box-shadow: 0 4px 15px 0 rgba(0, 0, 0, 0.2);
    border-radius: 5px;
    overflow: hidden;
    align-items: center;
}

.bgm-nav-btn {
    padding: 8px 12px;
    font-size: 0.9em;
    flex-grow: 0;
}

#bgm-select {
    background-color: rgba(26, 26, 46, 0.8);
    color: #f0f0f0;
    border: 2px solid #6c757d;
    padding: 8px;
    font-family: inherit;
    font-size: 0.9em;
    outline: none;
    cursor: pointer;
}
#bgm-select option {
    background-color: #1a1a2e;
    color: #f0f0f0;
}

#bgm-volume {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 6px;
    background: #2a3a5a;
    outline: none;
    opacity: 0.8;
    transition: opacity .2s;
    border-radius: 3px;
    margin: 0 5px;
}

#bgm-volume:hover {
    opacity: 1;
}

#bgm-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #4a90e2;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #1a1a2e;
}

#wrong-answer-feedback {
    margin-top: 20px;
    padding: 15px;
    background-color: rgba(233, 69, 96, 0.1);
    border: 1px solid #e94560;
    border-radius: 8px;
}
#wrong-answer-feedback p {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    color: #f0f0f0;
}
#wrong-answer-feedback strong {
    color: #50e3c2;
}


#bgm-volume::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4a90e2;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #1a1a2e;
}

/* Guestbook Form Desktop Styles */
#guestbook-form {
    flex-direction: row;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}
#guestbook-form #guestbook-name { flex: 1; }
#guestbook-form #guestbook-message { flex: 3; }
#guestbook-form button { flex: 0.8; }
#guestbook-form > * {
    margin: 0; /* Override .form-container defaults */
    padding: 10px;
}

/* Guestbook Styles (Moved from inline for responsiveness) */
.guestbook-entry {
    border-bottom: 1px solid #2a3a5a;
    padding: 10px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.guestbook-content {
    margin: 0;
    font-size: 1em;
    color: #c0c0c0;
    flex-grow: 1;
    text-align: left;
}

.guestbook-date {
    color: #a0a0a0;
    font-size: 0.9em;
    white-space: nowrap;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    body {
        align-items: flex-start;
        padding-top: 20px;
        padding-bottom: 160px;
    }

    .container {
        width: 95%;
        padding: 15px;
    }

    h1 {
        font-size: 2em;
    }

    .game-options-container {
        flex-direction: column;
        gap: 15px;
    }
    
    .option-group {
        justify-content: space-between;
        width: 100%;
    }

    /* Guestbook on mobile */
    .guestbook-entry {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .guestbook-date {
        align-self: flex-end;
        font-size: 0.8em;
    }

    /* Guestbook Form on mobile */
    #guestbook-form {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    #guestbook-form input, #guestbook-form button {
        width: 100%;
        margin: 5px 0 !important;
        flex: auto !important;
        box-sizing: border-box;
    }

    /* BGM Controls on mobile */
    #bgm-controls {
        width: 90%;
        left: 5%;
        right: 5%;
        bottom: 10px;
        flex-wrap: wrap;
        justify-content: center;
        background-color: rgba(26, 26, 46, 0.95);
        padding: 10px;
    }
    
    #bgm-select {
        width: 100% !important;
        margin-bottom: 10px;
        order: -1;
    }

    /* Make tables scrollable */
    .leaderboard-container {
        overflow-x: auto;
    }
    
    table {
        min-width: 500px;
    }
    
    /* Adjust external links buttons */
    .external-links .button {
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 5px;
    }
}
