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

body {
    background-color: #1a1a1a;
    color: #fff;
    font-family: 'Press Start 2P', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 800px;
    background-color: #0d1117;
    border: 4px solid #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
}

#ui-layer {
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    z-index: 10;
}

.stats-box {
    background: rgba(0,0,0,0.7);
    padding: 10px;
    border: 2px solid #555;
    font-size: 10px;
    line-height: 1.8;
}

.controls-hint {
    background: rgba(0,0,0,0.7);
    padding: 10px;
    border: 2px solid #555;
    font-size: 10px;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.key-hint {
    margin-bottom: 8px;
}

.key {
    background: #fff;
    color: #000;
    padding: 4px 6px;
    border-radius: 4px;
    margin-right: 5px;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

#champagne-screen {
    z-index: 100;
}

h1 {
    font-size: 40px;
    margin-bottom: 20px;
    color: #f1c40f;
    text-shadow: 4px 4px 0 #d35400;
}

p {
    font-size: 12px;
    line-height: 2;
    margin-bottom: 10px;
    text-align: center;
}

button {
    margin-top: 30px;
    padding: 15px 30px;
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    background-color: #2ecc71;
    color: #fff;
    border: 4px solid #fff;
    cursor: pointer;
    box-shadow: 4px 4px 0 #27ae60;
}

button:hover {
    background-color: #27ae60;
}

button:active {
    transform: translate(4px, 4px);
    box-shadow: none;
}

/* Profit Card Base */
.profit-card {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%); /* Fallback */
    border: 8px solid #FFF;
    border-radius: 15px;
    padding: 30px;
    color: #000;
    width: 450px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 0 20px rgba(255,255,255,0.5);
    transform: scale(0.8);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Market Themes */
.card-theme-crypto {
    background: linear-gradient(135deg, #2c3e50 0%, #8e44ad 100%);
    border-color: #00ffff;
    color: #fff;
}
.card-theme-crypto h2 { border-bottom-color: #00ffff; }

.card-theme-ashare {
    background: linear-gradient(135deg, #c0392b 0%, #f39c12 100%);
    border-color: #fff;
    color: #fff;
}
.card-theme-ashare h2 { border-bottom-color: #fff; }

.card-theme-usstock {
    background: linear-gradient(135deg, #116b47 0%, #2ecc71 100%);
    border-color: #f1c40f;
    color: #fff;
}
.card-theme-usstock h2 { border-bottom-color: #f1c40f; }

.screen.active .profit-card {
    transform: scale(1);
}

.profit-card h2 {
    font-size: 20px;
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 4px dashed #000;
    padding-bottom: 10px;
}

.card-details p {
    text-align: left;
    font-size: 14px;
    margin-bottom: 15px;
}

.highlight {
    background: #000;
    color: #0f0;
    padding: 4px 8px;
}

.big-return {
    font-size: 32px !important;
    text-align: center !important;
    margin-top: 20px;
    font-weight: bold;
}

.positive { color: #2ecc71; }
.negative { color: #e74c3c; }
.neutral { color: #fff; }
.card-positive { color: #008000; text-shadow: 2px 2px 0 #fff; }
.card-negative { color: #d30000; text-shadow: 2px 2px 0 #fff; }
.card-neutral { color: #333; text-shadow: 2px 2px 0 #fff; }

.status-msg {
    margin-top: 20px;
    font-size: 12px;
    text-align: center !important;
    font-weight: bold;
}

.export-area {
    display: flex;
    gap: 30px;
    padding: 40px;
    background: #0d1117;
    border: 8px solid #f1c40f;
    justify-content: center;
    align-items: center;
    width: max-content;
    transform: scale(0.6);
    transform-origin: top center;
}

.action-buttons {
    margin-top: -150px;
    z-index: 30;
    display: flex;
    gap: 20px;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: none;
    justify-content: space-around;
    align-items: center;
    z-index: 50;
    pointer-events: none;
}

.mobile-btn {
    pointer-events: auto;
    font-family: 'Press Start 2P', monospace;
    border: 4px solid #fff;
    background: #0d1117;
    color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 0 #fff;
    text-transform: uppercase;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.mobile-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #fff !important;
}

.action-btn {
    width: 80px;
    height: 80px;
    font-size: 14px;
    margin: 0 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.trade-emoji {
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    line-height: 1;
}

.buy-btn .trade-emoji {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff3a0;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #fff7b2 0%, #f1c40f 48%, #b8860b 100%);
    box-shadow: 0 0 0 2px rgba(241, 196, 15, 0.28), 0 3px 0 #8a6508;
    font-size: 19px;
}

.buy-btn {
    border-color: #2ecc71;
    color: #2ecc71;
    box-shadow: 0 4px 0 #2ecc71;
}

.sell-btn {
    border-color: #e74c3c;
    color: #e74c3c;
    box-shadow: 0 4px 0 #e74c3c;
}

.small-btn {
    width: 50px;
    height: 50px;
    font-size: 12px;
}

.dpad-center {
    display: flex;
}

@media (max-width: 768px) {
    body {
        align-items: flex-start;
    }
    #game-container {
        width: 100%;
        height: 100dvh;
        border: none;
        box-shadow: none;
    }
    #game-canvas {
        flex: 1;
        height: auto;
    }
    #mobile-controls {
        display: flex;
        position: relative;
        bottom: auto;
        left: auto;
        padding: 10px 0 20px 0;
        flex-shrink: 0;
    }
    #start-screen.active ~ #mobile-controls,
    #custom-challenge-screen.active ~ #mobile-controls,
    #settlement-screen.active ~ #mobile-controls {
        display: none;
    }
    .controls-hint {
        display: none;
    }
    
    #settlement-screen {
        justify-content: flex-start;
        overflow-y: auto;
        padding: 12px 12px 24px;
    }

    #settlement-screen .profit-card {
        flex-shrink: 0;
        margin-top: 8px;
    }

    #settlement-screen > button {
        width: auto;
        min-width: 176px;
        max-width: 82vw;
        margin-top: 10px;
        padding: 10px 16px;
        border-width: 3px;
        font-size: 10px;
        line-height: 1.35;
    }

    #settlement-screen #champagne-btn {
        font-size: 9px;
    }

    .profit-card {
        width: 100%;
        max-width: 320px;
        padding: 20px;
        border-width: 4px;
    }
    .profit-card h2 { font-size: 16px; margin-bottom: 10px; }
    .card-details p { font-size: 12px; margin-bottom: 8px; }
    .big-return { font-size: 24px !important; margin-top: 10px; }
    
    .export-area {
        flex-direction: column;
        width: 100%;
        box-sizing: border-box;
        transform: scale(1);
        gap: 15px;
        padding: 20px;
        border-width: 4px;
    }
    
    .action-buttons {
        flex-direction: column;
        margin-top: 20px;
        gap: 10px;
        width: 90%;
    }
    .action-buttons button {
        width: 100%;
        margin: 0;
    }
}
