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

/* ========== 加载屏幕 ========== */
#loading-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
}

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

.loading-content {
    text-align: center;
    color: white;
}

.loading-title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 40px;
    letter-spacing: 5px;
    text-shadow: 2px 2px 10px rgba(0,0,0,0.3);
    animation: titlePulse 2s ease-in-out infinite;
}

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

.loading-spinner {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 30px auto;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 4px solid transparent;
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

.spinner-ring:nth-child(1) {
    border-top-color: #fff;
    animation-delay: 0s;
}

.spinner-ring:nth-child(2) {
    border-right-color: #fff;
    animation-delay: 0.2s;
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
}

.spinner-ring:nth-child(3) {
    border-bottom-color: #fff;
    animation-delay: 0.4s;
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    margin-bottom: 20px;
    opacity: 0.9;
}

.loading-progress {
    margin: 20px auto;
    width: 300px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #4ecdc4, #44a08d);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-percent {
    font-size: 16px;
    font-weight: bold;
}

.loading-tip {
    font-size: 14px;
    opacity: 0.7;
    margin-top: 30px;
    animation: tipFade 3s ease-in-out infinite;
}

@keyframes tipFade {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

body {
    font-family: 'Microsoft YaHei', sans-serif;
    overflow: hidden;
    background: #333;
}

#game-container {
    width: 100vw;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.screen.active {
    display: block;
}

/* ========== 剧情场景 ========== */
#story-screen {
    background: #1a1a2e;
    cursor: pointer;
    overflow: hidden;
}

#skip-story-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 20px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 25px;
    color: white;
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s ease;
}

#skip-story-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    border-color: white;
    transform: scale(1.05);
}

#story-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: opacity 0.5s ease;
}

#story-background.scene-1 {
    background-image: url('assets/images/story1_phone.jpg');
    background-color: #4a90d9;
}

#story-background.scene-2 {
    background-image: url('assets/images/story2_deskmate.jpg');
    background-color: #5cb85c;
}

#story-background.scene-3 {
    background-image: url('assets/images/story3_teacher.jpg');
    background-color: #f0ad4e;
}

#story-background.scene-4 {
    background-image: url('assets/images/story4_angry.jpg');
    background-color: #d9534f;
}

#story-dialogue-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    transition: opacity 0.3s ease;
    z-index: 50;
}

#story-dialogue-container.hidden {
    opacity: 0;
    pointer-events: none;
}

#story-text {
    font-size: 22px;
    color: #333;
    line-height: 1.8;
    min-height: 60px;
    text-align: center;
}

#click-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #999;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

#story-choices-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.5);
    z-index: 100;
}

#story-choices-container.active {
    display: flex;
}

#story-choices {
    display: flex;
    gap: 40px;
    justify-content: center;
    flex-wrap: wrap;
}

.story-choice {
    padding: 20px 50px;
    font-size: 22px;
    border: none;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    min-width: 250px;
}

.story-choice.choice-a {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: #fff;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.5);
}

.story-choice.choice-b {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: #fff;
    box-shadow: 0 5px 20px rgba(78, 205, 196, 0.5);
}

.story-choice:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.story-choice:active {
    transform: scale(1.05);
}

/* ========== 游戏画面 ========== */
#game-screen {
    background: #87ceeb;
}

#game-header {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    z-index: 20;
}

.score-box {
    background: rgba(0,0,0,0.7);
    color: #ffd700;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 18px;
    font-weight: bold;
}

#speed-indicator {
    background: rgba(255,0,0,0.7);
    color: #fff;
    display: none;
}

#speed-indicator.active {
    display: block;
}

#game-canvas-container {
    width: 100%;
    height: 100%;
    position: relative;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
    cursor: pointer;
}

.start-text {
    font-size: 48px;
    color: #fff;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    animation: pulse 1.5s infinite;
}

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

.controls-text {
    font-size: 20px;
    color: #ccc;
}

#game-over-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.game-over-title {
    font-size: 56px;
    color: #ff6b6b;
    font-weight: bold;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.game-over-stats {
    font-size: 24px;
    color: #fff;
    text-align: center;
    margin-bottom: 30px;
}

.game-over-stats p {
    margin: 10px 0;
}

#restart-btn, #replay-btn {
    padding: 15px 50px;
    font-size: 20px;
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: #fff;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

#restart-btn:hover, #replay-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 30px rgba(78, 205, 196, 0.5);
}

/* ========== 答题画面 ========== */
#quiz-screen {
    background: rgba(0,0,0,0.8);
}

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

.quiz-container {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    padding: 50px;
    border-radius: 20px;
    text-align: center;
    max-width: 600px;
    width: 90%;
}

.quiz-header {
    font-size: 28px;
    color: #ff6b6b;
    font-weight: bold;
    margin-bottom: 30px;
}

.quiz-question {
    font-size: 24px;
    color: #fff;
    margin-bottom: 40px;
    line-height: 1.6;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.quiz-option {
    padding: 15px 30px;
    font-size: 18px;
    border: 2px solid #4ecdc4;
    background: rgba(78, 205, 196, 0.1);
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.quiz-option:hover {
    background: rgba(78, 205, 196, 0.3);
    border-color: #fff;
}

.quiz-option.correct {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    border-color: #27ae60;
}

.quiz-option.wrong {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    border-color: #c0392b;
}

.quiz-timer {
    font-size: 20px;
    color: #ffd700;
    font-weight: bold;
}

/* ========== 结局画面 ========== */
#ending-screen {
    background: #1a1a2e;
}

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

.ending-container {
    text-align: center;
    max-width: 800px;
    padding: 40px;
}

.ending-title {
    font-size: 48px;
    font-weight: bold;
    margin-bottom: 30px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.ending-title.ending-a {
    color: #ff6b6b;
}

.ending-title.ending-b {
    color: #4ecdc4;
}

.ending-content {
    font-size: 22px;
    color: #ccc;
    line-height: 1.8;
    margin-bottom: 40px;
}