* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg-dark: #0a0a1a;
    --neon-cyan: #00ffff;
    --neon-purple: #bf40ff;
    --neon-pink: #ff40a0;
    --neon-green: #40ff80;
    --neon-yellow: #ffff40;
    --neon-red: #ff4040;
}
body {
    background: linear-gradient(135deg, #0f0f2f 0%, #1a1a3f 50%, #0a0a1a 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    font-family: 'Orbitron', 'Courier New', monospace;
    overflow: hidden;
}
#game-wrapper {
    display: flex;
    gap: 0;
    border: 3px solid var(--neon-cyan);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5), 0 0 60px rgba(0, 255, 255, 0.3);
    overflow: hidden;
}
#game-container {
    position: relative;
    width: 960px;
    height: 640px;
}
#gameCanvas { display: block; background-color: #0a0a1a; }
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 30, 0.98);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    padding: 15px;
    overflow-y: auto;
    z-index: 200;
    pointer-events: auto;
}
.screen.active { display: flex; }
.title {
    font-size: 32px;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
    letter-spacing: 4px;
}
.subtitle { color: #a0a0d0; margin-bottom: 16px; font-size: 15px; }
.btn {
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.3), rgba(0, 255, 255, 0.1));
    border: 2px solid var(--neon-cyan);
    color: white;
    padding: 10px 30px;
    font-size: 16px;
    font-family: 'Orbitron', monospace;
    cursor: pointer;
    margin: 5px;
    border-radius: 8px;
    transition: all 0.3s;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
    background: linear-gradient(180deg, rgba(0, 255, 255, 0.5), rgba(0, 255, 255, 0.2));
}
.mode-selector { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; justify-content: center; }
.mode-btn {
    padding: 8px 18px;
    background: rgba(191, 64, 255, 0.2);
    border: 2px solid var(--neon-purple);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}
.mode-btn:hover, .mode-btn.selected {
    background: rgba(191, 64, 255, 0.5);
    box-shadow: 0 0 15px rgba(191, 64, 255, 0.5);
}
.controls-info {
    margin-top: 12px;
    padding: 10px 20px;
    background: rgba(20, 20, 40, 0.8);
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    line-height: 1.6;
    font-size: 12px;
    max-width: 420px;
}
.controls-info span { color: var(--neon-yellow); font-weight: bold; }
.stats-box {
    background: rgba(20, 20, 40, 0.9);
    border: 2px solid var(--neon-purple);
    padding: 15px 20px;
    border-radius: 12px;
    width: 280px;
    margin-top: 10px;
}
.stats-box h2 { color: var(--neon-pink); margin-bottom: 12px; font-size: 22px; }
.stats-box p { display: flex; justify-content: space-between; margin: 6px 0; color: #a0a0d0; font-size: 13px; }
.stats-box .value { color: var(--neon-green); font-weight: bold; }
#speech-status {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    border: 2px solid var(--neon-cyan);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 300px;
    max-width: 90%;
    text-align: center;
    z-index: 50;
}
#speech-status .target-sentence {
    color: var(--neon-yellow);
    font-size: 14px;
    margin-bottom: 6px;
    font-weight: bold;
    word-wrap: break-word;
}
#speech-status .status {
    color: #aaa;
    font-size: 12px;
}
#speech-status.listening {
    border-color: var(--neon-green);
    animation: pulse-green 1s infinite;
}
#text-input-container {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
}
#text-input-container input {
    padding: 10px 15px;
    font-size: 16px;
    font-family: 'Orbitron', monospace;
    border: 2px solid var(--neon-purple);
    border-radius: 8px;
    background: rgba(10, 10, 30, 0.9);
    color: white;
    width: 300px;
}
#text-input-container input:focus {
    outline: none;
    border-color: var(--neon-cyan);
}
.result-popup {
    position: absolute;
    font-size: 48px;
    font-weight: bold;
    pointer-events: none;
    animation: popUp 0.8s forwards;
}
.result-popup.correct { color: var(--neon-green); }
.result-popup.wrong { color: var(--neon-red); }
@keyframes popUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(1.5); opacity: 0; }
}
@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 10px rgba(64, 255, 128, 0.5); }
    50% { box-shadow: 0 0 20px rgba(64, 255, 128, 0.8); }
}

/* ===== Sentence Panel ===== */
#sentence-panel {
    width: 300px;
    background: rgba(10, 10, 30, 0.98);
    border-left: 2px solid rgba(0, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    max-height: 640px;
}
.panel-header {
    padding: 14px 16px;
    font-size: 15px;
    font-weight: bold;
    color: var(--neon-cyan);
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
    text-align: center;
    flex-shrink: 0;
}
#sentence-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#sentence-list::-webkit-scrollbar {
    width: 4px;
}
#sentence-list::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.3);
    border-radius: 2px;
}
.sentence-card {
    background: rgba(20, 20, 50, 0.9);
    border: 1px solid rgba(191, 64, 255, 0.3);
    border-radius: 8px;
    padding: 10px 12px;
    transition: all 0.3s;
}
.sentence-card.attacking {
    border-color: var(--neon-red);
    box-shadow: 0 0 10px rgba(255, 64, 64, 0.4);
    animation: card-flash 0.8s infinite;
}
@keyframes card-flash {
    0%, 100% { border-color: var(--neon-red); }
    50% { border-color: rgba(255, 64, 64, 0.3); }
}
.sentence-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.sentence-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}
.sentence-index.normal {
    background: rgba(191, 64, 255, 0.4);
    color: #fff;
    border: 1px solid var(--neon-purple);
}
.sentence-index.boss {
    background: rgba(255, 64, 64, 0.4);
    color: #fff;
    border: 1px solid var(--neon-red);
}
.speak-btn {
    background: rgba(0, 255, 255, 0.15);
    border: 1px solid rgba(0, 255, 255, 0.4);
    color: var(--neon-cyan);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.speak-btn:hover {
    background: rgba(0, 255, 255, 0.35);
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.5);
    transform: scale(1.1);
}
.speak-btn:active {
    transform: scale(0.95);
}
.sentence-en {
    display: block;
    color: var(--neon-yellow);
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 3px;
    word-break: break-word;
}
.sentence-cn {
    display: block;
    color: #8080b0;
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 8px;
    word-break: break-word;
}
.sentence-hp-bar {
    height: 5px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}
