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

body {
    font-family: 'Georgia', serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e8e8e8;
    min-height: 100vh;
    overflow-x: hidden;
}

#game-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Title Screen */
#title-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    text-align: center;
}

.game-title {
    font-size: 2.5em;
    margin-bottom: 20px;
    color: #d4af37;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
    font-size: 1.2em;
    margin-bottom: 40px;
    color: #b8b8b8;
    font-style: italic;
}

.btn-primary {
    padding: 15px 40px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #d4af37 0%, #aa8c2c 100%);
    color: #1a1a2e;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

#current-period {
    font-size: 1.3em;
    color: #d4af37;
}

/* Metrics */
.metrics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.metric {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.08);
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid #d4af37;
}

.metric-icon {
    font-size: 2em;
    margin-right: 12px;
    min-width: 50px;
    text-align: center;
}

.metric-info {
    flex: 1;
}

.metric-label {
    font-size: 0.85em;
    color: #b8b8b8;
    margin-bottom: 4px;
}

.metric-bar-container {
    height: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 4px;
}

.metric-bar {
    height: 100%;
    transition: width 0.8s ease, background-color 0.3s;
    border-radius: 10px;
}

.wealth-bar {
    background: linear-gradient(90deg, #d4af37 0%, #f4d03f 100%);
}

.treasury-bar {
    background: linear-gradient(90deg, #3498db 0%, #5dade2 100%);
}

.elite-bar {
    background: linear-gradient(90deg, #9b59b6 0%, #bb8fce 100%);
}

.anger-bar {
    background: linear-gradient(90deg, #e74c3c 0%, #ec7063 100%);
}

.metric-value {
    font-size: 0.9em;
    text-align: right;
    color: #e8e8e8;
    font-weight: bold;
}

/* Legacy Container */
.legacy-container {
    min-height: 40px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.legacy-container:empty {
    display: none;
}

.legacy-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    border-radius: 20px;
    font-size: 0.85em;
    animation: legacy-appear 0.5s ease;
}

@keyframes legacy-appear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Debug Section */
.debug-section {
    margin-bottom: 20px;
}

.debug-details {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
}

.debug-summary {
    cursor: pointer;
    font-size: 0.9em;
    color: #ff6b6b;
    font-weight: bold;
    list-style: none;
    padding: 5px;
    user-select: none;
}

.debug-summary::-webkit-details-marker {
    display: none;
}

.debug-summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

.debug-details[open] .debug-summary::before {
    transform: rotate(90deg);
}

.debug-content {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 0, 0, 0.2);
}

.debug-info {
    margin-bottom: 15px;
}

.debug-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.debug-label {
    font-size: 0.85em;
    color: #ff6b6b;
    font-weight: bold;
}

.debug-value {
    font-size: 0.85em;
    color: #e8e8e8;
    text-align: right;
}

.debug-events-details {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 0, 0, 0.2);
    border-radius: 6px;
    padding: 8px;
    margin-top: 10px;
}

.debug-events-summary {
    cursor: pointer;
    font-size: 0.85em;
    color: #ffaa00;
    font-weight: bold;
    list-style: none;
    padding: 5px;
    user-select: none;
}

.debug-events-summary::-webkit-details-marker {
    display: none;
}

.debug-events-summary::before {
    content: '▶ ';
    display: inline-block;
    transition: transform 0.2s;
}

.debug-events-details[open] .debug-events-summary::before {
    transform: rotate(90deg);
}

.debug-events-list {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.debug-event-item {
    padding: 8px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid #d4af37;
    border-radius: 4px;
    font-size: 0.8em;
}

.debug-event-id {
    color: #ffaa00;
    font-weight: bold;
    display: block;
    margin-bottom: 4px;
}

.debug-event-title {
    color: #e8e8e8;
    display: block;
}

.debug-event-tree {
    margin-top: 10px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-size: 0.75em;
    font-family: 'Courier New', monospace;
}

.debug-tree-stats {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.debug-tree-stats h4 {
    color: #d4af37;
    margin: 0 0 8px 0;
    font-size: 1.1em;
}

.debug-tree-stats p {
    margin: 4px 0;
    color: #e8e8e8;
}

.debug-tree-hint {
    color: #888;
    font-style: italic;
    font-size: 0.9em;
}

.debug-tree-stat-row {
    display: flex;
    justify-content: space-between;
    margin: 4px 0;
}

.debug-tree-stat-label {
    color: #aaa;
}

.debug-tree-stat-value {
    color: #d4af37;
    font-weight: bold;
}

.debug-tree-warning {
    background: rgba(255, 0, 0, 0.1);
    border-left: 3px solid #ff4444;
    padding: 8px;
    margin: 8px 0;
    border-radius: 4px;
}

.debug-tree-section {
    margin: 16px 0;
}

.debug-tree-section h5 {
    color: #d4af37;
    margin: 0 0 8px 0;
    font-size: 1em;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    padding-bottom: 4px;
}

.debug-tree-node {
    margin: 4px 0;
    padding: 4px 0;
    color: #e8e8e8;
    line-height: 1.6;
}

.debug-tree-node-id {
    color: #ffaa00;
    font-weight: bold;
}

.debug-tree-node-title {
    color: #e8e8e8;
}

.debug-tree-node-badge {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 6px;
    border-radius: 3px;
    font-size: 0.85em;
    background: rgba(255, 255, 255, 0.1);
}

.debug-tree-node-badge.dead-end {
    background: rgba(255, 100, 100, 0.2);
    color: #ff6666;
}

.debug-tree-node-badge.branching {
    background: rgba(100, 255, 100, 0.2);
    color: #66ff66;
}

.debug-tree-node-badge.orphaned {
    background: rgba(255, 165, 0, 0.2);
    color: #ffaa55;
}

/* Event Card */
.event-card {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(212, 175, 55, 0.3);
}

.event-title {
    font-size: 1.4em;
    margin-bottom: 15px;
    color: #d4af37;
}

.event-description {
    font-size: 1em;
    line-height: 1.6;
    margin-bottom: 20px;
    color: #e8e8e8;
}

/* Choices */
.choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-btn {
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(212, 175, 55, 0.4);
    border-radius: 8px;
    color: #e8e8e8;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.choice-btn:hover {
    background: rgba(212, 175, 55, 0.2);
    border-color: #d4af37;
    transform: translateX(4px);
}

.choice-btn:active {
    transform: translateX(2px);
}

.choice-text {
    margin-bottom: 8px;
    font-size: 1em;
}

.choice-effects {
    display: flex;
    gap: 12px;
    font-size: 0.9em;
    padding-top: 8px;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    margin-top: 8px;
}

/* Game Over Screen */
#gameover-screen {
    text-align: center;
    padding: 40px 20px;
}

.gameover-reason {
    font-size: 1.2em;
    margin: 30px 0;
    padding: 20px;
    background: rgba(231, 76, 60, 0.2);
    border: 2px solid #e74c3c;
    border-radius: 8px;
}

.final-stats {
    margin: 30px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    text-align: left;
}

.stat-line {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
}

.final-legacy {
    margin: 30px 0;
    padding: 20px;
    background: rgba(212, 175, 55, 0.1);
    border-radius: 8px;
}

/* Special Effects */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s;
}

/* Mobile Optimization */
@media (max-width: 480px) {
    .game-title {
        font-size: 2em;
    }

    .event-title {
        font-size: 1.2em;
    }

    #game-container {
        padding: 15px;
    }
}
/* Card Styles */
:root {
    --card-width: 100%;
    --card-height: auto;
    --rarity-common-color: #b0b0b0;
    --rarity-rare-color: #3498db;
    --rarity-epic-color: #9b59b6;
    --rarity-legendary-color: #f1c40f;
}

.event-card {
    background: rgba(30, 30, 40, 0.95);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    transform-style: preserve-3d;
    perspective: 1000px;
}

/* Card Animation */
@keyframes drawCard {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9) rotateX(10deg);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0);
    }
}

