:root {
    --bg-color: #1a1a2e;
    --panel-bg: #16213e;
    --accent-gold: #f1c40f;
    --accent-red: #e74c3c;
    --accent-green: #2ecc71;
    --text-main: #ecf0f1;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    user-select: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* --- Character Selection --- */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.char-card {
    background: var(--panel-bg);
    border: 2px solid #34495e;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.char-card.locked {
    opacity: 0.7;
    filter: grayscale(0.8);
    cursor: not-allowed;
    border-style: dashed;
    border-color: #555;
}

.char-lock-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5;
    text-align: center;
}

.char-card:hover:not(.locked) {
    transform: translateY(-5px);
    border-color: var(--accent-gold);
    box-shadow: 0 5px 15px rgba(241, 196, 15, 0.2);
}

.char-card.selected {
    border-color: var(--accent-gold);
    background: #2c3e50;
}

.char-icon { font-size: 3rem; margin-bottom: 10px; }
.skill-tag { background: #e67e22; color: white; padding: 2px 8px; border-radius: 4px; font-size: 0.8em; }

/* --- Game Dashboard Layout --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 250px 1fr 280px; /* Left Center Right */
    gap: 20px;
    height: calc(100vh - 60px);
}

/* Left Panel: Stats */
.stats-panel {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stat-item label { display: block; color: #95a5a6; font-size: 0.9em; margin-bottom: 5px; }
.stat-value { font-size: 1.8em; font-weight: bold; }
.progress-bar-bg { background: #333; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 5px; }
.progress-bar-fill { height: 100%; transition: width 0.5s; }

/* Center: Desk */
.desk-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.event-banner {
    background: #c0392b;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    animation: fadeInDown 0.5s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cards-area {
    flex-grow: 1;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-content: flex-start;
}

.game-card {
    width: 200px;
    height: 280px;
    background: #ecf0f1;
    color: #2c3e50;
    border-radius: 10px;
    padding: 15px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    cursor: pointer;
}

.game-card:hover { transform: scale(1.05) rotate(1deg); z-index: 10; }
.card-type { font-size: 0.8em; text-transform: uppercase; letter-spacing: 1px; color: #7f8c8d; }
.card-title { font-size: 1.2em; font-weight: bold; margin: 10px 0; }
.card-desc { font-size: 0.9em; flex-grow: 1; }
.card-cost { 
    display: inline-block;
    background: #34495e;
    color: #ecf0f1;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: bold;
    margin-bottom: 5px;
}

/* Event Choices */
.event-choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.choice-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid #bdc3c7;
    color: white;
    padding: 8px;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
}
.choice-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: var(--accent-gold);
}

/* Positions Panel */
.positions-panel {
    margin-bottom: 15px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
}
.position-card {
    background: var(--panel-bg);
    border: 1px solid #34495e;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
}
.close-pos-btn {
    width: 100%;
    background: #e74c3c;
    border: none;
    color: white;
    padding: 5px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* Tutorial Overlay */
.tutorial-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 3000;
    pointer-events: none;
}
.tutorial-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #333;
    padding: 20px;
    border-radius: 10px;
    max-width: 300px;
    z-index: 3001;
    pointer-events: auto;
    box-shadow: 0 0 20px rgba(241, 196, 15, 0.5);
    text-align: left;
}
.tutorial-highlight {
    position: relative;
    z-index: 3002;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.7);
    border-radius: 8px;
}

/* Mobile Next Turn Button */
.mobile-next-turn-container {
    position: fixed;
    bottom: 60px;
    left: 0;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    background: linear-gradient(to top, var(--bg-color), transparent);
    z-index: 90;
    pointer-events: none;
}
.mobile-next-turn-container button {
    width: 100%;
    pointer-events: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* Mobile Stats Header */
.mobile-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8em;
}
.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}
.stat-label {
    font-size: 0.8em;
    color: #7f8c8d;
    transform: scale(0.9);
}
.stat-val {
    font-weight: bold;
    font-size: 1.1em;
}

