/* style.css */
:root {
    --bg-dark: #0f0f12;
    --panel-bg: rgba(20, 20, 25, 0.9);
    --gold: #d4af37;
    --red: #8b0000;
    --text-main: #e0e0e0;
    --text-muted: #888;
}

body {
    margin: 0;
    padding: 0;
    background: radial-gradient(circle at center, #1a1a24 0%, var(--bg-dark) 100%);
    color: var(--text-main);
    font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
    font-weight: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* CRT Scanline overlay */
body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 2;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid rgba(212, 175, 55, 0.5);
    margin-bottom: 15px;
    padding-bottom: 5px;
}

.section-header h2 {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.header-links {
    display: flex;
    gap: 15px;
    align-items: center;
}

.header-link {
    color: var(--gold);
    text-decoration: underline;
    font-size: 0.9em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: color 0.2s ease, filter 0.2s ease;
}

.header-link:hover {
    color: #fff;
    filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.8));
}

.header-link-separator {
    color: rgba(212, 175, 55, 0.5);
    font-size: 0.9em;
}

#game-container {
    display: flex;
    width: 97vw;
    height: 98vh;
    border: 1px solid var(--gold);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.2), inset 0 0 20px rgba(212, 175, 55, 0.05);
    border-radius: 8px;
    overflow: hidden;
    z-index: 1;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(10px);
}

#left-panel {
    flex: 1.2;
    background: linear-gradient(135deg, rgba(5,5,5,0.9) 0%, rgba(15,15,20,0.9) 100%);
    position: relative;
    border-right: 1px solid rgba(212, 175, 55, 0.5);
    display: flex;
    flex-direction: column;
}

#map-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

#roman-map {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    transition: opacity 0.5s ease;
}

#spqr-emblem {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 180px;
    opacity: 0.9;
    filter: drop-shadow(0 0 10px rgba(0,0,0,0.8));
}

#event-illustration-container {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    z-index: 10;
}

#event-illustration-container.visible {
    opacity: 1;
    pointer-events: auto;
}

#event-illustration-img {
    max-width: 90%;
    max-height: 90%;
    border: 2px solid var(--gold);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
    border-radius: 5px;
    object-fit: contain;
}

#right-panel {
    flex: 1;
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
}

.panel-section {
    margin-bottom: 14px;
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 6px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    transition: border-color 0.3s ease;
}

.panel-section:hover {
    border-color: rgba(212, 175, 55, 0.4);
}

h2, h3 {
    color: var(--gold);
    margin-top: 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.5);
    padding-bottom: 5px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 2px;
}

#stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
    font-size: 0.9em;
}

/* Wide screens: three stat columns — a shorter sheet buys the narrative
   stream another hand's-breadth of scroll. */
@media (min-width: 821px) {
    #stats-grid {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 6px 16px;
        font-size: 0.85em;
    }
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 1px 0;
    border-bottom: 1px dotted #333;
}

.section-header h2 {
    font-size: 1.05em;
}

#options-panel h3 {
    font-size: 0.95em;
    margin-bottom: 8px;
    padding-bottom: 3px;
}

.stat-name {
    color: var(--gold);
}

.stat-value {
    font-weight: bold;
    color: #fff;
}

.stat-value.danger {
    color: var(--red);
}

#text-readout {
    /* Automatic fill: flex-basis 0 hands the stream exactly the leftover
       space, however much the viewport offers — no cap, no guesswork. */
    flex: 1 1 0;
    min-height: 160px;
    overflow-y: auto;
    font-size: 0.9em;
    line-height: 1.35;
    border: 1px inset rgba(212, 175, 55, 0.2);
    padding: 15px;
    background: #080808;
    color: #ccc;
}

