/* 基础样式和重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

:root {
    --primary-orange: #FF7A45;
    --secondary-orange: #FF9C6E;
    --light-orange: #FFD8BF;
    --dark-orange: #D4380D;
    --warm-yellow: #FFC53D;
    --light-yellow: #FFE58F;
    --warm-red: #FF4D4F;
    --light-red: #FF7875;
    --warm-brown: #8B4513;
    --light-brown: #D2691E;
    --cream: #FFF7E6;
    --light-cream: #FFFBEF;
    --dark-gray: #434343;
    --medium-gray: #8C8C8C;
    --light-gray: #D9D9D9;
    --success: #52C41A;
    --info: #1890FF;
    --warning: #FAAD14;
    --error: #FF4D4F;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
}

body {
    background: linear-gradient(135deg, #FFF7E6, #FFE7BA);
    color: var(--dark-gray);
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, var(--primary-orange), var(--warm-yellow));
    border-radius: var(--border-radius-lg);
    padding: 30px 40px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

header::before {
    content: "";
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
    background-size: 30px 30px;
    transform: rotate(15deg);
    z-index: 1;
}

.header-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

h1 {
    font-size: 3.2rem;
    color: white;
    margin-bottom: 15px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

h1 i {
    font-size: 2.8rem;
    animation: pulse 2s infinite;
}

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

.subtitle {
    font-size: 1.4rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
}

/* 场次信息和钱包区域 */
.race-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.race-info-card, .wallet-card {
    background: white;
    border-radius: var(--border-radius-md);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--light-orange);
}

.race-info-card {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--light-cream);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--primary-orange);
}

.info-item i {
    font-size: 2rem;
    color: var(--primary-orange);
}

.info-label {
    font-size: 0.9rem;
    color: var(--medium-gray);
    margin-bottom: 5px;
}

.info-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--dark-orange);
}

.wallet-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.wallet-header i {
    font-size: 1.8rem;
    color: var(--primary-orange);
}

.wallet-header h3 {
    color: var(--dark-orange);
    font-size: 1.5rem;
}

.address-label {
    font-size: 0.9rem;
    color: var(--medium-gray);
    margin-bottom: 10px;
}

.address-container {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--light-cream);
    padding: 12px 15px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--light-orange);
    margin-bottom: 15px;
}

#walletAddress {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--dark-gray);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: all;
}

.copy-btn {
    background: var(--primary-orange);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.copy-btn:hover {
    background: var(--dark-orange);
    transform: scale(1.05);
}

.wallet-note {
    font-size: 0.85rem;
    color: var(--medium-gray);
    display: flex;
    align-items: center;
    gap: 8px;
}

.wallet-note i {
    color: var(--info);
}

/* 主游戏区域 */
.game-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.track-container {
    background: white;
    border-radius: var(--border-radius-md);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--light-orange);
}

.track-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light-cream);
}

.track-header h2 {
    color: var(--dark-orange);
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.race-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--light-cream);
    border-radius: 50px;
    border: 2px solid var(--light-orange);
}

.status-icon {
    font-size: 1.5rem;
}

.status-text {
    font-weight: 600;
    color: var(--dark-gray);
}

/* 赛道样式 */
.track {
    position: relative;
    height: 500px;
    background: linear-gradient(to right, #4A7C1F, #6BAA2F, #8BC34A);
    border-radius: 15px;
    overflow: hidden;
    border: 8px solid var(--warm-brown);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.lane {
    position: absolute;
    width: 100%;
    height: 60px;
    border-bottom: 3px dashed rgba(255, 255, 255, 0.3);
}

.lane-number {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.2rem;
    border: 2px solid white;
    z-index: 2;
}

.horse {
    position: absolute;
    width: 100px;
    height: 70px;
    left: 60px;
    transition: left 0.2s linear;
    z-index: 10;
    filter: drop-shadow(3px 3px 5px rgba(0,0,0,0.5));
}

.horse-body {
    position: absolute;
    width: 70px;
    height: 45px;
    background: currentColor;
    border-radius: 35px 15px 20px 20px;
    top: 12px;
    left: 15px;
    transform: skewX(-5deg);
}

.horse-head {
    position: absolute;
    width: 30px;
    height: 30px;
    background: currentColor;
    border-radius: 50% 40% 50% 40%;
    top: 8px;
    left: 0;
    transform: rotate(-15deg);
}

.horse-leg {
    position: absolute;
    width: 10px;
    height: 30px;
    background: currentColor;
    bottom: 0;
    border-radius: 5px 5px 0 0;
}

.leg-front { left: 20px; }
.leg-back { left: 55px; }

.horse-mane {
    position: absolute;
    width: 25px;
    height: 20px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5), rgba(0,0,0,0.2));
    border-radius: 50% 30% 30% 50%;
    top: 5px;
    left: 25px;
    transform: rotate(15deg);
}