.event-card.drawing {
    animation: drawCard 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Rarity Styles */
.event-card.rarity-common {
    border-top: 4px solid var(--rarity-common-color);
}

.event-card.rarity-rare {
    border-top: 4px solid var(--rarity-rare-color);
    box-shadow: 0 10px 30px rgba(52, 152, 219, 0.2);
}

.event-card.rarity-epic {
    border-top: 4px solid var(--rarity-epic-color);
    box-shadow: 0 10px 30px rgba(155, 89, 182, 0.3);
}

.event-card.rarity-legendary {
    border-top: 4px solid var(--rarity-legendary-color);
    box-shadow: 0 10px 40px rgba(241, 196, 15, 0.3);
    background: linear-gradient(145deg, rgba(30, 30, 40, 0.95) 0%, rgba(25, 20, 10, 0.95) 100%);
}

/* Foil/Holographic Effect for Rare+ */
.foil-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s;
    background: linear-gradient(
        125deg, 
        rgba(255,255,255,0) 0%, 
        rgba(255,255,255,0) 40%, 
        rgba(255,255,255,0.1) 45%, 
        rgba(255,255,255,0.2) 50%, 
        rgba(255,255,255,0.1) 55%, 
        rgba(255,255,255,0) 60%, 
        rgba(255,255,255,0) 100%
    );
    background-size: 200% 200%;
    animation: foil-shine 6s infinite linear;
}