.sentence-hp-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}
.sentence-hp-fill.normal {
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
}
.sentence-hp-fill.boss {
    background: linear-gradient(90deg, var(--neon-red), #ff8040);
}
#achievements-display {
    margin-top: 15px;
    max-width: 320px;
}
.achievement-popup {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
    border: 1px solid #ffd700;
    border-radius: 8px;
    padding: 8px 14px;
    margin: 6px 0;
    font-size: 13px;
    color: #ffd700;
    text-align: center;
    animation: achPop 0.5s ease-out;
}
@keyframes achPop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Stats Panel */
#stats-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    background: rgba(10, 10, 30, 0.98);
    border: 2px solid var(--neon-cyan);
    border-radius: 12px;
    padding: 20px;
    z-index: 300;
    display: none;
}
#stats-panel.active { display: block; }
#stats-panel h3 {
    color: var(--neon-cyan);
    font-size: 14px;
    margin: 15px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(0, 255, 255, 0.2);
}
#stats-panel h3:first-child { margin-top: 0; }
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: rgba(20, 20, 50, 0.8);
    border-radius: 6px;
    border: 1px solid rgba(191, 64, 255, 0.2);
}
.stat-label {
    color: #8080b0;
    font-size: 11px;
}
.stat-value {
    color: #fff;
    font-size: 13px;
    font-weight: bold;
}
.week-chart {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 80px;
    padding: 10px 0;
}
.day-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.bar {
    width: 30px;
    min-height: 4px;
    border-radius: 3px 3px 0 0;
    transition: height 0.3s;
}
.day-label {
    color: #8080b0;
    font-size: 10px;
}
.weak-words {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.weak-word {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(20, 20, 50, 0.6);
    border-radius: 4px;
}
.word-text {
    color: #fff;
    font-size: 12px;
    min-width: 80px;
}
.word-accuracy {
    color: #ff8040;
    font-size: 11px;
    font-weight: bold;
}
.word-seen {
    color: #666;
    font-size: 10px;
}
.no-data {
    color: #666;
    font-size: 11px;
    text-align: center;
    padding: 10px;
}
.stats-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.stats-close:hover {
    border-color: var(--neon-red);
    color: var(--neon-red);
}

/* ===== 手机端控件 ===== */
#mobile-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}
#mobile-controls.hidden .joystick-base,
#mobile-controls.hidden .skill-buttons,
#mobile-controls.hidden .record-btn {
    display: none;
}

/* 隐藏按钮 */
.toggle-controls-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    z-index: 300;
    transition: all 0.2s;
}
.toggle-controls-btn:hover {
    background: rgba(0, 255, 255, 0.3);
    border-color: var(--neon-cyan);
}

/* 虚拟摇杆 */
.joystick-base {
    position: absolute;
    bottom: 40px;
    left: 40px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(0, 255, 255, 0.4);
    pointer-events: auto;
    touch-action: none;
}
.joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0, 255, 255, 0.8), rgba(0, 255, 255, 0.3));
    border: 2px solid var(--neon-cyan);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.4);
    pointer-events: none;
}

/* 技能按钮 */
.skill-buttons {
    position: absolute;
    bottom: 100px;
    right: 30px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}
.skill-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.15);
    border: 2px solid rgba(0, 255, 255, 0.5);
    color: white;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    transition: all 0.15s;
    position: relative;
}
.skill-btn:active {
    transform: scale(0.9);
    background: rgba(0, 255, 255, 0.4);
}
.skill-btn .skill-label {
    position: absolute;
    bottom: -16px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    white-space: nowrap;
}
.skill-btn .skill-cost {
    position: absolute;
    top: -14px;
    font-size: 9px;
    color: var(--neon-yellow);
    white-space: nowrap;
}
.skill-btn.on-cooldown {
    opacity: 0.4;
    border-color: #444;
}

/* 录音按钮 */
.record-btn {
    position: absolute;
    bottom: 30px;
    right: 40px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 64, 64, 0.2);
    border: 3px solid rgba(255, 64, 64, 0.6);
    color: white;
    font-size: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    cursor: pointer;
    touch-action: none;
    transition: all 0.15s;
}
.record-btn:active {
    transform: scale(0.95);
}
.record-btn.recording {
    background: rgba(255, 64, 64, 0.5);
    border-color: #ff4040;
    animation: pulse-record 1s infinite;
}
@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 64, 64, 0.4); }
    50% { box-shadow: 0 0 30px rgba(255, 64, 64, 0.7); }
}

/* 移动端适配 */
@media (max-width: 768px) {
    body {
        overflow: auto;
        align-items: flex-start;
    }
    #game-wrapper {
        flex-direction: column;
        width: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    #game-container {
        width: 100%;
    }
    #gameCanvas {
        width: 100%;
        height: auto;
    }
    #sentence-panel {
        width: 100%;
        max-height: 200px;
        border-left: none;
        border-top: 2px solid rgba(0, 255, 255, 0.3);
    }
    .controls-info {
        display: none;
    }
}
