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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 600px;
    width: 90%;
}

.game-title {
    font-size: 3em;
    color: #667eea;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-subtitle {
    font-size: 1.2em;
    color: #666;
    margin-bottom: 40px;
}

.start-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#playerName {
    padding: 15px;
    font-size: 1.1em;
    border: 2px solid #ddd;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
}

#playerName:focus {
    border-color: #667eea;
}

.nationality-select {
    padding: 15px;
    font-size: 1.1em;
    border: 2px solid #ddd;
    border-radius: 10px;
    outline: none;
    transition: border-color 0.3s;
    background: white;
    cursor: pointer;
}

.nationality-select:focus {
    border-color: #667eea;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

/* 游戏界面 */
#gameScreen.active {
    display: block;
    height: 100vh;
    overflow: hidden;
}

.game-layout {
    display: flex;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 左侧面板 15% - 玩家信息 */
.left-panel {
    width: 15%;
    min-width: 200px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-right: 3px solid #667eea;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.player-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 15px;
    border-radius: 12px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.player-avatar {
    font-size: 2em;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
}

.player-detail {
    flex: 1;
}

.detail-label {
    font-size: 0.85em;
    opacity: 0.9;
    margin-bottom: 4px;
}

.detail-value {
    font-size: 1.2em;
    font-weight: bold;
    word-break: break-word;
}

/* 中间面板 70% - 世界地图 */
.center-panel {
    width: 70%;
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: relative;
}

.map-header {
    text-align: center;
    margin-bottom: 15px;
    color: white;
}

.map-header h2 {
    font-size: 2em;
    margin: 0 0 5px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.map-hint {
    font-size: 1.1em;
    opacity: 0.9;
    margin: 0;
}

.center-panel .world-map {
    flex: 1;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.3);
}

/* 右侧面板 15% - 仓库和交易记录 */
.right-panel {
    width: 15%;
    min-width: 200px;
    background: rgba(255, 255, 255, 0.95);
    border-left: 3px solid #667eea;
    display: flex;
    flex-direction: column;
}

.warehouse-section {
    flex: 1;
    padding: 15px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.trade-log-section {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(255, 250, 240, 0.5);
}

.section-header {
    margin-bottom: 10px;
}

.section-header h3 {
    color: #667eea;
    font-size: 1.1em;
    margin: 0 0 8px 0;
}

.warehouse-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.warehouse-count {
    color: #667eea;
    font-weight: bold;
}

.btn-upgrade-mini {
    padding: 4px 8px;
    background: #ffd43b;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75em;
    color: #333;
    transition: all 0.3s;
}

.btn-upgrade-mini:hover {
    background: #fcc419;
}

.btn-upgrade-mini:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.warehouse-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.warehouse-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 8px;
    font-size: 0.85em;
}

.warehouse-item-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.warehouse-item-info {
    color: #666;
    font-size: 0.9em;
}

.trade-log-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.trade-log-item {
    background: white;
    padding: 8px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    font-size: 0.75em;
    line-height: 1.4;
}

.trade-log-item.buy {
    border-left-color: #51cf66;
}

.trade-log-item.sell {
    border-left-color: #ff6b6b;
}

.trade-log-time {
    color: #999;
    font-size: 0.9em;
    margin-bottom: 3px;
}

.trade-log-product {
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
}

.trade-log-price {
    color: #667eea;
    font-weight: bold;
}

.world-map {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #b8d8f0;
    overflow: hidden;
    background-image: url('./Resource/worldmap.jpeg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 添加半透明白色遮罩使地图变淡 */
.world-map::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
}

.city {
    position: absolute;
    width: 35px;
    height: 35px;
    background: #ff6b6b;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    border: 3px solid white;
    z-index: 10;
}

.city:hover {
    transform: scale(1.3);
    z-index: 100;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
}

.city.visited {
    background: #51cf66;
}

.city.current {
    background: #ffd43b;
    animation: pulse 1s infinite;
}

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

.city-label {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    font-weight: bold;
}

/* 分类标签 */
.category-tabs {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 6px 10px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: bold;
    transition: all 0.3s;
    color: #666;
}

.tab-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.tab-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 市场弹窗 - 极致宽屏 */
.modal-content.market-modal {
    width: 70vw !important;
    height: 70vh !important;
    max-width: none !important;
    max-height: none !important;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    margin: 1vh auto; /* 居中 */
}

.market-modal-header {
    padding: 15px 25px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.market-modal-header h2 {
    margin: 0;
    color: white;
    font-size: 1.8em;
}

.market-modal-header .close {
    color: white;
    font-size: 35px;
    position: static;
}

.market-modal-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    background-color: white;
}

.market-section {
    flex: 1; /* 自动占据剩余空间 */
    padding: 20px;
    border-right: 2px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.warehouse-section-modal {
    width: 320px; /* 固定宽度 */
    min-width: 320px;
    flex-shrink: 0; /* 不允许缩小 */
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #f9f9f9;
    border-left: 1px solid #ddd;
}

.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); /* 自适应列数 */
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
    padding-bottom: 10px;
    align-content: start;
}

.warehouse-grid {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.market-modal-footer {
    padding: 15px 30px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
    background: #f8f9fa;
}

.market-modal-footer button {
    padding: 12px 30px;
    font-size: 1.1em;
}

/* 市场商品网格布局 - 三列 */
.market-container-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}

/* 仓库容器 - 单列 */
.warehouse-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    flex: 1;
}

/* 紧凑的商品卡片 - 两行布局，买按钮在右侧 */
.product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 6px 8px;
    transition: all 0.2s;
    display: none;
}

