/* General Body and App Container Styling */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Helvetica Neue', Arial, sans-serif;
    overflow: hidden;
    background-color: #000;
    color: #fff;
    -webkit-user-select: none; /* Safari */
    -ms-user-select: none; /* IE 10+ and Edge */
    user-select: none; /* Standard syntax */
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Page Styling */
.page {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    padding: 20px;
    flex-direction: column;
    transition: opacity 0.5s ease;
}

.page.active {
    display: flex; /* Shown when active */
    opacity: 1;
}

.page-content {
    background: rgba(0, 0, 0, 0.7); /* Slightly darker for better contrast */
    padding: 20px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

h1, h2, h3, p {
    margin: 0;
    padding: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
}

h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

h2 {
    font-size: 1.8em;
    margin-bottom: 20px;
}

/* Main Menu Specific Styles */
#main-title {
    color: #FFD700; /* Gold */
    animation: fadeIn 2s, pulse 4s infinite 2s;
}

#main-subtitle {
    font-size: 1.2em;
    margin-bottom: 20px;
    animation: fadeIn 3s;
}

/* User Profile Styles for Single User & Level System */
.user-profile-container {
    background-color: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin: 0 auto 20px;
    width: 100%;
    max-width: 300px;
    text-align: center;
    box-sizing: border-box;
}
#user-display-mode, #user-edit-mode {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}
#current-username-display {
    font-size: 1.3em;
    font-weight: bold;
    color: #FFD700;
}
.small-btn {
    padding: 5px 10px;
    font-size: 0.8em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    background: #555;
    color: #fff;
    transition: background-color 0.2s;
}
.small-btn:hover {
    background: #777;
}
#new-username-input {
    flex-grow: 1;
    padding: 8px;
    border-radius: 5px;
    border: 1px solid #777;
    background-color: #333;
    color: #fff;
}
.level-container {
    width: 100%;
}
#level-display {
    font-size: 1em;
    font-weight: bold;
    color: #ccc;
    margin-bottom: 5px;
    display: block;
}
.xp-bar-container {
    width: 100%;
    height: 15px;
    background-color: #333;
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid #555;
}
#xp-bar-inner {
    height: 100%;
    width: 0%; /* Set by JS */
    background: linear-gradient(90deg, #4d90fe, #5db85d);
    border-radius: 10px;
    transition: width 0.5s ease;
}
#xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.7em;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
    margin: 20px auto 0;
}

.main-menu-btn, .result-page-btn, .back-btn, .overlay-content button {
    padding: 15px 20px;
    font-size: 1.2em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    background: linear-gradient(145deg, #f0c14b, #d8ab3a);
    color: #111;
    font-weight: bold;
    box-shadow: 0 5px #a88734;
    transition: all 0.1s ease-in-out;
}

.main-menu-btn:active, .result-page-btn:active, .back-btn:active, .overlay-content button:active {
    transform: translateY(3px);
    box-shadow: 0 2px #a88734;
}

/* Level Page Styles */
.difficulty-container {
    text-align: center;
    width: 100%;
    margin-bottom: 20px;
}
#difficulty-select {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    font-size: 1em;
    margin-top: 10px;
    border-radius: 10px;
    border: 2px solid #ddd;
    background-color: #fff;
}

#difficulty-select option:disabled {
    color: #999;
}

.category-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.category-btn {
    border: none;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    padding: 0;
    aspect-ratio: 1 / 1;
    transition: transform 0.2s, opacity 0.3s;
}
.category-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}
.category-btn:disabled .lock-icon {
    display: flex;
}

.category-btn:active {
    transform: scale(0.95);
}

.category-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.category-btn span {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 0;
    font-size: 1em;
    font-weight: bold;
}
.lock-icon {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #FFD700;
    font-size: 3em;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
    text-shadow: 0 0 10px #000;
}

/* Quiz Page Styles */
#score-popup-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}
.score-popup {
    position: absolute;
    left: 50%;
    bottom: 15%;
    transform: translateX(-50%);
    color: #FFD700;
    font-size: 1.1em;
    font-weight: bold;
    text-shadow: 2px 2px 5px #000;
    animation: floatUp 1.5s ease-out forwards;
}
#current-score-display {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.2em;
    font-weight: bold;
    background-color: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 8px;
}
.exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2em;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    text-shadow: 2px 2px 4px #000;
    z-index: 10;
}

#quiz-image-container {
    position: relative;
    margin-bottom: 15px;
}

#quiz-image {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 10px;
    display: block;
}

/* MODIFIED: Image credit is now subtle text with a shadow */
#image-attribution {
    position: absolute;
    bottom: 8px;
    right: 8px;
    font-size: 10px;
    color: #f0f0f0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.9);
    max-width: calc(100% - 16px);
    text-align: right;
    display: none;
}

#question-text {
    font-size: 1.3em;
    margin-bottom: 20px;
    min-height: 50px;
}

#answer-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.answer-btn {
    padding: 15px 10px;
    font-size: 1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    color: white;
    font-weight: bold;
}
.answer-btn.disabled {
    pointer-events: none;
    opacity: 0.6;
}

