html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: #ffffff;
    background-color: #1C1917;
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    background: #1C1917;
}

#game-container {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#game-container canvas {
    touch-action: none;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#hud button,
#hud a,
#hud input,
#hud [role="button"],
#hud .interactive {
    pointer-events: auto;
}

/* ---------------- Generic screens ---------------- */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    padding: 16px;
    box-sizing: border-box;
}

.screen-menu {
    background: radial-gradient(ellipse at center, #3d2b1f 0%, #1C1917 80%);
    text-align: center;
    gap: 24px;
}

.market-emoji-row {
    font-size: 40px;
    margin-bottom: 8px;
    letter-spacing: 6px;
}

.market-title h1 {
    font-size: 30px;
    margin: 4px 0;
    color: #FBBF24;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.subtitle {
    color: #e5d9c8;
    font-size: 14px;
    max-width: 320px;
    margin: 0 auto;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 320px;
}

.btn {
    min-height: 56px;
    padding: 14px 20px;
    border-radius: 14px;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, filter 0.15s ease;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(180deg, #10B981, #008751);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(0,135,81,0.5);
}

.btn-secondary {
    background: #78350F;
    color: #fff2df;
}

.btn-difficulty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: #2b1b10;
    border: 2px solid #78350F;
    color: #fff;
    text-align: left;
}

.diff-name {
    font-size: 16px;
    font-weight: 800;
    color: #FBBF24;
}

.diff-detail {
    font-size: 12px;
    color: #cbb8a2;
}

.btn-accept {
    background: linear-gradient(180deg, #10B981, #059669);
    color: #fff;
}

.btn-decline {
    background: linear-gradient(180deg, #EF4444, #b91c1c);
    color: #fff;
}

/* ---------------- Modal ---------------- */
.screen-modal {
    background: rgba(0,0,0,0.6);
}

.modal-card {
    background: #241a12;
    border: 2px solid #78350F;
    border-radius: 18px;
    padding: 22px;
    width: 100%;
    max-width: 380px;
    max-height: 90%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-card h2 {
    margin: 0 0 4px 0;
    color: #FBBF24;
    font-size: 20px;
    text-align: center;
}

.howto-list {
    padding-left: 18px;
    margin: 4px 0;
    font-size: 13px;
    line-height: 1.5;
    color: #e5d9c8;
}

.deal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    justify-content: center;
    margin: 6px 0;
}

.finished-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    color: #f0e6d8;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    padding: 10px;
}

.proverb {
    font-style: italic;
    color: #FBBF24;
    font-size: 13px;
    text-align: center;
}

/* ---------------- Countdown ---------------- */
.screen-countdown {
    background: rgba(0,0,0,0.5);
}

.countdown-text {
    font-size: 42px;
    font-weight: 900;
    color: #FBBF24;
    text-shadow: 0 4px 12px rgba(0,0,0,0.7);
    text-align: center;
    animation: pulse 0.7s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

/* ---------------- HUD top bar ---------------- */
.top-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px;
    background: linear-gradient(180deg, rgba(28,25,23,0.95), rgba(28,25,23,0.6));
    pointer-events: auto;
    flex-wrap: wrap;
}

.hud-stat {
    font-size: 13px;
    font-weight: 800;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
}

.hud-stat.cash { color: #FBBF24; }
.hud-stat.target { color: #10B981; }
.hud-stat.timer { color: #93c5fd; }
.hud-stat.timer.urgent { color: #EF4444; animation: pulse 0.5s ease-in-out infinite; }

.icon-btn {
    margin-left: auto;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

/* ---------------- Event ticker ---------------- */
.event-ticker {
    position: absolute;
    top: 58px;
    left: 8px;
    right: 8px;
    background: #F97316;
    color: #1C1917;
    font-weight: 700;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    text-align: center;
    pointer-events: none;
    z-index: 20;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.active-event-badge {
    position: absolute;
    top: 58px;
    right: 8px;
    background: rgba(239,68,68,0.9);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    pointer-events: none;
    z-index: 21;
}

/* ---------------- Product grid ---------------- */
.product-grid {
    position: absolute;
    top: 66px;
    bottom: 10px;
    left: 0;
    right: 0;
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    pointer-events: auto;
}

.product-card {
    background: rgba(41,30,20,0.92);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 10px 12px;
}

.product-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-icon {
    font-size: 26px;
}

.product-name-block {
    flex: 1;
}

.product-name {
    font-weight: 800;
    font-size: 14px;
    color: #fff2df;
}

.product-unit {
    font-size: 11px;
    color: #b3a08a;
}

.trend-badge {
    font-size: 18px;
}

.product-price {
    font-size: 18px;
    font-weight: 900;
    color: #FBBF24;
    margin-top: 4px;
}

.product-owned {
    font-size: 11px;
    color: #cbb8a2;
    margin-bottom: 6px;
}

.product-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 6px;
}

.action-btn {
    min-height: 40px;
    border-radius: 8px;
    border: none;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    color: #fff;
}

.action-btn.buy {
    background: #008751;
}

.action-btn.sell {
    background: #b45309;
}

/* ---------------- Customer modal ---------------- */
.customer-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 30;
    padding: 16px;
}

.customer-modal {
    background: #241a12;
    border: 2px solid #FBBF24;
    border-radius: 16px;
    padding: 20px;
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.6);
}

.customer-name {
    font-size: 18px;
    font-weight: 900;
    color: #FBBF24;
}

.customer-deal {
    font-size: 13px;
    font-weight: 800;
}

.customer-dialogue {
    font-style: italic;
    color: #e5d9c8;
    font-size: 13px;
}

.customer-order-detail {
    font-size: 13px;
    color: #fff2df;
    background: rgba(255,255,255,0.06);
    border-radius: 8px;
    padding: 8px;
}

.customer-actions {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.customer-actions .btn {
    flex: 1;
    min-height: 56px;
}

@media (min-width: 700px) {
    .product-grid {
        grid-template-columns: 1fr 1fr;
    }
}