.horse-number {
    position: absolute;
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: black;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.4rem;
    border: 3px solid black;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    z-index: 11;
}

.horse-name {
    position: absolute;
    top: -70px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 15px;
    border-radius: 20px;
    border: 2px solid currentColor;
    min-width: 80px;
    text-align: center;
}

.finish-line {
    position: absolute;
    right: 70px;
    top: 0;
    bottom: 0;
    width: 12px;
    background: repeating-linear-gradient(
        to bottom,
        white,
        white 20px,
        var(--warm-red) 20px,
        var(--warm-red) 40px
    );
    z-index: 5;
    box-shadow: 0 0 25px rgba(255, 77, 79, 0.6);
}

.finish-flag {
    position: absolute;
    right: 85px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    z-index: 6;
    filter: drop-shadow(3px 3px 5px rgba(0,0,0,0.7));
    animation: wave 2s infinite;
}

@keyframes wave {
    0%, 100% { transform: translateY(-50%) rotate(0deg); }
    25% { transform: translateY(-50%) rotate(5deg); }
    75% { transform: translateY(-50%) rotate(-5deg); }
}

/* 排行榜样式 */
.leaderboard {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-md);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--primary-orange);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.leaderboard-header h3 {
    color: var(--dark-orange);
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.race-progress {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-bar {
    width: 150px;
    height: 10px;
    background: var(--light-cream);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-orange), var(--warm-yellow));
    border-radius: 5px;
    width: 0%;
    transition: width 0.5s;
}

#progressText {
    font-weight: bold;
    color: var(--dark-orange);
    min-width: 45px;
}

.leaderboard-content {
    max-height: 200px;
    overflow-y: auto;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: var(--light-cream);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid;
    transition: all 0.3s;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

/* 控制面板样式 */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.time-card, .stats-card, .action-card {
    background: white;
    border-radius: var(--border-radius-md);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--light-orange);
}

.time-header, .stats-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.time-header i, .stats-header i {
    font-size: 1.8rem;
    color: var(--primary-orange);
}

.time-header h3, .stats-header h3 {
    color: var(--dark-orange);
    font-size: 1.5rem;
}