.Restoran-btn { background-color: #c0392b; }
.Minimarket-btn { background-color: #2980b9; }
.Kereta-btn { background-color: #8e44ad; }
.Apotek-btn { background-color: #27ae60; }

.answer-btn:hover {
    opacity: 0.9;
}

.ad-placeholder-bottom, .ad-placeholder-center {
    width: 100%;
    max-width: 320px;
    height: 50px;
    background-color: #444;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 15px auto 0;
    border-radius: 5px;
}

/* Timer Bar Styles */
#timer-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 5px;
    width: 100%;
}
#timer-container span { font-size: 1.5em; }
.timer-bar-outer {
    flex-grow: 1;
    height: 10px;
    background-color: #555;
    border-radius: 5px;
    overflow: hidden;
}
#timer-bar-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #66ff66, #ffff66, #ff6666);
    background-size: 300% 100%;
    border-radius: 5px;
    transition: width 0.1s linear;
}

.progress-container {
    width: 100%;
    background-color: #555;
    border-radius: 5px;
    height: 10px;
    margin-top: 5px;
}

#progress-bar {
    width: 0%;
    height: 100%;
    background-color: #4caf50;
    border-radius: 5px;
    transition: width 0.3s ease;
}

/* Result Page Styles */
.result-report {
    width: 100%;
    max-width: 350px;
    margin-bottom: 20px;
}
.result-report h2 {
    font-size: 1.5em;
    margin-bottom: 10px;
}
#result-image {
    width: 100%;
    max-width: 200px;
    border-radius: 10px;
    margin: 10px 0;
    border: 3px solid #777;
}
#score-text {
    font-size: 1.3em;
    font-weight: bold;
    margin-bottom: 8px;
}
#result-text {
    font-size: 1.5em;
    margin-bottom: 5px;
    color: #FFD700;
}
#result-subtext {
    font-size: 1em;
}

/* Jejak Petualangan & Guidebook Page Styles */
.adventure-log-content, .guidebook-content {
    width: 100%;
    max-width: 600px;
}
.tabs {
    display: flex;
    margin-bottom: 15px;
    background-color: rgba(0,0,0,0.4);
    border-radius: 10px;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: #ccc;
    font-size: 1em;
    cursor: pointer;
    border-radius: 10px;
    transition: background-color 0.3s, color 0.3s;
}
.tab-btn.active {
    background-color: #FFD700;
    color: #111;
    font-weight: bold;
}
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}
.tab-content-container {
}

#leaderboard h3 {
    margin-bottom: 10px;
}

.leaderboard-container {
    height: 380px; 
    overflow-y: auto;
    border: 1px solid #555;
    border-radius: 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
}
th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #555;
}
table thead tr {
    position: sticky;
    top: 0;
    z-index: 1;
}
th {
    background-color: #3a3a3a;
}
tbody tr:last-child td {
    border-bottom: none;
}
td:nth-child(1), th:nth-child(1) { width: 10%; text-align: center; }
td:nth-child(2), th:nth-child(2) { width: 40%; }
td:nth-child(3), th:nth-child(3) { width: 20%; text-align: right; }
td:nth-child(4), th:nth-child(4) { width: 30%; }

/* Achievements Page Styles */
.achievements-container {
    height: 380px;
    overflow-y: auto;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 15px;
    box-sizing: border-box;
    background-color: rgba(0,0,0,0.2);
}
#achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}
.achievement-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid #444;
    cursor: pointer;
    transition: background-color 0.2s;
}
.achievement-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}
.achievement-item.unlocked {
    background-color: rgba(255, 215, 0, 0.1);
    border-color: #FFD700;
}
.achievement-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
    transition: filter 0.3s, opacity 0.3s;
}
.achievement-item.locked .achievement-icon {
    filter: grayscale(100%);
    opacity: 0.5;
}
.achievement-item.unlocked .achievement-icon {
    filter: none;
    opacity: 1;
}
.achievement-title {
    font-size: 0.8em;
    font-weight: bold;
    color: #fff;
    text-align: center;
}
.achievement-item.locked .achievement-title {
    color: #888;
}

/* Overlay Styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.overlay.active {
    display: flex;
    opacity: 1;
}
.overlay-content {
    background: #2c2c2c;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border: 2px solid #FFD700;
}
.overlay-content h2 {
    color: #FFD700;
}

/* Achievement Popup Styles */
.achievement-popup img {
    width: 80px;
    height: 80px;
    margin: 10px auto;
}
.achievement-popup h3 {
    font-size: 1.4em;
    color: #FFD700;
}
.achievement-popup p {
    font-size: 0.9em;
    color: #ccc;
    margin-bottom: 15px;
}
.achievement-popup-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
}
.achievement-popup-buttons button {
    flex: 1;
}

/* Journal Popup Styles */
#journal-content {
    max-height: 60vh;
    overflow-y: auto;
    text-align: left;
    width: 100%;
    padding-right: 10px;
    box-sizing: border-box;
}
.journal-item {
    background-color: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}
.journal-item p { text-shadow: none; }
.journal-question {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 1.1em;
}
.journal-answer {
    padding: 8px;
    border-radius: 5px;
    margin: 4px 0;
    font-size: 0.9em;
}
.journal-answer.correct {
    background-color: rgba(39, 174, 96, 0.7);
    color: white;
}
.journal-answer.incorrect {
    background-color: rgba(192, 57, 43, 0.7);
    color: white;
}
.journal-answer.user-answer::before {
    content: '▶ ';
    font-weight: bold;
}

/* Guidebook Page Specific Styles */
.guidebook-content .tab-content {
    text-align: left;
    padding-right: 10px;
}
.guidebook-content h4 {
    color: #FFD700;
    margin-top: 15px;
    margin-bottom: 5px;
}
.guidebook-content p {
    font-size: 0.9em;
    line-height: 1.5;
    margin-bottom: 10px;
    color: #ddd;
}
.guidebook-content strong {
    color: #f0c14b;
}
.guidebook-content .back-btn {
    margin-top: 20px;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse {
    0% { color: #FFD700; text-shadow: 0 0 5px #FFD700; }
    50% { color: #FFF; text-shadow: 0 0 20px #FFF; }
    100% { color: #FFD700; text-shadow: 0 0 5px #FFD700; }
}
@keyframes floatUp {
    0% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -100px); }
}