/* FONT IMPORT */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Roboto:wght@400;500&display=swap');

/* GENERAL STYLING */
:root {
    --bg-main: #f0e5c9;
    --panel-bg: #e6d8b8;
    --border-color: #b49a6a;
    --header-bg: #4a2c2a;
    --text-dark: #4f3421;
    --text-light: #f5f5f5;
    --accent-color: #8c1c1c;
    --font-title: 'Cinzel', serif;
    --font-body: 'Roboto', sans-serif;
}
body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-dark);
    margin: 0;
    overflow-x: hidden;
}

/* HALAMAN SETUP (LOGIN, REGISTER, SUKU, POSISI AWAL) */
.auth-container, .tribe-selection-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}
.auth-form, .tribe-selection-container .panel {
    width: 100%;
    max-width: 400px;
    padding: 30px;
    background: var(--panel-bg);
    border: 3px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.tribe-selection-container .panel {
    max-width: 700px;
}
.auth-form h2, .tribe-selection-container h2 {
    font-family: var(--font-title);
    text-align: center;
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--header-bg);
}
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; }
.form-group input { width: 100%; padding: 10px; border: 1px solid var(--border-color); border-radius: 4px; box-sizing: border-box; background-color: #fff; }
.btn { width: 100%; padding: 12px; background-color: #2e7d32; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 1em; font-weight: bold; transition: background-color 0.3s; }
.btn:hover { background-color: #388e3c; }
.auth-link { text-align: center; margin-top: 20px; }
.auth-link a { color: var(--header-bg); text-decoration: none; font-weight: bold; }
.auth-link a:hover { text-decoration: underline; }
.message { text-align: center; padding: 10px; margin-bottom: 15px; border-radius: 4px; border: 1px solid transparent; }
.message.error { background-color: #f8d7da; color: #721c24; border-color: #f5c6cb; }
.message.success { background-color: #d4edda; color: #155724; border-color: #c3e6cb; }

/* Gaya Halaman Pemilihan Suku */
.tribe-selection-container { background-image: url('assets/images/tribe_background.jpg'); background-size: cover; background-position: center; }
.tribe-selection-container .panel { background-color: rgba(230, 216, 184, 0.95); }
.tribe-options { display: flex; justify-content: center; gap: 15px; margin: 20px 0; border: 2px solid var(--border-color); padding: 10px; background-color: rgba(0,0,0,0.1); border-radius: 5px; }
.tribe-option { display: block; position: relative; cursor: pointer; }
.tribe-option input[type="radio"] { position: absolute; opacity: 0; }
.tribe-card { padding: 10px; border-radius: 8px; text-align: center; transition: all 0.3s ease; width: 80px; height: 80px; background-color: var(--panel-bg); border: 3px solid transparent; background-size: cover; background-position: center; }
.tribe-option input[type="radio"]:checked + .tribe-card { border-color: var(--accent-color); transform: scale(1.1); }
.tribe-details { margin-top: 20px; min-height: 150px; }
.tribe-description h3 { font-family: var(--font-title); font-size: 1.8em; color: var(--accent-color); text-align: center; margin-bottom: 15px; }
.tribe-description ul { list-style: none; padding: 0; font-size: 1em; max-width: 450px; margin: 0 auto; }
.tribe-description li { margin-bottom: 10px; padding-left: 25px; position: relative; }
.tribe-description li::before { content: '✔'; position: absolute; left: 0; color: #2e7d32; font-size: 1.2em; }
.btn-confirm-tribe { width: 50%; margin: 20px auto 0; display: block; padding: 15px; font-size: 1.2em; }

/* Gaya Halaman Pemilihan Posisi Awal */
.start-position-map { position: relative; width: 100%; max-width: 500px; margin: 20px auto; border: 3px solid var(--border-color); background-size: cover; background-position: center; aspect-ratio: 1 / 1; }
.start-option { position: absolute; width: 50%; height: 50%; cursor: pointer; display: flex; justify-content: center; align-items: center; transition: background-color 0.3s; }
.start-option span { background-color: rgba(0,0,0,0.7); color: white; padding: 5px 10px; border-radius: 5px; font-weight: bold; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.start-option input:checked + span { opacity: 1; }
.start-option input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.start-option.nw { top: 0; left: 0; } .start-option.ne { top: 0; right: 0; } .start-option.sw { bottom: 0; left: 0; } .start-option.se { bottom: 0; right: 0; }
.start-option { background-color: rgba(0, 0, 0, 0.5); }
.start-option:hover { background-color: rgba(0, 0, 0, 0.3); }
.start-option:has(input:checked) { background-color: transparent; }
.start-option:has(input:checked):hover { background-color: rgba(255, 255, 255, 0.1); }

/* GAYA HALAMAN KONFIRMASI */
.confirmation-boxes { display: flex; justify-content: space-around; gap: 20px; margin-bottom: 30px; }
.confirm-box { background-color: #fdfaf2; border: 2px solid var(--border-color); border-radius: 5px; padding: 15px; text-align: center; width: 45%; }
.confirm-box h4 { margin-top: 0; font-family: var(--font-title); }
.confirm-box img { width: 80px; height: 80px; object-fit: contain; border-radius: 4px; margin-bottom: 10px; }
.confirm-box a { font-size: 0.9em; color: var(--text-dark); display: block; margin-top: 10px; }
.character-name-input { margin-bottom: 20px; }
.character-name-input label { display: block; margin-bottom: 10px; font-weight: bold; }
.character-name-input input { width: 100%; padding: 10px; font-size: 1.1em; border: 2px solid var(--border-color); border-radius: 5px; box-sizing: border-box; }
.info-box { margin-top: 10px; padding: 10px; background-color: rgba(0,0,0,0.05); border-radius: 5px; font-size: 0.9em; }

/* UI UTAMA GAME */
.top-bar { background-color: var(--header-bg); color: var(--text-light); display: flex; justify-content: space-between; align-items: center; padding: 5px 20px; border-bottom: 4px solid var(--border-color); position: sticky; top: 0; z-index: 1000; }
.resource-bar { display: flex; gap: 25px; font-weight: 500; font-size: 1.1em; }
.resource-bar > span { display: flex; align-items: center; gap: 8px; }
.resource-bar img { width: 24px; height: 24px; }
.resource-bar span.full span { color: #ff6b6b; font-weight: bold; }
.logout-button { background-color: var(--accent-color); color: var(--text-light); padding: 8px 15px; border-radius: 5px; text-decoration: none; font-weight: bold; transition: background-color 0.3s; }
.logout-button:hover { background-color: #a82c2c; }

.main-nav { display: flex; justify-content: center; background-color: var(--panel-bg); border-bottom: 3px solid var(--border-color); padding: 5px 0; }
.main-nav a { font-family: var(--font-title); font-size: 1.2em; font-weight: bold; color: var(--text-dark); text-decoration: none; padding: 10px 30px; border-bottom: 4px solid transparent; transition: all 0.3s ease; }
.main-nav a:hover { background-color: rgba(0,0,0,0.05); }
.main-nav a.active { color: var(--accent-color); border-bottom-color: var(--accent-color); }

.main-container.single-column { max-width: 1200px; margin: 20px auto; padding: 0 15px; }
.sidebar { width: 100%; }

.panel { background-color: var(--panel-bg); border: 3px solid var(--border-color); border-radius: 8px; padding: 15px; margin-bottom: 20px; box-shadow: 0 4px 8px rgba(0,0,0,0.2); }
.panel h3, .panel h2 { font-family: var(--font-title); font-weight: 700; color: var(--header-bg); margin-top: 0; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; text-align: center; }

.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 15px; }
.building-item { background: #fdfaf2; border: 2px solid var(--border-color); padding: 15px; border-radius: 5px; text-align: center; transition: transform 0.2s, box-shadow 0.2s; }
.building-item h3 { margin-top: 0; margin-bottom: 10px; font-size: 1.1em; }
.upgrade-info .costs { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; font-size: 0.9em; }
.upgrade-info .costs span { display: flex; align-items: center; gap: 4px; }
.btn-upgrade, .btn-disabled { display: inline-block; color: white; padding: 8px 15px; text-decoration: none; border-radius: 4px; margin-top: 10px; font-size: 0.9em; border: none; cursor: pointer; width: 90%; font-weight: bold; }
.btn-upgrade { background-color: #2e7d32; transition: background-color 0.3s; }
.btn-upgrade:hover { background-color: #388e3c; }
.btn-disabled { background-color: #9e9e9e; cursor: not-allowed; }
.max-level-text { font-weight: bold; color: var(--accent-color); margin-top: 20px; }

.queue-box { text-align: center; }
#countdown-timer { font-size: 1.2em; font-weight: bold; color: var(--accent-color); }

.btn-action { display: block; background-color: #1976d2; color: white; padding: 8px 15px; text-decoration: none; border-radius: 4px; margin-bottom: 10px; font-size: 0.9em; font-weight: bold; transition: background-color 0.3s; }
.btn-action:hover { background-color: #1565c0; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); z-index: 2000; justify-content: center; align-items: center; }
.modal-overlay.show { display: flex; }
.modal-content { background-color: var(--panel-bg); border: 3px solid var(--border-color); border-radius: 8px; padding: 20px 30px; width: 90%; max-width: 400px; text-align: center; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.modal-content h3 { font-family: var(--font-title); color: var(--accent-color); margin-top: 0; border-bottom: none; }
.modal-close-btn { position: absolute; top: 5px; right: 15px; font-size: 2em; font-weight: bold; color: var(--text-dark); cursor: pointer; }

.resource-map-container, .village-map-container { position: relative; width: 100%; max-width: 900px; margin: 20px auto; background-size: cover; background-position: center; aspect-ratio: 826 / 639; }
.resource-slot, .building-slot { position: absolute; width: 50px; height: 50px; background-color: rgba(255, 255, 255, 0.8); border: 2px solid #fff; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 1.3em; font-weight: bold; color: var(--header-bg); text-decoration: none; box-shadow: 0 0 10px rgba(0,0,0,0.5); transition: all 0.3s ease; cursor: pointer; transform: translate(-50%, -50%); }
.resource-slot:hover, .building-slot:hover { transform: translate(-50%, -50%) scale(1.1); background-color: #fff; }
.building-slot.town-hall { width: 80px; height: 80px; font-size: 1.8em; }

.resource-slot[data-tooltip]::after, .building-slot[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: 125%; left: 50%; transform: translateX(-50%); background-color: var(--header-bg); color: var(--text-light); padding: 5px 10px; border-radius: 5px; font-size: 0.8em; font-weight: normal; white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; z-index: 10; }
.resource-slot[data-tooltip]:hover::after, .building-slot[data-tooltip]:hover::after { opacity: 1; visibility: visible; }

/* Posisi Slot Sumber Daya */
.slot-1 { top: 45%; left: 18%; } .slot-2 { top: 55%; left: 28%; } .slot-3 { top: 65%; left: 18%; }
.slot-4 { top: 45%; left: 82%; } .slot-5 { top: 55%; left: 72%; } .slot-6 { top: 65%; left: 82%; }
.slot-7 { top: 20%; left: 45%; } .slot-8 { top: 20%; left: 60%; } .slot-9 { top: 88%; left: 45%; }
.slot-10 { top: 88%; left: 60%; } .slot-11 { top: 25%; left: 25%; } .slot-12 { top: 15%; left: 15%; }
.slot-13 { top: 25%; left: 75%; } .slot-14 { top: 15%; left: 85%; } .slot-15 { top: 40%; left: 50%; }
.slot-16 { top: 58%; left: 40%; } .slot-17 { top: 58%; left: 60%; } .slot-18 { top: 75%; left: 50%; }

/* Posisi Slot Bangunan Desa */
.building-slot-5 { top: 50%; left: 50%; } .building-slot-6 { top: 35%; left: 35%; }
.building-slot-7 { top: 35%; left: 65%; } .building-slot-8 { top: 65%; left: 35%; }
.building-slot-9 { top: 65%; left: 65%; }

/* RESPONSIVE DESIGN */
@media (max-width: 992px) { .main-container.single-column { grid-template-columns: 1fr; } }
@media (max-width: 768px) { .top-bar { flex-direction: column; gap: 10px; } .resource-bar { font-size: 1em; gap: 15px; flex-wrap: wrap; justify-content: center; } }