/* Skill Modal */
.skill-modal-content {
    background: #fff;
    color: #333;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}
.skill-modal-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
.skill-modal-btn-group button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}
.btn-confirm { background: var(--accent-green); color: white; }
.btn-cancel { background: #95a5a6; color: white; }
.action-panel {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.market-trend { 
    font-size: 0.9em; padding: 5px 10px; border-radius: 4px; background: rgba(255,255,255,0.1); text-align: center;
}

.invest-btn {
    background: transparent;
    border: 1px solid #555;
    color: #fff;
    padding: 10px;
    width: 100%;
    cursor: pointer;
    border-radius: 6px;
    transition: 0.2s;
    text-align: left;
}
.invest-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); border-color: var(--accent-gold); }
.invest-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.skill-btn {
    background: linear-gradient(45deg, #f1c40f, #f39c12);
    color: #2c3e50;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 0 #d35400;
}
.skill-btn:active { transform: translateY(4px); box-shadow: none; }
.skill-btn:disabled { filter: grayscale(1); cursor: not-allowed; }

.next-turn-btn {
    margin-top: auto;
    background: var(--accent-green);
    border: none;
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.2em;
    cursor: pointer;
    font-weight: bold;
}

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}
.modal-content {
    background: #fff; color: #333;
    padding: 30px; border-radius: 10px;
    max-width: 500px; text-align: center;
    box-shadow: 0 0 30px rgba(241, 196, 15, 0.5);
}

/* Utils */
.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.log-area { 
    height: 150px; overflow-y: auto; background: rgba(0,0,0,0.2); 
    padding: 10px; border-radius: 6px; font-size: 0.85em; font-family: monospace;
    display: flex; flex-direction: column;
}

/* Base Mobile Layout */
@media (max-width: 900px) {
    html, body {
        height: 100%;
        overflow: hidden;
        padding: 0;
        margin: 0;
    }
    
    /* Remove padding from body specifically to ensure full width */
    body {
        padding: 0 !important;
    }

    #app {
        height: 100%;
        display: flex;
        flex-direction: column;
    }

    /* RESTORED: Critical Mobile Dashboard Layout layout */
    .dashboard-grid { 
        display: flex; 
        flex-direction: column; 
        height: 100%;
        gap: 0;
        overflow: hidden;
    }
    
    .stats-panel, .desk-area, .action-panel {
        flex: 1;
        overflow-y: auto;
        padding: 10px;
        padding-bottom: 70px; /* Space for bottom nav */
        box-sizing: border-box;
    }

    /* Phase 1 Scroller */
    #app > div:first-child {
        height: 100%;
        overflow-y: auto;
        padding: 20px 0; /* Vertical padding only */
        box-sizing: border-box;
    }

    /* Mobile Stats Header */
    .mobile-stats-header {
        position: sticky;
        top: 0;
        z-index: 100;
        width: 100%;
    }

    /* Mobile Nav */
    .mobile-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: var(--panel-bg);
        border-top: 1px solid #34495e;
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    }
    
    .mobile-nav button {
        background: transparent;
        border: none;
        color: #7f8c8d;
        font-size: 1em;
        font-weight: bold;
        padding: 10px;
        flex: 1;
        height: 100%;
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .mobile-nav button.active {
        color: var(--accent-gold);
        background: rgba(241, 196, 15, 0.1);
        border-top: 3px solid var(--accent-gold);
    }
    
    .cards-area {
        justify-content: center;
    }
    
    .game-card {
        width: 100%;
        max-width: 320px;
        margin-bottom: 10px;
    }
}

/* Discard Button (Global) */
.discard-btn {
    position: static;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0,0,0,0.3);
    padding: 2px 6px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
    font-size: 0.8em;
}
.discard-btn:hover {
    background: rgba(231, 76, 60, 0.8);
}

/* Mobile Stats Header */
.mobile-stats-header {
    background: var(--panel-bg);
    padding: 10px;
    border-bottom: 1px solid #34495e;
    position: sticky;
    top: 0;
    z-index: 100;
}

.mobile-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 0.9em;
}