.product-card.visible {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.product-card:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

/* 第一行：商品名称和品质 */
.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-name {
    font-weight: bold;
    font-size: 0.85em;
    color: #333;
    flex: 1;
}

.product-quality {
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.65em;
    font-weight: bold;
    white-space: nowrap;
}

.quality-low { background: #ced4da; color: #495057; }
.quality-medium { background: #74c0fc; color: white; }
.quality-high { background: #69db7c; color: white; }
.quality-veryhigh { background: #ffd43b; color: #333; }
.quality-super { background: #ff6b6b; color: white; }

/* 第二行：价格信息和买入按钮 */
.product-buy-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.product-info-compact {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.product-price {
    font-size: 0.9em;
    color: #667eea;
    font-weight: bold;
}

.price-change {
    font-size: 0.65em;
    margin-left: 3px;
}

.price-up { color: #51cf66; }
.price-down { color: #ff6b6b; }

.inventory-info {
    font-size: 0.7em;
    color: #666;
}

.product-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.product-actions button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    font-size: 0.75em;
    white-space: nowrap;
}

.btn-buy {
    background: #51cf66;
    color: white;
}

.btn-buy:hover {
    background: #40c057;
}

.btn-sell {
    background: #ff6b6b;
    color: white;
}

.btn-sell:hover {
    background: #fa5252;
}

.btn-buy:disabled, .btn-sell:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 交易弹窗 */
.trade-modal {
    max-width: 450px;
}

.trade-modal h2 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.trade-modal-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.trade-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
}

.trade-info p {
    margin: 8px 0;
    font-size: 1.1em;
}

.trade-input-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trade-input-group label {
    font-weight: bold;
    color: #333;
}

.input-with-btn {
    display: flex;
    gap: 10px;
}

.input-with-btn input {
    flex: 1;
    padding: 12px;
    font-size: 1.2em;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
}

.btn-max {
    padding: 12px 20px;
    background: #ffd43b;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-max:hover {
    background: #fcc419;
}

.trade-total {
    background: #e7f5ff;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.trade-total p {
    font-size: 1.3em;
    margin: 0;
}

.trade-total strong {
    color: #667eea;
    font-size: 1.4em;
}

.trade-actions {
    display: flex;
    gap: 10px;
}

.trade-actions button {
    flex: 1;
}

/* 结束界面 */
.final-score {
    font-size: 1.3em;
    margin: 30px 0;
    line-height: 2;
}

.final-score strong {
    color: #667eea;
}

#rankMessage {
    font-size: 1.5em;
    color: #ffd43b;
    font-weight: bold;
    margin-top: 20px;
}

/* 排行榜弹窗 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 30px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 30px;
    text-align: center;
}

.leaderboard-list {
    margin-bottom: 30px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s;
}

.leaderboard-item:hover {
    background: #e9ecef;
    transform: translateX(5px);
}

.leaderboard-rank {
    font-size: 1.5em;
    font-weight: bold;
    width: 50px;
    text-align: center;
}

.rank-1 { color: #ffd700; }
.rank-2 { color: #c0c0c0; }
.rank-3 { color: #cd7f32; }

.leaderboard-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.leaderboard-name {
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
}

.leaderboard-nationality {
    font-size: 0.9em;
    color: #666;
}

.leaderboard-money {
    font-size: 1.2em;
    color: #667eea;
    font-weight: bold;
    min-width: 120px;
    text-align: right;
}

.empty-leaderboard {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 1.1em;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .game-top {
        flex-direction: column;
    }
    
    .player-info-panel {
        width: 100%;
        flex-direction: row;
        height: auto;
        overflow-x: auto;
    }
    
    .trade-log-panel {
        width: 100%;
        height: 150px;
    }
    
    .market-container-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .game-top {
        height: 50vh;
    }
    
    .game-bottom {
        height: 50vh;
        flex-direction: column;
    }
    
    .market-panel,
    .warehouse-panel {
        width: 100%;
        height: 50%;
    }
    
    .city {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .city-label {
        font-size: 9px;
    }
}