@keyframes foil-shine {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 200%; }
}

.event-card.rarity-rare .foil-overlay,
.event-card.rarity-epic .foil-overlay {
    opacity: 0.3;
}

.event-card.rarity-legendary .foil-overlay {
    opacity: 0.5;
    background: linear-gradient(
        125deg, 
        transparent 0%, 
        transparent 35%,
        rgba(255, 215, 0, 0.2) 45%, 
        rgba(255, 255, 255, 0.4) 50%, 
        rgba(255, 215, 0, 0.2) 55%, 
        transparent 65%,
        transparent 100%
    );
    background-size: 300% 300%;
}

/* Storyline Theming */
.storyline-header {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.storyline-icon {
    font-size: 1.5em;
    margin-right: 10px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.storyline-name {
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: bold;
    opacity: 0.8;
}

.event-content {
    position: relative;
    z-index: 2;
}

/* Update existing event elements */
.event-title {
    font-size: 1.5em;
    margin-bottom: 15px;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    line-height: 1.3;
}

.event-description {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 25px;
    color: #e0e0e0;
}

/* Refined Choices */
.choice-btn {
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.rarity-legendary .choice-btn:hover {
    border-color: var(--rarity-legendary-color);
    background: rgba(241, 196, 15, 0.1);
}

/* Rarity Badge */
.rarity-badge {
    position: absolute;
    top: -10px;
    right: 20px;
    padding: 4px 12px;
    border-radius: 0 0 8px 8px;
    font-size: 0.7em;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    z-index: 10;
}

.rarity-badge.common { background: var(--rarity-common-color); color: #333; }
.rarity-badge.rare { background: var(--rarity-rare-color); color: white; }
.rarity-badge.epic { background: var(--rarity-epic-color); color: white; }
.rarity-badge.legendary { background: var(--rarity-legendary-color); color: #333; box-shadow: 0 0 10px var(--rarity-legendary-color); }

/* Debug Graph Styles */
.debug-graph-container {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.debug-graph {
    width: 100%;
    height: 500px;
    background: #1a1a1a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    margin-bottom: 15px;
}

.graph-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: #e8e8e8;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid;
}

.legend-color.eligible {
    background-color: #d4af37;
    border-color: #f4d03f;
    box-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
}

.legend-color.in-deck {
    background-color: #aa8c2c;
    border-color: #d4af37;
}

.legend-color.current {
    background-color: #e74c3c;
    border-color: #c0392b;
}

.legend-color.completed {
    background-color: #444;
    border-color: #666;
    opacity: 0.4;
}

.legend-color.not-in-deck {
    background-color: #2a2a2a;
    border-color: #555;
    opacity: 0.2;
}

.graph-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.graph-btn {
    padding: 8px 16px;
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid #d4af37;
    border-radius: 4px;
    color: #d4af37;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
}

.graph-btn:hover {
    background: rgba(212, 175, 55, 0.3);
    transform: translateY(-1px);
}

.graph-btn:active {
    transform: translateY(0);
}

