* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-color: #2196F3;
    --secondary-color: #FFC107;
    --success-color: #4CAF50;
    --danger-color: #F44336;
    --background-color: #F5F5F5;
    --card-background: #FFFFFF;
    --text-primary: #212121;
    --text-secondary: #757575;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-elevated: 0 4px 8px rgba(0,0,0,0.15);
    --border-radius: 12px;
    --header-height: 80px;
    --bottom-menu-height: 100px;
    --max-content-width: 800px;
}

[data-theme="dark"] {
    --primary-color: #64B5F6;
    --secondary-color: #FFD54F;
    --success-color: #81C784;
    --background-color: #121212;
    --card-background: #1E1E1E;
    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --shadow: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-elevated: 0 4px 8px rgba(0,0,0,0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

.game-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--header-height) + env(safe-area-inset-top));
    background: var(--card-background);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
    padding-top: env(safe-area-inset-top, 0);
    z-index: 100;
}

.currency-display {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    padding: 16px 20px;
    position: relative;
    height: 100%;
    border-radius: 8px;
    margin-left: -20px;
}

.currency-display:hover {
    transform: translateY(-1px);
    background: rgba(0,0,0,0.05);
}

.currency-display:active {
    transform: scale(0.95);
}

.currency-display::after {
    content: '💰';
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    opacity: 0;
    transition: all 0.3s ease;
}

.currency-display:hover::after {
    opacity: 0.5;
    right: -25px;
}

.currency-main {
    font-size: 28px;
    font-weight: bold;
    color: var(--success-color);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    animation: pulse-subtle 2s ease-in-out infinite;
}

@keyframes pulse-subtle {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

#currency-symbol {
    margin-right: 4px;
}

.income-per-second {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.income-symbol {
    color: var(--success-color);
    margin-right: 2px;
}

.income-suffix {
    margin-left: 2px;
    opacity: 0.8;
}

.region-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    position: relative;
    overflow: hidden;
}

.region-indicator::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(45deg);
    transition: all 0.6s;
    opacity: 0;
}

.region-indicator:hover::before {
    animation: shine 0.6s ease-in-out;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); opacity: 0; }
}

.region-indicator:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

.region-indicator:active {
    transform: scale(0.95);
}

.region-flag {
    font-size: 24px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.region-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.game-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
    padding-bottom: calc(var(--bottom-menu-height) + env(safe-area-inset-bottom));
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.business-list {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: var(--max-content-width);
    margin: 0 auto;
    width: 100%;
}

.business-card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    padding: 16px;
    height: 140px;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
}

.business-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.6s;
}

.business-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.business-card:hover::before {
    left: 100%;
}

.business-card.tapped {
    transform: scale(0.98);
    animation: bounce-back 0.4s ease;
}

@keyframes bounce-back {
    0% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.business-card.locked {
    opacity: 0.9;
    background: var(--card-background);
}

.business-icon-container {
    position: relative;
    flex-shrink: 0;
}

.business-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    transition: all 0.3s ease;
}

.business-card:hover .business-icon {
    transform: rotate(5deg) scale(1.1);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.4);
}

.business-icon.locked {
    background: #9E9E9E;
    filter: grayscale(100%);
}

.lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    background: rgba(0,0,0,0.7);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-pill {
    position: absolute;
    bottom: -8px;
    right: -8px;
    background: linear-gradient(135deg, var(--secondary-color), #FFD54F);
    color: #333;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
    animation: level-pulse 2s ease-in-out infinite;
}

@keyframes level-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.business-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.business-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.business-name {
    font-size: 16px;
    font-weight: 600;
}

.business-timer {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    width: 60px;
    text-align: right;
}

.progress-container {
    width: 100%;
    height: 24px;
    background: #E0E0E0;
    border-radius: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--success-color);
    border-radius: 12px;
    transition: width 0.1s linear;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.progress-income {
    font-size: 12px;
    color: white;
    font-weight: 500;
    white-space: nowrap;
}

.business-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.business-earnings {
    font-size: 14px;
    color: var(--text-secondary);
}

.level-up-buttons {
    display: flex;
    gap: 8px;
}

.level-up-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.level-up-button.buy-max {
    background: var(--secondary-color);
}

.button-label {
    font-size: 11px;
    opacity: 0.9;
}

.button-cost {
    font-size: 12px;
    font-weight: 600;
}

.level-up-button:active:not(:disabled) {
    transform: scale(0.95);
}

.level-up-button:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
    opacity: 0.6;
}

