/* ============================================
   LATAM President Simulator
   Monkey Island / Retro Adventure Style
   ============================================ */

:root {
    --bg: #000020;
    --text: #ffffff;
    --text-dim: #8888aa;
    --highlight: #ffff54;
    --dialog-bg: #000000;
    --dialog-border: #8888aa;
    --red: #cc2222;
    --green: #22cc22;
    --gold: #ccaa22;
    --blue: #5555ff;
    --danger: #ff4444;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Press Start 2P', monospace;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 10px;
    line-height: 1.8;
    image-rendering: pixelated;
}

/* CRT Overlay */
.crt-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.08) 0px,
        rgba(0, 0, 0, 0.08) 1px,
        transparent 1px,
        transparent 3px
    );
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    justify-content: center;
    align-items: center;
}
.screen.active { display: flex; }

/* === CANVAS === */
.scene-canvas {
    width: 100%;
    max-width: 640px;
    aspect-ratio: 320 / 200;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border: 2px solid var(--dialog-border);
    display: block;
}
.title-canvas {
    border: none;
}

/* === TITLE SCREEN === */
.title-screen {
    position: relative;
    max-width: 640px;
    width: 100%;
}
.title-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
}
.title-blink {
    font-size: 7px;
    color: var(--highlight);
    margin-bottom: 12px;
    animation: pulse 2s ease infinite;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.title-text {
    font-size: clamp(20px, 5vw, 36px);
    line-height: 1.4;
    text-shadow: 3px 3px 0 #000, -1px -1px 0 #000;
    margin-bottom: 24px;
    color: var(--text);
}
.title-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.title-footnote {
    position: absolute;
    bottom: 10px;
    font-size: 6px;
    color: var(--text-dim);
}
.title-footnote .blink {
    color: var(--highlight);
    animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* === MENU OPTIONS === */
.menu-option {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--text-dim);
    padding: 8px 16px;
    cursor: pointer;
    transition: color 0.1s;
    text-transform: uppercase;
    background: none;
    border: none;
    text-align: left;
}
.menu-option:hover {
    color: var(--highlight);
}
.back-btn {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 100;
    font-size: 8px;
}

/* === RETRO CONTAINER === */
.retro-container {
    max-width: 640px;
    width: 100%;
    padding: 16px;
}

/* === DIALOG BOX (Monkey Island style) === */
.dialog-box {
    background: var(--dialog-bg);
    border: 2px solid var(--dialog-border);
    padding: 16px;
    margin: 0 auto;
    max-width: 640px;
    width: 100%;
}
.dialog-title {
    font-size: 12px;
    color: var(--highlight);
    margin-bottom: 8px;
    text-align: center;
}
.dialog-sub {
    font-size: 8px;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 16px;
}

/* === COUNTRY SELECT === */
.select-dialog {
    max-height: 85vh;
    overflow-y: auto;
}
.countries-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.country-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 8px;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.1s;
    border-bottom: 1px solid #111;
}
.country-option:last-child { border-bottom: none; }
.country-option:hover {
    color: var(--highlight);
    background: #111122;
}
.country-option .co-arrow {
    color: var(--highlight);
    flex-shrink: 0;
    margin-top: 2px;
}
.country-option .co-flag {
    font-size: 16px;
    flex-shrink: 0;
}
.country-option .co-info {
    flex: 1;
}
.country-option .co-name {
    font-size: 10px;
    color: var(--text);
    margin-bottom: 4px;
}
.country-option:hover .co-name { color: var(--highlight); }
.country-option .co-desc {
    font-size: 7px;
    line-height: 1.6;
    color: var(--text-dim);
}

/* === NAME INPUT === */
.name-dialog {
    text-align: center;
}
.country-badge-retro {
    font-size: 24px;
    margin-bottom: 12px;
}
.retro-input {
    width: 100%;
    max-width: 400px;
    padding: 10px 12px;
    background: #0a0a1a;
    border: 2px solid var(--dialog-border);
    border-bottom: 3px solid var(--highlight);
    color: var(--highlight);
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    text-align: center;
    outline: none;
    margin: 12px auto;
    display: block;
    text-transform: uppercase;
}
.retro-input::placeholder {
    color: #333355;
}
.retro-input:focus {
    border-color: var(--highlight);
}
.start-btn {
    text-align: center;
    margin: 12px auto;
    font-size: 10px;
}
.tip-text {
    font-size: 6px;
    color: #444466;
    margin-top: 12px;
    font-style: italic;
}

