@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600&family=EB+Garamond:ital,wght@0,400;0,500;1,400&display=swap');

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: #0b0908;
    color: #d8cdb8;
    font-family: 'EB Garamond', serif;
    font-size: 16px;
}

.wrap {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px;
}

.wrap.narrow {
    max-width: 420px;
}

.title {
    font-family: 'Cinzel', serif;
    font-size: 20px;
    letter-spacing: 3px;
    color: #c9a86a;
    margin-bottom: 16px;
}

h1, h2, h3 {
    font-family: 'Cinzel', serif;
    color: #eee0c0;
    letter-spacing: 1px;
}

h1 { font-size: 22px; }
h2 { font-size: 18px; margin-top: 0; }
h3 { font-size: 14px; color: #a89a7c; text-transform: uppercase; letter-spacing: 2px; }

a { color: #c9a86a; }

/* ---- Forms (register, login, character creation) ---- */

form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 14px;
    color: #a89a7c;
}

input[type="text"], input[type="email"], input[type="password"] {
    background: #17130f;
    border: 1px solid #4a3c28;
    border-radius: 3px;
    padding: 10px 12px;
    color: #eee0c0;
    font-family: 'EB Garamond', serif;
    font-size: 15px;
}

button {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    letter-spacing: 1px;
    color: #d8cdb8;
    background: #1e1812;
    border: 1px solid #6b2e26;
    border-radius: 3px;
    padding: 12px 16px;
    cursor: pointer;
}

button:hover {
    background: #2a2018;
    border-color: #8a3c30;
}

fieldset {
    border: 1px solid #3a2f22;
    border-radius: 4px;
    padding: 14px;
}

legend {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    color: #a89a7c;
    padding: 0 8px;
}

.class-option {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: #d8cdb8;
}

/* ---- Messages ---- */

.error {
    background: #2a1512;
    border: 1px solid #6b2e26;
    color: #e0b0a8;
    padding: 12px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.flash {
    background: #1a2015;
    border: 1px solid #4a5a2e;
    color: #c4d8a8;
    padding: 12px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}

.outcome-banner {
    text-align: center;
    font-family: 'Cinzel', serif;
    font-size: 18px;
    letter-spacing: 2px;
    padding: 16px;
}

.fight-log {
    background: #100c09;
    border: 1px solid #2a2218;
    border-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
}

/* ---- Game screen (matches mockup_main_screen.html) ---- */

.frame {
    max-width: 900px;
    margin: 0 auto;
    background: #14100d;
    border: 1px solid #3a2f22;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

.frame .topbar {
    padding: 10px 20px;
    background: linear-gradient(180deg,#1c1712,#120e0a);
    border-bottom: 1px solid #3a2f22;
    margin-bottom: 0;
}

.player-tag {
    font-size: 14px;
    color: #a89a7c;
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-tag b { color: #d8cdb8; }

.layout {
    display: grid;
    grid-template-columns: 1fr 240px;
}

.main-col { min-width: 0; }

.scene-wrap {
    position: relative;
}

.scene-img {
    width: 100%;
    height: 320px;
    object-fit: cover;
    display: block;
    filter: saturate(0.9);
}

.scene-fade {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 90px;
    background: linear-gradient(180deg, rgba(20,16,13,0), #14100d);
}

.room-name {
    position: absolute;
    left: 20px; bottom: 14px;
    font-family: 'Cinzel', serif;
    font-size: 22px;
    letter-spacing: 1px;
    color: #eee0c0;
    text-shadow: 0 2px 6px rgba(0,0,0,0.8);
}

.room-name-plain {
    padding: 16px 20px 0;
    margin: 0;
}

.log {
    padding: 16px 20px;
    font-size: 16px;
    line-height: 1.7;
    color: #d8cdb8;
    max-height: 220px;
    overflow-y: auto;
    border-bottom: 1px solid #2a2218;
}

.log .sys { margin-bottom: 10px; }
.log .sys:last-child { margin-bottom: 0; }
.log .enc { color: #e0b0a8; }

.room-actions {
    padding: 14px 20px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.inline-form {
    display: contents;
}

.gated-form {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.gated-form input[type="text"] {
    padding: 7px 10px;
    font-size: 14px;
    min-width: 160px;
}

.actbtn {
    font-family: 'EB Garamond', serif;
    font-size: 14px;
    color: #d8cdb8;
    background: #1e1812;
    border: 1px solid #4a3c28;
    border-radius: 3px;
    padding: 7px 14px;
    cursor: pointer;
    display: inline-block;
}

.actbtn:hover { background: #2a2018; border-color: #6b4e26; }
.actbtn.attack { border-color: #6b2e26; color: #e0b0a8; }
.actbtn.locked { border-color: #4a3c28; color: #8a4a3f; cursor: default; }
.actbtn.disabled { color: #6a5c48; cursor: default; }

.sidebar {
    border-left: 1px solid #2a2218;
    background: #100c09;
    padding: 18px 16px;
}

.charname {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    color: #eee0c0;
    margin-bottom: 2px;
}

.classline {
    font-size: 13px;
    color: #8a7a5c;
    margin-bottom: 14px;
}

.portrait-wrap {
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #4a3c28;
    background: #1a1510;
    margin-bottom: 14px;
}

.portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
}

.stat-row {
    margin-bottom: 10px;
}

.bar-fill.xp { background: #7c6a2b; }
.bar-fill.mana { background: #3a5fa8; }

.fight-status {
    margin: 6px 0;
    font-size: 13px;
    color: #a89a7a;
}

.actions.abilities {
    flex-wrap: wrap;
    margin-top: 8px;
}

.gold {
    margin-top: 16px;
    font-size: 14px;
    color: #cdae6a;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #2a2218;
    padding-top: 12px;
}

@media (max-width: 720px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar { border-left: none; border-top: 1px solid #2a2218; }
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #3a2f22;
}

.logout-link {
    font-size: 13px;
    color: #8a7a5c;
    text-decoration: none;
}

.actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
}

.actions button {
    width: 100%;
}

.actions button.attack {
    border-color: #6b2e26;
    color: #e0b0a8;
}

.actions button.flee {
    border-color: #4a3c28;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #a89a7c;
    margin: 6px 0 4px;
}

.room-image {
    display: block;
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #2a2218;
    animation: room-image-fade-in 0.5s ease;
}

@keyframes room-image-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.bar {
    height: 9px;
    background: #221c15;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #382d1f;
    margin-bottom: 8px;
}

.bar-fill {
    height: 100%;
    background: #3c8a4a; /* green: healthy, above 50% */
}

.bar-fill.hp-mid { background: #c9a03a; } /* yellow: 25-50% */
.bar-fill.hp-low { background: #a8362c; } /* red: below 25% */

.room-panel {
    background: #100c09;
    border: 1px solid #2a2218;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 10px;
}

.room-panel p {
    margin: 0 0 8px;
    line-height: 1.5;
}

.room-panel p:last-child {
    margin-bottom: 0;
}

.room-exits-text {
    color: #a89a7c;
    font-size: 14px;
}

.room-flavor {
    font-size: 17px;
}

.exits-panel {
    margin-bottom: 10px;
}

.exit-form {
    display: block;
    flex-direction: row;
    margin-bottom: 8px;
}

.exit-form button {
    width: 100%;
    text-align: left;
}

.exit-form input[type="text"] {
    width: 100%;
    margin: 6px 0;
}

.locked {
    display: block;
    font-size: 13px;
    color: #8a4a3f;
    margin-bottom: 4px;
}

/* ---- Direction compass + stairs + character panel (TODO-009 redesign) ---- */

.stage-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.compass-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.compass-rose {
    position: relative;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    border: 1px solid #4a3c28;
    background: radial-gradient(circle, #17130f 0%, #100c09 100%);
    flex-shrink: 0;
}

.compass-letter {
    position: absolute;
    font-family: 'Cinzel', serif;
    font-size: 12px;
    color: #a89a7c;
}

.compass-letter.n { top: 6px; left: 50%; transform: translateX(-50%); }
.compass-letter.s { bottom: 6px; left: 50%; transform: translateX(-50%); }
.compass-letter.e { right: 8px; top: 50%; transform: translateY(-50%); }
.compass-letter.w { left: 8px; top: 50%; transform: translateY(-50%); }

.compass-needle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2px;
    height: 38px;
    background: linear-gradient(180deg, #cdae6a, transparent);
    transform-origin: bottom center;
    margin-left: -1px;
    margin-top: -38px;
}

.nav-stairs-group {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: center;
    min-height: 110px;
}

.explore-form {
    margin-bottom: 0;
    flex-shrink: 0;
}

.explore-btn {
    width: auto;
    padding: 8px 16px;
    border-color: #6b2e26;
    color: #e0b0a8;
    font-size: 12px;
}

.side-panel {
    flex: 1;
    min-width: 240px;
    min-height: 110px;
    display: flex;
    gap: 14px;
    background: #14100d;
    border: 1px solid #3a2f22;
    border-radius: 4px;
    padding: 12px 16px;
}

.side-panel-portrait {
    width: 90px;
    object-fit: cover;
    object-position: top;
    border-radius: 4px;
    border: 1px solid #4a3c28;
    background: #1a1510;
    flex-shrink: 0;
}

.side-panel-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.side-panel-name {
    font-family: 'Cinzel', serif;
    font-size: 15px;
    color: #eee0c0;
    margin-bottom: 4px;
}

.side-panel-gold {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #2a2218;
    font-size: 13px;
    color: #cdae6a;
}

.bar-fill.pvp { background: #7c4a2b; }

@media (max-width: 640px) {
    .side-panel { flex-basis: 100%; }
}

/* ---- Combat cards (matches approved_combat_screen.png) ---- */

.battle-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #100c09;
    border: 1px solid #3a2f22;
    border-radius: 4px;
    padding: 14px 16px;
    margin-bottom: 16px;
}

.battle-card.enemy {
    border-color: #5a2a24;
}

.battle-card-portrait {
    width: 90px;
    height: 90px;
    object-fit: cover;
    object-position: top;
    border-radius: 4px;
    border: 1px solid #4a3c28;
    background: #1a1510;
    flex-shrink: 0;
}

.battle-card.enemy .battle-card-portrait {
    border-color: #5a2a24;
}

.battle-card-portrait-wrap {
    position: relative;
    flex-shrink: 0;
    display: inline-block;
}

.death-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.battle-card-info {
    flex: 1;
    min-width: 0;
}

.battle-card-name {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    color: #eee0c0;
    margin-bottom: 8px;
}

.battle-card.enemy .battle-card-name {
    color: #e0b0a8;
}

.battle-vs {
    text-align: center;
    font-family: 'Cinzel', serif;
    letter-spacing: 3px;
    font-size: 13px;
    color: #6a5c48;
    margin: -8px 0 16px;
}

.compass-pad {
    display: grid;
    grid-template-columns: 32px 32px 32px;
    grid-template-rows: 32px 32px 32px;
    gap: 3px;
    flex-shrink: 0;
}

.compass-slot form,
.stairs-slot form {
    margin: 0;
    display: contents;
}

.compass-slot,
.stairs-slot {
    display: flex;
}

.slot-forward  { grid-column: 2; grid-row: 1; }
.slot-left     { grid-column: 1; grid-row: 2; }
.slot-right    { grid-column: 3; grid-row: 2; }
.slot-backward { grid-column: 2; grid-row: 3; }

.stairs-pad {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex-shrink: 0;
}

.nav-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.nav-btn.locked {
    font-size: 11px;
    border-color: #4a3c28;
    color: #8a4a3f;
}

.nav-btn.disabled {
    border-color: #241d16;
    color: #4a4038;
    background: #14100d;
    cursor: default;
    opacity: 0.5;
}

.riddle-form {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.riddle-form input[type="text"] {
    flex: 1;
    padding: 6px 8px;
}

.facing-indicator {
    font-size: 13px;
    color: #a89a7c;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.facing-indicator strong {
    color: #cdae6a;
}

/* --- TEMPORARY DEBUG: remove once nav bug is confirmed fixed --- */
.nav-debug-id {
    display: block;
    font-size: 9px;
    opacity: 0.7;
    margin-top: 1px;
}

h2 .nav-debug-id {
    display: inline;
    font-size: 12px;
    margin-left: 8px;
}