.ap-dots {
    display: flex;
    gap: 3px;
}
.ap-dots div {
    width: 10px; height: 10px; border-radius: 50%;
}

.mobile-log-bar {
    margin-top: 8px;
    background: rgba(0,0,0,0.3);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    color: #bdc3c7;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.log-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 90%;
}

.mobile-log-content {
    background: rgba(0,0,0,0.9);
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border-bottom: 1px solid #e67e22;
    font-size: 0.85em;
    max-height: 200px;
    overflow-y: auto;
    z-index: 101;
}

/* Action Grid */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}
.action-grid .full-width {
    grid-column: span 2;
}

/* --- Feature Update: Mobile & Styles --- */

/* 1. Cost Indicators */
.cost-low { background: #27ae60 !important; }
.cost-med { background: #f39c12 !important; }
.cost-high { background: #c0392b !important; }

/* 2. Mobile Floating Button */
.mobile-floating-next {
    position: fixed;
    bottom: 70px; 
    left: 0;
    width: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    z-index: 900;
    pointer-events: none;
    display: flex;
    justify-content: center;
}
.mobile-floating-next button {
    pointer-events: auto;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.2);
    animation: pulse 2s infinite;
}

/* 3. Report Modal */
.report-modal {
    background: #2c3e50;
    color: white;
    padding: 25px;
    border-radius: 12px;
    width: 85%;
    max-width: 400px;
    border: 2px solid var(--accent-gold);
    box-shadow: 0 0 30px rgba(0,0,0,0.8);
}
.report-list {
    background: rgba(0,0,0,0.2);
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 20px;
}
.report-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed #555;
    font-size: 1.1em;
}
.report-item:last-child { border-bottom: none; }

.report-hint {
    background: rgba(241, 196, 15, 0.1);
    color: #f1c40f;
    padding: 15px;
    border-radius: 6px;
    font-size: 0.95em;
    line-height: 1.6;
}

.card-effect {
  margin-top: auto; /* Push to bottom */
  font-size: 0.85em;
  color: #333; /* Darker text for readability if bg is light */
  background: rgba(0, 0, 0, 0.1); /* Light grey bg */
  padding: 8px;
  border-radius: 4px;
  display: block;
}

/* Event Modal */
.event-modal-content {
    background: #2c3e50;
    color: white;
    border: 2px solid var(--accent-gold);
}

/* Mobile Tutorial Box */
@media screen and (max-width: 900px) {
    .tutorial-box {
        width: 85% !important;
        max-width: none !important;
        font-size: 1.1em;
        text-align: center;
        padding: 30px 20px !important;
    }
}


/* FIX: Game Cards (Vertical Grid) vs Character Cards (Horizontal Swipe) */
@media (max-width: 900px) {
    /* CHARACTER SELECTION: Horizontal Swipe (80vw width) */
    .char-grid {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 10px 20px 25px 20px;
        scroll-snap-type: x mandatory;
        gap: 15px;
        justify-content: flex-start;
        -webkit-overflow-scrolling: touch;
    }
    .char-card {
        flex: 0 0 80vw;
        width: 80vw;
        max-width: 350px;
        min-width: 0;
        scroll-snap-align: center;
        margin: 0;
    }
    .char-grid::after {
        content: '';
        flex: 0 0 20px;
        min-width: 20px;
    }

    /* GAME DESK: Vertical 2-Column Grid (No Swipe) */
    .cards-area {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important; /* 2 Columns */
        gap: 10px !important;
        padding: 10px 10px 100px 10px !important; /* Bottom padding for FAB */
        overflow-x: hidden !important; 
        overflow-y: visible !important;
    }
    
    .game-card {
        width: 100% !important; /* Full width of column */
        max-width: none !important;
        min-width: 0 !important;
        margin: 0 !important;
        height: auto !important; 
        min-height: 220px;
        font-size: 0.9em;
        flex: none !important; /* Disable flex sizing */
    }

    /* Remove spacer for grid */
    .cards-area::after {
        display: none !important;
    }
}