/* === GAME LAYOUT === */
.game-layout {
    max-width: 640px;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 8px;
}

/* Scene wrapper */
.scene-wrapper {
    position: relative;
    width: 100%;
    flex-shrink: 0;
}

/* Scene header */
.scene-header {
    position: absolute;
    top: 6px;
    left: 8px;
    font-size: 7px;
    color: var(--text);
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    z-index: 5;
}
.scene-sep { color: var(--text-dim); margin: 0 4px; }
.highlight { color: var(--highlight); }

/* HUD Overlay */
.hud-overlay {
    position: absolute;
    top: 6px;
    right: 8px;
    background: rgba(0, 0, 0, 0.75);
    padding: 6px 8px;
    border: 1px solid #333;
    z-index: 5;
    min-width: 120px;
}
.hud-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
    font-size: 7px;
}
.hud-label {
    width: 24px;
    color: var(--text-dim);
    font-size: 6px;
}
.hud-bar {
    flex: 1;
    height: 4px;
    background: #222;
    position: relative;
    min-width: 50px;
}
.hud-bar-fill {
    height: 100%;
    transition: width 0.8s ease;
    position: absolute;
    left: 0;
    top: 0;
}
.hud-bar-fill.high { background: var(--green); }
.hud-bar-fill.mid { background: var(--gold); }
.hud-bar-fill.low { background: var(--red); }
.hud-bar-fill.critical { background: var(--danger); animation: flash 0.5s infinite; }

@keyframes flash {
    50% { opacity: 0.3; }
}

.hud-val {
    width: 22px;
    text-align: right;
    font-size: 7px;
    color: var(--text);
}
.hud-info {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 3px;
    border-top: 1px solid #333;
    font-size: 7px;
}
.hud-gold { color: var(--gold); }
.hud-date { color: var(--text-dim); }

/* Stat change floating */
.stat-float {
    position: fixed;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    pointer-events: none;
    animation: floatUp 1.5s ease-out forwards;
    z-index: 50;
    text-shadow: 2px 2px 0 #000;
}
.stat-float.pos { color: var(--green); }
.stat-float.neg { color: var(--red); }

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-30px); }
}

/* === GAME DIALOG BOX === */
.game-dialog {
    flex: 1;
    overflow-y: auto;
    margin-top: 0;
    border-top: none;
    min-height: 80px;
    max-height: 180px;
    position: relative;
}
.consequence-text {
    display: none;
    font-size: 8px;
    color: var(--text-dim);
    padding: 8px;
    margin-bottom: 6px;
    border-left: 2px solid var(--gold);
    background: #0a0a15;
    line-height: 2;
}
.consequence-text.visible { display: block; }

.narrative-text {
    font-size: 9px;
    line-height: 2;
    color: var(--text);
    padding: 4px 0;
    white-space: pre-wrap;
}

.continue-prompt {
    text-align: center;
    font-size: 8px;
    color: var(--highlight);
    cursor: pointer;
    padding: 6px;
    animation: pulse 1.5s ease infinite;
}
.continue-prompt.hidden { display: none; }

/* Typing cursor */
.typing-cursor {
    display: inline-block;
    width: 8px;
    height: 10px;
    background: var(--highlight);
    animation: blink-cursor 0.6s step-end infinite;
    vertical-align: text-bottom;
    margin-left: 1px;
}
@keyframes blink-cursor { 50% { opacity: 0; } }