.log-entry {
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(212, 175, 55, 0.1);
    padding-bottom: 6px;
    animation: fadeInSlideUp 0.4s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes fadeInSlideUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.log-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.log-good { color: #4ade80; }
.log-bad { color: #f87171; }
.log-neutral { color: #a1a1aa; }

/* Automatic stat-change readout line */
.log-delta {
    font-size: 0.88em;
    letter-spacing: 1px;
    padding-left: 12px;
    border-left: 2px solid rgba(212, 175, 55, 0.4);
}

.delta-good { color: #4ade80; font-weight: bold; }
.delta-bad { color: #f87171; font-weight: bold; }
.delta-warn { color: var(--gold); font-weight: bold; }

/* Rival dossier: replaces the message log while open.
   No max-height — with only two options on screen, the dossier
   takes every line of space the flex column can give it. */
#dossier-panel {
    flex-grow: 1;
    min-height: 120px;
    overflow-y: auto;
    font-size: 0.92em;
    line-height: 1.45;
}

.dossier-name {
    color: var(--gold);
    font-weight: bold;
    font-size: 1.15em;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.dossier-epithet {
    color: #fff;
    font-style: italic;
    margin-bottom: 6px;
}

.dossier-tags {
    color: var(--text-muted);
    font-size: 0.85em;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.dossier-trait {
    color: #f87171;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.dossier-trait span { font-weight: bold; }

.dossier-bio {
    color: #ccc;
    margin: 0 0 10px 0;
}

.dossier-historia {
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-left: 3px solid var(--gold);
    background: rgba(212, 175, 55, 0.05);
    padding: 8px 10px;
    margin-bottom: 10px;
}

.historia-label {
    color: var(--gold);
    font-size: 0.75em;
    letter-spacing: 3px;
    margin-bottom: 4px;
}

.dossier-historia p { margin: 0; color: #e0e0e0; }

.dossier-stats {
    color: var(--text-muted);
    font-size: 0.85em;
    border-top: 1px dotted #333;
    padding-top: 6px;
}

/* Intro screen: the map seen once, as a title card (mobile only, via JS) */
#intro-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background:
        linear-gradient(rgba(10, 10, 15, 0.55), rgba(10, 10, 15, 0.85)),
        url("assets/roman_map_49bce.png") center / cover no-repeat;
    cursor: pointer;
}

#intro-emblem {
    width: 140px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 12px rgba(0, 0, 0, 0.9));
}

#intro-screen h1 {
    color: var(--gold);
    letter-spacing: 6px;
    font-size: 1.8em;
    margin: 0 0 10px 0;
    text-shadow: 0 0 14px rgba(0, 0, 0, 0.9);
}

.intro-tagline {
    color: #e0e0e0;
    font-style: italic;
    margin: 0 0 40px 0;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
}

.intro-prompt {
    color: var(--gold);
    font-weight: bold;
    letter-spacing: 3px;
    animation: introPulse 1.6s ease-in-out infinite;
}

@keyframes introPulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

/* --- Mobile: no split screen. The map was the title card; the right panel
   is the game; event images take the whole screen until their timer or a tap. --- */
@media (max-width: 820px) {
    body {
        height: 100dvh;
        align-items: stretch;
    }

    #game-container {
        width: 100vw;
        height: 100dvh;
        border: none;
        border-radius: 0;
    }

    /* The left panel collapses to nothing but stays rendered, so its
       fixed-position child (the illustration overlay) can still appear.
       display:none here would silently kill portraits and event art. */
    #left-panel {
        display: block;
        flex: none;
        width: 0;
        height: 0;
        min-width: 0;
        border: none;
        overflow: visible;
    }

    #map-wrapper {
        display: none;
    }

    #event-illustration-container {
        position: fixed;
        inset: 0;
        z-index: 50;
        background: rgba(0, 0, 0, 0.94);
    }

    #right-panel {
        flex: 1;
        padding: 12px;
    }

    #stats-grid {
        font-size: 0.82em;
        gap: 5px 12px;
    }

    /* Phones keep a cap so the stream cannot shove the buttons off-screen. */
    #text-readout {
        max-height: 300px;
    }

    /* Phones get a single column: half-width buttons are too cramped at 375px. */
    #options-list {
        grid-template-columns: 1fr;
    }

    #options-list li {
        padding: 11px 8px;
    }

    .key-hint {
        padding: 5px 11px;
    }

    #dossier-panel {
        max-height: none;
    }
}

#current-event {
    color: #fff;
    font-size: 1.05em;
    min-height: 44px;
    border-left: 3px solid var(--gold);
    padding-left: 15px;
    line-height: 1.4;
}

#options-list {
    list-style: none;
    padding: 0;
    margin: 0;
    /* Two columns of same-size buttons: more room for the message stream above. */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}

#options-list li {
    margin-bottom: 0;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 6px 5px;
    border-radius: 4px;
    border: 1px solid rgba(212, 175, 55, 0.15);
    background: rgba(0, 0, 0, 0.25);
}

#options-list li:hover {
    color: #fff;
    background: rgba(212, 175, 55, 0.1);
    border-color: rgba(212, 175, 55, 0.4);
    text-shadow: 0 0 8px rgba(212, 175, 55, 0.4);
}

#options-list li:hover .key-hint {
    background: var(--gold);
    color: #000;
    box-shadow: 0 0 10px var(--gold);
}

.key-hint {
    color: var(--gold);
    font-weight: bold;
    margin-right: 8px;
    background: #111;
    padding: 2px 7px;
    border-radius: 3px;
    border: 1px solid var(--gold);
    transition: all 0.3s ease;
}

#tribute-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85em;
    font-style: italic;
    margin-top: auto;
    padding-top: 20px;
}
