/* ===========================
   GLOBAL STYLES & RESET
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1a2e 50%, #16213e 100%);
    color: #fff;
    overflow: hidden;
    width: 100%;
    height: 100vh;
}

/* ===========================
   MAIN GAME CONTAINER
   =========================== */
.game-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0.5rem;
}

/* Check if in iframe or standalone */
@media (min-height: 600px) {
    body {
        height: 90vh;
    }
}

/* ===========================
   TOP STATS BAR
   =========================== */
.stats-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #00ffff;
    border-radius: 10px;
    padding: 0.5rem 1rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: help;
    transition: transform 0.2s;
}

.stat-item:hover {
    transform: scale(1.1);
}

.stat-label {
    font-size: 0.7rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
}

.combo-display {
    color: #ffff00;
    text-shadow: 0 0 10px rgba(255, 255, 0, 0.8);
}

/* ===========================
   WORD DISPLAY SECTION
   =========================== */
.word-display {
    text-align: center;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    border: 2px solid #ff00ff;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

.hanzi {
    font-size: 2.5rem;
    font-weight: bold;
    color: #ff00ff;
    text-shadow: 0 0 20px rgba(255, 0, 255, 0.8);
    margin-bottom: 0.3rem;
}

.instruction {
    font-size: 0.9rem;
    color: #00ffff;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ===========================
   RACE TRACK
   =========================== */
.race-track {
    flex: 1;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #00ff00;
    border-radius: 10px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

/* Finish Line */
.finish-line {
    position: absolute;
    right: 10px;
    top: 0;
    bottom: 0;
    width: 30px;
    background: repeating-linear-gradient(
        45deg,
        #fff,
        #fff 10px,
        #000 10px,
        #000 20px
    );
    border-left: 3px solid #ffff00;
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.6);
    z-index: 1;
}

/* Lane Styling */
.lane {
    position: relative;
    height: 25%;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
}

.lane:last-child {
    border-bottom: none;
}

/* Distance Markers */
.distance-marker {
    position: absolute;
    right: 50px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
}

/* ===========================
   RACER STYLING
   =========================== */
.racer {
    position: absolute;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.3s ease-out;
    z-index: 2;
}

.racer-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
}

.racer-label {
    font-size: 0.6rem;
    margin-top: 0.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.player-racer .racer-label {
    color: #00ffff;
    text-shadow: 0 0 5px rgba(0, 255, 255, 0.8);
}

.ai-racer .racer-label {
    color: #ff6b6b;
    text-shadow: 0 0 5px rgba(255, 107, 107, 0.8);
}

/* ===========================
   INPUT SECTION
   =========================== */
.input-section {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.pinyin-input {
    flex: 1;
    padding: 0.8rem 1.2rem;
    font-size: 1.2rem;
    font-family: 'Noto Sans SC', sans-serif;
    background: rgba(0, 0, 0, 0.6);
    border: 3px solid #00ffff;
    border-radius: 10px;
    color: #fff;
    outline: none;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
    transition: all 0.3s;
}

.pinyin-input:focus {
    border-color: #ff00ff;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
    transform: scale(1.02);
}

.pinyin-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Input Shake Animation for Wrong Answer */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.3s;
    border-color: #ff0000 !important;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.8) !important;
}

/* ===========================
   BUTTONS
   =========================== */
.start-btn,
.restart-btn {
    padding: 0.8rem 2rem;
    font-size: 1rem;
    font-weight: bold;
    font-family: 'Noto Sans SC', sans-serif;
    background: linear-gradient(135deg, #00ff00, #00cc00);
    color: #000;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transition: all 0.3s;
    white-space: nowrap;
}

.start-btn:hover,
.restart-btn:hover {
    background: linear-gradient(135deg, #00ff88, #00dd44);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.8);
    transform: scale(1.05);
}

.start-btn:active,
.restart-btn:active {
    transform: scale(0.95);
}

.hidden {
    display: none !important;
}

/* ===========================
   PARTICLE EFFECTS
   =========================== */
.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #00ff00;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-burst 0.6s ease-out forwards;
    box-shadow: 0 0 10px #00ff00;
}

@keyframes particle-burst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* Neon Flash Effect */
@keyframes neon-flash {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.neon-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 255, 0, 0.2);
    pointer-events: none;
    animation: neon-flash 0.3s;
    z-index: 999;
}

/* ===========================
   RESULT OVERLAY
   =========================== */
.result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.result-card {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 3px solid #00ffff;
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.5);
    max-width: 400px;
    width: 90%;
}

.result-title {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 1.5rem;
    color: #ffff00;
    text-shadow: 0 0 20px rgba(255, 255, 0, 0.8);
}

.result-stats {
    margin-bottom: 1.5rem;
}

.result-stat {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.result-stat:last-child {
    border-bottom: none;
}

.result-label {
    color: #00ffff;
    font-size: 1rem;
}

.result-value {
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
}

/* ===========================
   RESPONSIVE ADJUSTMENTS
   =========================== */
@media (max-width: 768px) {
    .hanzi {
        font-size: 2rem;
    }
    
    .stat-label {
        font-size: 0.6rem;
    }
    
    .stat-value {
        font-size: 1rem;
    }
    
    .racer-icon {
        font-size: 1.5rem;
    }
    
    .pinyin-input {
        font-size: 1rem;
        padding: 0.6rem 1rem;
    }
}

/* ===========================
   ACCESSIBILITY
   =========================== */
button:focus,
input:focus {
    outline: 3px solid #ffff00;
    outline-offset: 2px;
}