.bottom-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-menu-height) + env(safe-area-inset-bottom));
    background: var(--card-background);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    padding: 16px max(16px, env(safe-area-inset-left)) env(safe-area-inset-bottom) max(16px, env(safe-area-inset-right));
    z-index: 100;
}

.menu-button {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 12px;
    transition: all 0.3s ease;
    position: relative;
}

.menu-button:hover {
    background-color: rgba(33, 150, 243, 0.1);
    transform: translateY(-2px);
}

.menu-button:active {
    transform: scale(0.95);
    background-color: rgba(33, 150, 243, 0.2);
}

.menu-icon {
    font-size: 28px;
    transition: transform 0.3s ease;
}

.menu-button:hover .menu-icon {
    transform: scale(1.1) rotate(5deg);
}

.menu-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.boost-timer {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--success-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    display: none;
}

.boost-timer.active {
    display: block;
}

.active-boosts {
    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card-background);
    border-bottom: 1px solid rgba(0,0,0,0.1);
    overflow-x: auto;
    min-height: 0;
    transition: all 0.3s ease;
}

.active-boosts:empty {
    display: none;
}

.boost-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.boost-item .boost-icon {
    font-size: 16px;
}

.boost-item .boost-time {
    font-family: monospace;
    font-weight: bold;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-elevated);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #E0E0E0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

.modal-body {
    padding: 20px;
}

.upgrade-item, .manager-item {
    background: var(--background-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.item-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.item-effect {
    font-size: 12px;
    color: var(--success-color);
    font-weight: 500;
}

.buy-button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.buy-button:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
}

.buy-button.purchased {
    background: var(--success-color);
}

.unlock-cost {
    color: var(--secondary-color);
    font-weight: 600;
}

.unlock-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.unlock-button {
    background: #9E9E9E;
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    margin-top: 8px;
}

.unlock-button.can-afford {
    background: var(--success-color);
}

.unlock-button:active:not(:disabled) {
    transform: scale(0.95);
}

.unlock-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.theme-toggle {
    position: fixed;
    top: calc(20px + env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    background: var(--card-background);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: var(--shadow-elevated);
    z-index: 200;
    transition: all 0.3s;
}

.theme-toggle:active {
    transform: scale(0.9);
}

/* Milestone Notifications */
.milestone-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.milestone-notification.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.milestone-content {
    display: flex;
    align-items: center;
    gap: 16px;
    color: #333;
}

.milestone-icon {
    font-size: 48px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.milestone-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.milestone-title {
    font-size: 20px;
    font-weight: bold;
    color: #222;
}

.milestone-desc {
    font-size: 16px;
    color: #444;
}

.milestone-reward {
    font-size: 18px;
    font-weight: bold;
    color: #0a5e0a;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
    .theme-toggle {
        top: auto;
        bottom: calc(var(--bottom-menu-height) + env(safe-area-inset-bottom) + 20px);
        right: max(16px, env(safe-area-inset-right));
    }
}

/* Business Blitz Minigame Styles */
.business-blitz-modal .modal-content {
    max-width: 500px;
    padding: 25px;
}

.blitz-description {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
}

.blitz-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--background-secondary);
    border-radius: 10px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    font-size: 12px;
    color: #999;
    display: block;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.blitz-game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
}

.blitz-card {
    aspect-ratio: 1;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s;
}

.blitz-card:hover {
    transform: scale(1.05);
}

.blitz-card.flipped {
    transform: rotateY(180deg);
}

.blitz-card.matched {
    animation: matchPulse 0.5s ease-out;
    pointer-events: none;
}

.blitz-card.matched .card-back {
    background: var(--success-color);
    color: white;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border-radius: 10px;
    backface-visibility: hidden;
}

.card-front {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    font-weight: bold;
}

.card-back {
    background: white;
    border: 2px solid var(--primary-color);
    transform: rotateY(180deg);
}

@keyframes matchPulse {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.2); }
    100% { transform: rotateY(180deg) scale(1); }
}

.blitz-controls {
    text-align: center;
}

.blitz-rewards {
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

.blitz-rewards h3 {
    color: var(--secondary-color);
    font-size: 28px;
    margin-bottom: 20px;
}

.final-score, .reward-text, .combo-text {
    font-size: 18px;
    margin: 10px 0;
}

.final-score {
    color: var(--primary-color);
}

.reward-text {
    color: var(--success-color);
    font-weight: bold;
}

.combo-text {
    color: var(--secondary-color);
}

.floating-score {
    position: fixed;
    font-size: 24px;
    font-weight: bold;
    color: var(--success-color);
    pointer-events: none;
    animation: floatUp 1s ease-out forwards;
    z-index: 10000;
    transform: translateX(-50%);
}

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