@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=MedievalSharp&display=swap');

/* --- BASE LAYOUT --- */
body {
    margin: 0; height: 100vh; display: flex; background-color: #1a1510; color: #e0d0b0;
    font-family: 'MedievalSharp', cursive; overflow: hidden;
}

/* --- LOBBY --- */
#lobby-screen { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #111; z-index: 200; display: flex; align-items: center; justify-content: center; }
#lobby-screen::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: -1; }
.lobby-content { background: #2b2218; border: 4px double #d4af37; padding: 40px; text-align: center; max-width: 800px; width: 90%; box-shadow: 0 0 50px black; }
#hero-selection-grid { display: flex; gap: 20px; justify-content: center; margin: 30px 0; flex-wrap: wrap; }
.hero-card { background: #1a1510; border: 2px solid #555; padding: 10px; width: 140px; cursor: default; transition: 0.2s; border-radius: 5px; display: flex; flex-direction: column; align-items: center; }
.hero-card.selected { border-color: #d4af37; background: #3e2b10; box-shadow: 0 0 15px gold; }
.hero-select-area { width: 100%; cursor: pointer; text-align: center; }
.cpu-toggle { margin-top: 10px; font-size: 10px; padding: 4px; width: 80%; background: #444; border: 1px solid #777; cursor: pointer; }
.cpu-toggle.cpu-active { background: #b91c1c; border-color: #f00; }

/* --- SIDEBAR --- */
#sidebar { width: 320px; background: #2b2218; border-right: 4px solid #8b6c42; padding: 20px; box-shadow: 5px 0 15px rgba(0,0,0,0.8); z-index: 10; display: flex; flex-direction: column; overflow-y: auto; }
#btn-help { width: 30px; height: 30px; border-radius: 50%; background: #d4af37; color: #000; border: none; font-weight: bold; cursor: pointer; }
h1, h2, h3 { font-family: 'Cinzel', serif; color: #d4af37; text-shadow: 2px 2px 0px #000; margin-top: 0; }
.card { background: rgba(0,0,0,0.3); border: 1px solid #5a4a35; padding: 15px; margin-bottom: 20px; border-radius: 4px; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 1.1em; }
.stat-val { color: #fff; font-weight: bold; }
button { background: #6e1818; color: white; font-family: 'Cinzel', serif; font-size: 16px; padding: 10px; border: 2px solid #3e0b0b; cursor: pointer; transition: 0.2s; width: 100%; margin-top: 10px; }
button:hover { background: #8e2222; box-shadow: 0 0 10px #ff0000; }
button:disabled { background: #444; border-color: #222; color: #888; cursor: not-allowed; box-shadow: none; }
#inventory-list { margin-top: 10px; padding-top: 10px; border-top: 1px solid #555; }
.inv-item { font-size: 0.85em; padding: 3px; background: #222; margin-bottom: 4px; border-left: 2px solid #555; }
.inv-sword { border-color: #d4af37; color: #ffeb3b; }
.inv-treasure { border-color: #00bcd4; color: #00bcd4; }
.inv-rune { border-color: #9c27b0; color: #e1bee7; }

/* --- MAP & TOKENS --- */
#game-viewport { flex-grow: 1; position: relative; overflow: auto; background: #0f0c09; cursor: grab; }
#game-viewport:active { cursor: grabbing; }
#map-container { position: relative; display: inline-block; }
#map-img { display: block; pointer-events: none; user-select: none; }
.token { position: absolute; width: 32px; height: 32px; transform: translate(-50%, -50%); border: 2px solid white; box-shadow: 0 2px 5px black; display: flex; align-items: center; justify-content: center; font-weight: bold; font-size: 12px; cursor: pointer; z-index: 5; transition: top 0.3s, left 0.3s; }
.token.hero { background: #1e3a8a; border-radius: 50%; }
.token.monster { background: #7f1d1d; border-radius: 4px; }
.token.jarl { background: #064e3b; border-radius: 4px; } 
.token.unknown { background: #444; border: 2px dashed #888; color: #ccc; font-family: monospace; font-size: 16px; border-radius: 4px; }
.token.hero.wounded { border-color: red; box-shadow: 0 0 10px red; }
.token.hero.wounded::after { content: "🩸"; position: absolute; top: -10px; right: -10px; font-size: 14px; }
.zone-marker { position: absolute; width: 30px; height: 30px; border-radius: 50%; transform: translate(-50%, -50%); background: rgba(255, 215, 0, 0.0); cursor: pointer; z-index: 10; }
.zone-marker:hover { background: rgba(255, 215, 0, 0.4); border: 1px solid yellow; }
.zone-marker.valid-move { background: rgba(0, 255, 0, 0.3); border: 2px dashed #0f0; width: 50px; height: 50px; animation: pulse 1.5s infinite; }
.zone-marker.controlled { width: 50px; height: 50px; border: 4px double gold; background: rgba(255, 215, 0, 0.1); border-radius: 50%; }
@keyframes pulse { 0% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.2); } 100% { transform: translate(-50%, -50%) scale(1); } }

/* --- MODALS --- */
#modal-overlay, #recruit-modal, #rules-modal, #game-over-modal, #cpu-overlay, #gods-modal, #rest-modal, #reward-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 100; display: none; align-items: center; justify-content: center; }
#modal-overlay { background: rgba(0,0,0,0.85); }
.modal-backdrop { position: absolute; width: 100%; height: 100%; background: rgba(0,0,0,0.8); }
#combat-panel { background: #2b2218; border: 4px double #d4af37; padding: 30px; width: 500px; max-width: 90%; text-align: center; }
.combat-grid { display: grid; grid-template-columns: 1fr 50px 1fr; gap: 10px; align-items: center; margin-bottom: 20px; }
.combat-portrait { background: #443322; border: 2px solid #d4af37; padding: 10px; border-radius: 8px; }
.vs-badge { font-size: 20px; font-weight: bold; color: #8b0000; }
.stat-box { background: #000; color: #0f0; font-family: monospace; padding: 5px; margin-top: 5px; border: 1px solid #333; }
.luck-controls { background: rgba(0,0,0,0.3); padding: 10px; border: 1px dashed #555; margin: 15px 0; }
#dice-display { font-size: 3em; color: #fff; text-shadow: 0 0 10px gold; height: 60px; transition: transform 0.2s; margin: 10px 0; }
.roll-anim { animation: shake 0.5s infinite; }
.combat-log-text { color: #e0d0b0; font-size: 1.1em; margin-top: 15px; font-style: italic; min-height: 24px; }
#cpu-overlay { background: transparent; pointer-events: none; top: 20px; left: 50%; width: auto; height: auto; justify-content: center; }
#cpu-overlay div.cpu-container { background: rgba(0,0,0,0.8); padding: 10px 20px; border-radius: 20px; border: 1px solid #d4af37; display: flex; align-items: center; gap: 10px; }
.cpu-spinner { width: 20px; height: 20px; border: 3px solid #fff; border-top: 3px solid #d4af37; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.recruit-panel, .rules-panel { position: relative; background: #2b2218; border: 2px solid #d4af37; padding: 30px; width: 400px; max-width: 90%; text-align: center; box-shadow: 0 0 30px gold; }
.rules-panel { background: #e0d0b0; color: #2b2218; width: 600px; border-width: 8px; text-align: left; }
.recruit-options { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; justify-content: center; }
.rules-header { display: flex; justify-content: space-between; border-bottom: 2px solid #443322; margin-bottom: 10px; }
.rules-content { overflow-y: auto; max-height: 60vh; }

/* MOBILE */
@media (max-width: 768px) {
    body { flex-direction: column-reverse; }
    #game-viewport { height: 65vh; flex-grow: 0; }
    #sidebar { width: 100%; height: 35vh; border-right: none; border-top: 4px solid #8b6c42; padding: 10px; box-sizing: border-box; }
    #sidebar h1, #sidebar h3 { display: inline-block; font-size: 1.2em; margin-right: 10px; }
    .card { padding: 8px; margin-bottom: 10px; }
    .stat-row { font-size: 0.9em; margin-bottom: 4px; }
    #action-log { height: 60px; }
    .rules-panel, #combat-panel, .recruit-panel { width: 95%; max-height: 90vh; padding: 15px; }
    button { padding: 12px; font-size: 14px; }
    @media (max-width: 400px) { .combat-grid { grid-template-columns: 1fr; } .vs-badge { margin: 5px 0; } }
}