.countdown {
    font-size: 3.5rem;
    font-weight: bold;
    text-align: center;
    color: var(--dark-orange);
    font-family: 'Courier New', monospace;
    margin: 20px 0;
    padding: 15px;
    background: var(--light-cream);
    border-radius: var(--border-radius-sm);
    border: 3px solid var(--primary-orange);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.time-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.time-item {
    padding: 12px;
    background: var(--light-cream);
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-item span:first-child {
    font-size: 0.9rem;
    color: var(--medium-gray);
    margin-bottom: 5px;
}

.time-item span:last-child {
    font-weight: bold;
    color: var(--dark-orange);
    font-size: 1.1rem;
}

.stats-content {
    display: grid;
    gap: 15px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: var(--light-cream);
    border-radius: var(--border-radius-sm);
    border-left: 4px solid;
}

.btn {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.refresh-btn {
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-orange));
    color: white;
}

.history-btn {
    background: linear-gradient(135deg, var(--warm-yellow), var(--light-yellow));
    color: var(--dark-gray);
}

.rules-btn {
    background: linear-gradient(135deg, var(--info), #69C0FF);
    color: white;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.btn:active {
    transform: translateY(-1px);
}

/* 结果和统计区域 */
.results-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.results-panel, .stats-panel {
    background: white;
    border-radius: var(--border-radius-md);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--light-orange);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--light-cream);
}

.panel-header h2 {
    color: var(--dark-orange);
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.last-update {
    font-size: 0.9rem;
    color: var(--medium-gray);
}

.update-btn {
    padding: 8px 16px;
    background: var(--light-cream);
    border-radius: var(--border-radius-sm);
    color: var(--primary-orange);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.update-btn:hover {
    background: var(--primary-orange);
    color: white;
}

.results-content {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

.result-card {
    padding: 20px;
    margin-bottom: 15px;
    background: var(--light-cream);
    border-radius: var(--border-radius-md);
    border-left: 5px solid var(--primary-orange);
    transition: all 0.3s;
}

.result-card:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow-sm);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.race-number {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--dark-orange);
}

.race-time {
    font-size: 0.9rem;
    color: var(--medium-gray);
}

.winner-info {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.winner-name {
    font-size: 1.2rem;
    font-weight: bold;
}

.result-positions {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--medium-gray);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.horse-stat-card {
    padding: 20px;
    background: var(--light-cream);
    border-radius: var(--border-radius-md);
    border: 2px solid;
    transition: all 0.3s;
}

.horse-stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.stat-horse-name {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.win-rate-bar {
    height: 10px;
    background: var(--light-gray);
    border-radius: 5px;
    margin: 10px 0;
    overflow: hidden;
}

.win-rate-fill {
    height: 100%;
    border-radius: 5px;
}

.stat-numbers {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--medium-gray);
}

/* 规则说明区域 */
.rules-section {
    background: white;
    border-radius: var(--border-radius-md);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary-orange);
    margin-bottom: 30px;
    display: none;
}

.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--light-cream);
}

.rules-header h2 {
    color: var(--dark-orange);
    font-size: 2rem;
    display: flex;
    align-items: center;
    gap: 15px;
}

.close-rules {
    background: var(--light-cream);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--primary-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-rules:hover {
    background: var(--primary-orange);
    color: white;
    transform: rotate(90deg);
}

.rules-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

.rule-category h3 {
    color: var(--dark-orange);
    font-size: 1.4rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.rule-category ul {
    list-style: none;
    padding-left: 10px;
}

.rule-category li {
    padding: 10px 0;
    border-bottom: 1px solid var(--light-cream);
    position: relative;
    padding-left: 30px;
}

.rule-category li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: bold;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius-md);
    width: 90%;
    max-width: 1000px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-orange));
    color: white;
}

.modal-header h3 {
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.close-modal {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    transition: transform 0.3s;
}

.close-modal:hover {
    transform: scale(1.1);
}

.modal-body {
    padding: 30px;
    max-height: 60vh;
    overflow-y: auto;
}

.history-table-container {
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    background: var(--light-cream);
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: var(--dark-orange);
    border-bottom: 3px solid var(--primary-orange);
}

.history-table td {
    padding: 15px;
    border-bottom: 1px solid var(--light-cream);
}

.history-table tr:hover {
    background: var(--light-cream);
}

/* 页脚样式 */
footer {
    background: linear-gradient(135deg, var(--primary-orange), var(--secondary-orange));
    border-radius: var(--border-radius-md);
    padding: 25px;
    text-align: center;
    color: white;
    box-shadow: var(--shadow-md);
}

.footer-content p {
    margin-bottom: 10px;
}

.footer-note {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* 提示框样式 */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--success);
    color: white;
    padding: 20px 25px;
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    display: none;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.1rem;
}

/* 动画效果 */
@keyframes horseRun {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes celebration {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-25px) scale(1.2); }
}

.running {
    animation: horseRun 0.5s ease infinite;
}

.celebrate {
    animation: celebration 0.8s ease infinite;
    z-index: 20;
}

.pulse {
    animation: pulse 1.5s ease infinite;
}

/* 响应式设计 */
@media (max-width: 1200px) {
    .game-container {
        grid-template-columns: 1fr;
    }
    
    .results-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .race-meta {
        grid-template-columns: 1fr;
    }
    
    .race-info-card {
        grid-template-columns: 1fr;
    }
    
    .rules-content {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 2.2rem;
        flex-direction: column;
        gap: 10px;
    }
    
    .track-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .time-info {
        grid-template-columns: 1fr;
    }
}