* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --secondary: #f39c12;
    --success: #27ae60;
    --danger: #e74c3c;
    --bg: #f5f5f5;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --border: #ddd;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.15);
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
}

#app {
    width: 100%;
    height: 100vh;
    position: relative;
}

.screen {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* 开始画面 */
#start-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.start-container {
    text-align: center;
    color: white;
    max-width: 600px;
    padding: 40px;
}

.start-container h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.subtitle {
    font-size: 1.3em;
    margin-bottom: 30px;
    opacity: 0.9;
}

.story-box {
    background: rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 30px;
    backdrop-filter: blur(10px);
    line-height: 1.8;
}

.story-box strong {
    color: #ffeaa7;
}

/* 按钮 */
.btn-primary, .btn-secondary, .btn-success, .btn-danger, .btn-small, .btn-warning {
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #219a52;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-warning {
    background: var(--secondary);
    color: white;
}

.btn-warning:hover {
    background: #e67e22;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* 顶部状态栏 */
.top-bar {
    display: flex;
    justify-content: space-around;
    padding: 12px 20px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    z-index: 10;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.95em;
}

.stat-icon {
    font-size: 1.3em;
}

.stat-value {
    font-weight: bold;
    color: var(--primary);
    font-size: 1.1em;
}

/* 主区域 */
.main-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.section-title {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--text);
}

/* 摊位网格 */
.stalls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.stall-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.stall-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--secondary);
}

.stall-card.visited {
    opacity: 0.7;
}

.stall-icon {
    font-size: 2.5em;
    text-align: center;
    margin-bottom: 8px;
}

.stall-name {
    font-weight: bold;
    text-align: center;
    margin-bottom: 4px;
}

.stall-owner {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85em;
    margin-bottom: 8px;
}

.stall-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.tag {
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    color: var(--text-light);
}

.tag.specialty {
    background: #d5f5e3;
    color: var(--success);
}

/* 购物清单栏 */
.shopping-list-bar {
    background: var(--card-bg);
    padding: 16px 20px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}

.shopping-items {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.shopping-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 8px;
    white-space: nowrap;
    border: 2px solid transparent;
}

.shopping-item.completed {
    border-color: var(--success);
    background: #d5f5e3;
}

.shopping-item .item-icon {
    font-size: 1.3em;
}

.shopping-item .item-name {
    font-size: 0.9em;
}

.shopping-item .item-status {
    font-size: 0.75em;
    color: var(--text-light);
}

/* 商品选择画面 */
#product-select-screen {
    background: #f0f2f5;
}

.select-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.select-hint {
    color: var(--text-light);
    font-size: 0.9em;
}

.select-main {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.select-section {
    margin-bottom: 24px;
}

.needed-badge {
    background: #fdeaea;
    color: #e74c3c;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    margin-left: 8px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.product-select-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    text-align: center;
}

.product-select-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--secondary);
}

.product-select-card.needed {
    border-color: #fdeaea;
    background: linear-gradient(to bottom, #fff, #fff8f8);
}

.product-select-card.needed:hover {
    border-color: #e74c3c;
}

.product-select-card .p-icon {
    font-size: 3em;
    margin-bottom: 8px;
}

.product-select-card .p-name {
    font-weight: bold;
    margin-bottom: 4px;
}

.product-select-card .p-price {
    color: var(--primary);
    font-weight: bold;
    margin-bottom: 4px;
}

.product-select-card .p-freshness {
    font-size: 0.8em;
    color: var(--text-light);
    margin-bottom: 8px;
}

.product-select-card .p-tag {
    display: inline-block;
    background: #d5f5e3;
    color: var(--success);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75em;
}

/* 砍价战斗画面 */
#battle-screen {
    background: #f0f2f5;
}

.battle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--card-bg);
    box-shadow: var(--shadow);
}

.stall-name {
    font-weight: bold;
    font-size: 1.1em;
}

.turn-indicator {
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
    transition: all 0.3s;
}

.turn-indicator.player-turn {
    background: #dbeafe;
    color: #1e40af;
}

.turn-indicator.vendor-turn {
    background: #fdeaea;
    color: #991b1b;
}

.battle-main {
    flex: 1;
    display: grid;
    grid-template-columns: 260px 1fr 320px;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
    min-height: 0;
}

/* 商品面板 */
.product-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    min-height: 0;
}

.product-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.product-icon {
    font-size: 3.5em;
    margin-bottom: 8px;
}

.product-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 8px;
}

.product-price {
    margin-bottom: 6px;
    color: var(--text-light);
    font-size: 0.9em;
}

.product-price .original-price {
    text-decoration: line-through;
}

.product-price.current {
    color: var(--primary);
    font-size: 1.2em;
    font-weight: bold;
}

.product-price.current .current-price {
    font-size: 1.3em;
}

.product-freshness {
    margin: 8px 0;
    padding: 6px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.9em;
}

#inspect-btn {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    font-size: 0.9em;
}

.flaws-list {
    margin-top: 8px;
    text-align: left;
}

.flaw-item {
    background: #fdeaea;
    color: var(--danger);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8em;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* AP面板 */
.ap-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
}

