:root {
    --cor-fundo: #ffede0;
    --cor-laranja: #ff8c42;
    --cor-laranja-escuro: #e07b39;
    --cor-texto: #333;
    --cor-hp: #d9534f;
    --cor-energia: #5bc0de;
    --cor-adrenalina: #f0ad4e;
    --cor-borda: #ccc;
    --cor-defesa: #888;
}

body.night-mode {
    --cor-fundo: #1a1a1a;
    --cor-laranja: #b35900;
    --cor-laranja-escuro: #804000;
    --cor-texto: #e0e0e0;
    --cor-borda: #444;
    background: linear-gradient(180deg, #111, #000);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background: linear-gradient(180deg, #ffb74d, #ff9800);
    color: var(--cor-texto);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
    transition: background 0.3s, color 0.3s;
}

.game-container {
    width: 100%;
    max-width: 480px;
    background-color: var(--cor-fundo);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    min-height: 95vh;
    max-height: 95vh;
    transition: background-color 0.3s;
}
.layout-switch { display: flex; justify-content: flex-end; gap: 4px; padding: 8px 12px 0; flex-shrink: 0; }
.layout-option { padding: 7px 12px; border: 1px solid var(--cor-borda); border-radius: 6px; background: transparent; color: var(--cor-texto); cursor: pointer; }
.layout-option[aria-pressed="true"] { background: var(--cor-laranja-escuro); color: white; border-color: var(--cor-laranja-escuro); }

body.pc-mode .game-container { max-width: 1180px; }
body.pc-mode .screen { padding: 28px 40px; }
body.pc-mode #start-screen { flex-flow: row wrap; align-content: flex-start; align-items: flex-start; }
body.pc-mode #start-screen .game-title { flex-basis: 100%; }
body.pc-mode #start-screen > .btn { flex: 1 1 28%; max-width: 260px; min-width: 180px; }
body.pc-mode .pc-list-divider { flex: 0 0 100%; height: 2px; margin-top: 8px; background: var(--cor-borda); }
body.pc-mode .history-panel, body.pc-mode .achievements-panel { width: 44%; max-height: none; overflow: visible; align-self: flex-start; }
body.pc-mode .battle-area { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "progress progress" "enemy player" "log log" "actions actions"; gap: 12px; align-content: start; }
body.pc-mode #battle-progress { grid-area: progress; }
body.pc-mode #enemy-display { grid-area: enemy; width: auto; margin: 0; }
body.pc-mode #player-display { grid-area: player; width: auto; margin: 0; }
body.pc-mode #log-message { grid-area: log; }
body.pc-mode .action-panel { grid-area: actions; }
body.pc-mode .path-choices { flex-direction: row; }
body.pc-mode .path-choices .btn { flex: 1; min-width: 0; }

@media (max-width: 700px) {
    body.pc-mode .battle-area { grid-template-columns: 1fr; grid-template-areas: "progress" "enemy" "log" "player" "actions"; }
    body.pc-mode .screen { padding: 20px; }
}

.screen {
    padding: 20px;
    box-sizing: border-box;
    display: none !important;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
}
.screen.active { display: flex !important; }

h1, h2, h3 { color: var(--cor-laranja-escuro); margin-top: 0; }

#start-screen { justify-content: center; }
.game-title { font-size: 2.5em; font-weight: bold; margin-bottom: 20px; }

.btn {
    background-color: var(--cor-laranja); color: white; border: none;
    padding: 15px 30px; border-radius: 8px; font-size: 1.2em;
    cursor: pointer; margin: 5px; transition: 0.2s; min-width: 200px;
}
.btn:hover { background-color: var(--cor-laranja-escuro); }
.btn:active { transform: scale(0.98); }
.btn:disabled { background-color: #888; cursor: not-allowed; }

.btn-delete { background-color: #a9a9a9; }
.btn-delete:hover { background-color: #8b8b8b; }
.btn-night { background-color: #333; }

.history-panel, .achievements-panel {
    width: 90%; background: rgba(0,0,0,0.1); border-radius: 8px;
    padding: 10px; margin-top: 15px; text-align: left; max-height: 150px; overflow-y: auto;
    font-size: 0.9em;
}
.achievement-entry { padding: 5px 0; border-bottom: 1px solid rgba(0,0,0,0.1); }
.achievement-entry small { display: block; margin: 3px 0 0 24px; opacity: 0.75; }

.input-group { margin: 10px 0; width: 100%; }
.input-group select { width: 85%; padding: 10px; font-size: 1.1em; }
input[type="text"] { width: 80%; padding: 10px; font-size: 1.1em; border-radius: 5px; border: 1px solid var(--cor-borda); }
.emoji-selector { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 10px; }
.emoji-btn { font-size: 2em; padding: 5px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; background: none; }
.emoji-btn.selected { border-color: var(--cor-laranja); background-color: rgba(255,140,66,0.2); }

.battle-area { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "progress progress" "enemy player" "log log" "actions actions"; gap: 8px; align-content: start; flex-grow: 1; }
.battle-header { grid-area: progress; }
.battle-area #enemy-display { grid-area: enemy; width: auto; margin: 0; }
.battle-area #player-display { grid-area: player; width: auto; margin: 0; }
.battle-area #log-message { grid-area: log; }
.battle-area .action-panel { grid-area: actions; }
.character-display { border: 2px solid var(--cor-borda); border-radius: 10px; padding: 10px; margin: 5px auto; background-color: rgba(255,255,255,0.1); width: 90%; position: relative; }
.character-name { font-weight: bold; font-size: 1.2em; margin-bottom: 5px; }
.character-art { font-size: 3.5em; margin: 5px 0; line-height: 1; transition: transform 0.1s; }
.battle-header { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.battle-header .room-progress { margin: 0; }
.shield-indicator { min-height: 1.2em; color: #4383a5; font-weight: bold; }
.enemy-intent { margin-top: 8px; padding: 8px; border-radius: 6px; background: rgba(217, 83, 79, 0.12); font-weight: bold; }
.intent-reveal { animation: intent-reveal 0.4s ease-out; }
@keyframes intent-reveal { 0% { transform: scale(0.96); opacity: 0.45; } 100% { transform: scale(1); opacity: 1; } }
.damage-flash { animation: damage-flash 0.42s ease-out; }
@keyframes damage-flash { 35% { background-color: rgba(217, 83, 79, 0.3); border-color: #d9534f; } }
.shield-pulse { animation: shield-pulse 0.42s ease-out; }
@keyframes shield-pulse { 50% { box-shadow: 0 0 18px rgba(91, 192, 222, 0.8); border-color: #5bc0de; } }
.combat-effect { position: absolute; z-index: 8; top: 38%; left: 50%; white-space: nowrap; font-size: 1.05rem; font-weight: bold; text-shadow: 0 1px 3px white; pointer-events: none; animation: combat-float 0.9s ease-out forwards; }
.combat-effect.damage { color: #c62828; }
.combat-effect.blocked { color: #24738e; }
.combat-effect.shield { color: #1683a5; }
.combat-effect.healing { color: #388e3c; }
.combat-effect.energy { color: #008da8; }
@keyframes combat-float { 0% { opacity: 0; transform: translate(-50%, 10px) scale(0.85); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -42px) scale(1.05); } }
.hit-anim { transform: scale(1.2) rotate(5deg); color: red; }
.monster-dying { animation: monster-die 1.0s forwards; }
@keyframes monster-die { to { transform: rotate(180deg) scale(0); opacity: 0; } }
.log-message.victory-banner { position: fixed; top: 20px; left: 50%; z-index: 10; width: max-content; max-width: 90vw; height: auto; padding: 12px 24px; transform: translateX(-50%); background: #4caf50; color: white; border-radius: 8px; box-shadow: 0 3px 12px rgba(0,0,0,0.3); }

.stat-bars { width: 100%; }
.stat-bar { width: 100%; background-color: rgba(0,0,0,0.2); border-radius: 20px; margin: 5px 0; position: relative; height: 25px; overflow: hidden; border: 1px solid var(--cor-borda); }
.stat-bar > div { height: 100%; border-radius: 20px; transition: width 0.1s linear; text-align: right; padding-right: 5px; color: white; font-weight: bold; font-size: 0.9em; line-height: 25px; text-shadow: 1px 1px 2px rgba(0,0,0,0.5); }
.bar-label { position: absolute; left: 10px; top: 0; line-height: 25px; color: var(--cor-texto); font-weight: bold; font-size: 0.9em; z-index: 2; }

#hp-bar-fill, #enemy-hp-bar-fill { background-color: var(--cor-hp); }
#energy-bar-fill { background-color: var(--cor-energia); }
#adrenaline-bar-fill { background-color: var(--cor-adrenalina); }

.status-effects { display: flex; justify-content: center; gap: 5px; height: 20px; margin-top: 5px; font-size: 0.9em; color: red; font-weight: bold; }
.defending { border-color: var(--cor-defesa) !important; box-shadow: 0 0 10px var(--cor-defesa); }

.action-panel { margin-top: 10px; width: 100%; }
.card-hand-header { display: flex; justify-content: space-between; align-items: center; text-align: left; }
.card-hand-header h3 { margin: 0; }
.active-passives { min-height: 1em; margin-top: 4px; text-align: left; font-size: 0.75em; opacity: 0.8; }
.card-hand { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; width: 100%; margin-top: 8px; overflow: visible; }
.battle-card { position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; justify-self: center; width: 100%; max-width: 160px; gap: 3px; min-width: 0; aspect-ratio: 1; padding: 5px 3px; border: 2px solid var(--cor-borda); border-radius: 8px; background: rgba(255,255,255,0.65); color: var(--cor-texto); font-size: 0.78em; cursor: pointer; }
.battle-card.attack-card { border-color: #d9534f; }
.battle-card.defense-card { border-color: #5bc0de; }
.battle-card.recovery-card { border-color: #55a66d; }
.battle-card.strategy-card { border-color: #d28a3c; }
.battle-card.combination-card { border-color: #8066a3; }
.battle-card > span, .battle-card strong { max-width: 100%; overflow-wrap: anywhere; }
.battle-card:disabled { opacity: 0.5; cursor: not-allowed; }
.battle-card.empty-card { border-style: dashed; opacity: 0.5; cursor: default; }
.battle-card:not(:disabled):hover { transform: translateY(-7px); box-shadow: 0 6px 14px rgba(0,0,0,0.2); }
.battle-card.card-drawn { animation: card-drawn 0.28s ease-out both; }
@keyframes card-drawn { from { opacity: 0; transform: translateY(12px) scale(0.92); } to { opacity: 1; transform: translateY(0) scale(1); } }
.card-symbol { font-size: 1.7em; line-height: 1; }
.card-cost { font-weight: bold; }
.battle-card[data-tooltip]:hover::after, .battle-card[data-tooltip]:focus-visible::after { content: attr(data-tooltip); position: absolute; z-index: 20; bottom: calc(100% + 8px); left: 0; width: min(260px, 78vw); padding: 10px; border-radius: 6px; background: #222; color: white; text-align: left; white-space: pre-line; font-size: 12px; font-weight: normal; box-shadow: 0 3px 12px rgba(0,0,0,0.35); pointer-events: none; }
.battle-card:nth-child(n+3)[data-tooltip]:hover::after, .battle-card:nth-child(n+3)[data-tooltip]:focus-visible::after { left: auto; right: 0; }
.end-turn-btn { width: 100%; margin: 10px 0 0; }
.end-turn-btn:disabled { opacity: 0.6; }
.room-progress { margin: 0 0 12px; font-weight: bold; }
.path-choices { display: flex; flex-direction: column; width: 100%; gap: 8px; }
.path-choices .btn { width: 100%; }

.log-message { margin-top: 5px; font-style: italic; font-size: 0.9em; height: 1.2em; color: var(--cor-texto); font-weight: bold; }

.money-display { font-size: 1.5em; font-weight: bold; color: #e69100; margin-bottom: 15px; }
.shop-category { width: 100%; margin-bottom: 15px; border: 1px solid var(--cor-borda); border-radius: 8px; padding: 10px; box-sizing: border-box; }
.shop-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.1); text-align: left; }
.shop-item-info { width: 70%; }
.item-name { font-size: 1.1em; font-weight: bold; }
.item-desc { font-size: 0.8em; opacity: 0.8; }
.btn-buy { padding: 8px; font-size: 0.9em; min-width: 80px; margin: 0; }

#game-over-screen h1 { color: var(--cor-hp); }
.stats-summary { text-align: left; margin: 20px 0; background: rgba(0,0,0,0.1); padding: 15px; border-radius: 10px; }