/* === OPTIONS (dialog choices) === */
.options-area {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 2px solid var(--dialog-border);
    border-top: none;
    background: var(--dialog-bg);
    flex-shrink: 0;
}
.option-choice {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.1s;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    line-height: 1.8;
    border: none;
    background: none;
    text-align: left;
    width: 100%;
    border-bottom: 1px solid #111;
}
.option-choice:last-child { border-bottom: none; }
.option-choice:hover {
    color: var(--highlight);
    background: #111122;
}
.option-choice .opt-key {
    color: var(--highlight);
    flex-shrink: 0;
    font-size: 9px;
}
.option-choice .opt-content {
    flex: 1;
}
.option-choice .opt-preview {
    display: block;
    font-size: 6px;
    color: #555577;
    margin-top: 2px;
}
.option-choice:hover .opt-preview { color: #8888aa; }

/* === LOADING === */
.loading-box {
    text-align: center;
    padding: 16px;
    font-size: 8px;
    color: var(--text-dim);
    border: 2px solid var(--dialog-border);
    border-top: none;
    background: var(--dialog-bg);
}
.loading-box.hidden { display: none; }

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4) infinite;
}
@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* === GAME OVER === */
.gameover-scene .scene-canvas {
    border-bottom: none;
}
.gameover-dialog {
    text-align: center;
    border-top: none;
}
.gameover-icon {
    font-size: 32px;
    margin-bottom: 8px;
}
.gameover-title {
    font-size: 14px;
    margin-bottom: 12px;
}
.gameover-narrative {
    text-align: left;
    font-size: 8px;
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid #222;
    background: #0a0a15;
}
.gameover-scores {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 10px;
    margin-bottom: 12px;
}
.gameover-final-stats {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
    font-size: 7px;
    color: var(--text-dim);
}
.gameover-final-stat {
    padding: 4px 8px;
    border: 1px solid #222;
}

/* === LEADERBOARD === */
.leaderboard-dialog {
    max-height: 80vh;
    overflow-y: auto;
}
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.lb-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    border-bottom: 1px solid #111;
    font-size: 7px;
}
.lb-rank {
    width: 24px;
    text-align: center;
    color: var(--text-dim);
}
.lb-rank.gold { color: #ffcc00; }
.lb-rank.silver { color: #aaaacc; }
.lb-rank.bronze { color: #cc8844; }
.lb-flag { font-size: 14px; }
.lb-info { flex: 1; }
.lb-name { color: var(--text); font-size: 8px; }
.lb-detail { color: var(--text-dim); font-size: 6px; margin-top: 2px; }
.lb-score { color: var(--highlight); font-size: 10px; }
.lb-empty {
    text-align: center;
    padding: 24px;
    font-size: 8px;
    color: var(--text-dim);
    line-height: 2;
}

/* === SOUND TOGGLE === */
.sound-toggle {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-dim);
    border: 1px solid #333;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    padding: 6px 10px;
    cursor: pointer;
    z-index: 100;
}
.sound-toggle:hover { color: var(--highlight); border-color: var(--highlight); }
.sound-toggle.on { color: var(--green); }

/* === RESPONSIVE === */
@media (min-width: 1920px) {
    .game-layout,
    .retro-container,
    .title-screen {
        max-width: 800px;
    }
    body { font-size: 11px; }
    .narrative-text { font-size: 10px; }
    .game-dialog { max-height: 220px; }
}

@media (max-width: 768px) {
    .screen { padding: 0; }
    .game-layout { padding: 4px; }
    .hud-overlay {
        min-width: 90px;
        padding: 4px 6px;
    }
    .hud-bar { min-width: 30px; }
    .hud-label { font-size: 5px; }
    .hud-val { font-size: 6px; }
    .hud-info { font-size: 6px; }
    .dialog-title { font-size: 10px; }
    .narrative-text { font-size: 8px; }
    .option-choice { padding: 10px 12px; font-size: 8px; }
    .game-dialog { max-height: 150px; }
    .title-text { font-size: 20px; }
    .back-btn { font-size: 7px; top: 8px; left: 8px; }
    .retro-container { padding: 8px; }
}

@media (max-width: 480px) {
    .gameover-scores { flex-direction: column; gap: 4px; font-size: 9px; }
    .title-text { font-size: 16px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #000; }
::-webkit-scrollbar-thumb { background: #333; }
::-webkit-scrollbar-thumb:hover { background: #555; }