.ap-title {
    font-weight: bold;
    margin-bottom: 8px;
    text-align: center;
}

.ap-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.ap-label {
    font-size: 0.8em;
    width: 50px;
    color: var(--text-light);
}

.ap-bar {
    flex: 1;
    height: 10px;
    background: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
}

.ap-fill {
    height: 100%;
    transition: width 0.3s;
    border-radius: 5px;
}

.ap-fill.player-ap {
    background: #3498db;
}

.ap-fill.vendor-ap {
    background: #e74c3c;
}

.ap-text {
    font-size: 0.8em;
    width: 40px;
    text-align: right;
    font-weight: bold;
}

#end-turn-btn {
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    font-size: 0.9em;
}

/* 心情面板 */
.mood-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.mood-title {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.mood-bar {
    width: 100%;
    height: 10px;
    background: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 4px;
}

.mood-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #27ae60);
    width: 80%;
    transition: width 0.3s;
}

#vendor-mood-text {
    font-size: 0.85em;
    color: var(--text-light);
}

/* 耐心面板 */
.patience-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.patience-title {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.patience-bar {
    width: 100%;
    height: 10px;
    background: #ecf0f1;
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 4px;
}

.patience-fill {
    height: 100%;
    background: linear-gradient(90deg, #e74c3c, #f39c12, #3498db);
    width: 100%;
    transition: width 0.3s;
}

#patience-text {
    font-size: 0.85em;
    color: var(--text-light);
}

/* 警觉面板 */
.alert-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.alert-title {
    font-weight: bold;
    margin-bottom: 6px;
    font-size: 0.9em;
}

.alert-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
}

.alert-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ecf0f1;
    transition: all 0.3s;
}

.alert-dot.active {
    background: #e74c3c;
    box-shadow: 0 0 8px #e74c3c;
}

.alert-dot.warning {
    background: #f39c12;
}

/* 对话面板 */
.dialogue-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.dialogue-history {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
    padding-right: 4px;
    min-height: 0;
}

.dialogue-entry {
    margin-bottom: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 90%;
    animation: fadeIn 0.3s ease;
    font-size: 0.9em;
    word-break: break-word;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dialogue-entry.player {
    background: #dbeafe;
    margin-left: auto;
    text-align: right;
}

.dialogue-entry.vendor {
    background: #fdeaea;
    margin-right: auto;
}

.dialogue-entry.system {
    background: #fef3c7;
    text-align: center;
    margin: 0 auto 8px;
    font-size: 0.85em;
    color: #92400e;
}

.vendor-avatar {
    font-size: 2.5em;
    text-align: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.vendor-speech {
    text-align: center;
    font-style: italic;
    color: var(--text-light);
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95em;
    word-break: break-word;
    flex-shrink: 0;
}

/* 操作面板 */
.action-panel {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    overflow: hidden;
}

.defense-bar {
    text-align: center;
}

.defense-label {
    font-size: 0.85em;
    color: var(--text-light);
    margin-bottom: 4px;
}

.defense-track {
    width: 100%;
    height: 16px;
    background: #ecf0f1;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.defense-fill {
    height: 100%;
    background: linear-gradient(90deg, #27ae60, #f39c12, #e74c3c);
    width: 100%;
    transition: width 0.5s ease;
}

.deck-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-light);
    padding: 4px 0;
}

/* 卡牌 */
.cards-section {
    flex: 1;
    min-height: 0;
}

.cards-hand {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
    padding-right: 2px;
}

.card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
}

.card:hover:not(.disabled):not(.unplayable) {
    transform: translateX(-4px);
    box-shadow: var(--shadow-hover);
    border-color: #ffeaa7;
}

.card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.card.unplayable {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: #e74c3c;
}

.card-name {
    font-weight: bold;
    margin-bottom: 2px;
    font-size: 0.95em;
}

.card-desc {
    font-size: 0.75em;
    opacity: 0.9;
    line-height: 1.3;
}

.card-cost {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(255,255,255,0.25);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.7em;
}

.card-ap {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0,0,0,0.3);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.7em;
}

.card-cond {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.4);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.65em;
}

.direct-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.direct-actions button {
    width: 100%;
    padding: 10px;
    font-size: 0.95em;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.slider-container {
    margin: 20px 0;
}

#price-slider {
    width: 100%;
    margin-bottom: 8px;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--text-light);
}

.offer-chance {
    margin: 16px 0;
    font-size: 1.1em;
}

#success-chance {
    font-weight: bold;
    color: var(--primary);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

/* 结束画面 */
#end-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.end-container {
    text-align: center;
    color: white;
    padding: 40px;
}

.end-container h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
}

.end-stats {
    background: rgba(255,255,255,0.15);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: blur(10px);
    line-height: 2;
}

/* 动画 */
.shake {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.pulse {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.vendor-thinking {
    animation: thinking 1s ease infinite;
}

@keyframes thinking {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* 响应式 */
@media (max-width: 900px) {
    .battle-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        overflow-y: auto;
    }
    
    .stalls-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #bdc3c7;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #95a5a6;
}
