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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #050505;
    color: #e0e0e0;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 噪点覆盖 */
.noise {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.07;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    animation: noiseMove 0.2s steps(4) infinite;
}

@keyframes noiseMove {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-5%, 5%); }
    50% { transform: translate(5%, -5%); }
    75% { transform: translate(-5%, -5%); }
    100% { transform: translate(5%, 5%); }
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1000px;
    max-height: 700px;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
}

/* 标题界面 */
.title-screen {
    background: radial-gradient(circle at center, #1a0505 0%, #000000 80%);
}

.title-screen h1 {
    font-size: 4em;
    color: #8b0000;
    text-shadow: 0 0 20px #ff0000, 0 0 60px #500000;
    margin-bottom: 20px;
    letter-spacing: 8px;
    animation: flicker 3s infinite alternate;
}

.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    color: #ff0000;
    animation: glitch1 2s infinite linear alternate-reverse;
    clip-path: polygon(0 0, 100% 0, 100% 35%, 0 35%);
}

.glitch::after {
    color: #00ffff;
    animation: glitch2 2s infinite linear alternate-reverse;
    clip-path: polygon(0 65%, 100% 65%, 100% 100%, 0 100%);
}

@keyframes glitch1 {
    0% { transform: translate(0); }
    20% { transform: translate(-3px, 3px); }
    40% { transform: translate(3px, -3px); }
    60% { transform: translate(-2px, 0); }
    80% { transform: translate(2px, 2px); }
    100% { transform: translate(0); }
}

@keyframes glitch2 {
    0% { transform: translate(0); }
    20% { transform: translate(3px, -3px); }
    40% { transform: translate(-3px, 3px); }
    60% { transform: translate(2px, 0); }
    80% { transform: translate(-2px, -2px); }
    100% { transform: translate(0); }
}

@keyframes flicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% { opacity: 1; text-shadow: 0 0 20px #ff0000, 0 0 60px #500000; }
    20%, 24%, 55% { opacity: 0.7; text-shadow: 0 0 5px #500000; }
}

.subtitle {
    font-size: 1.2em;
    color: #a0a0a0;
    line-height: 2;
    margin-bottom: 15px;
}

.warning {
    color: #8b0000;
    font-size: 0.95em;
    margin-bottom: 35px;
    line-height: 1.8;
    border: 1px solid #3a0000;
    padding: 12px 20px;
    border-radius: 8px;
    background: rgba(50, 0, 0, 0.2);
}

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.mode-buttons .start-btn {
    margin: 0;
}

.start-btn, .menu-btn {
    padding: 16px 55px;
    font-size: 1.2em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    margin: 8px;
}

.start-btn {
    background: #8b0000;
    color: #fff;
    box-shadow: 0 0 25px rgba(139, 0, 0, 0.5);
}

.start-btn:hover {
    background: #b30000;
    box-shadow: 0 0 40px rgba(255, 0, 0, 0.6);
    transform: scale(1.03);
}

.menu-btn {
    background: transparent;
    color: #888;
    border: 1px solid #444;
}

.menu-btn:hover {
    color: #fff;
    border-color: #888;
}

.controls {
    margin-top: 35px;
    color: #666;
    font-size: 0.9em;
    line-height: 1.8;
}

/* 游戏界面 */
.game-screen {
    background: #000;
    justify-content: flex-start;
    padding: 0;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: none;
}

.hud {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 18px 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.hud-center {
    text-align: center;
}

.mode-badge {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.9em;
    font-weight: 600;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.flashlight, .keys, .heartbeat, .companion-status {
    font-size: 1.1em;
    color: #ccc;
    text-shadow: 0 0 5px #000;
}

.companion-status {
    color: #00bfff;
}

.companion-status.danger {
    color: #ff0000;
    animation: pulse 0.4s infinite;
}

#batteryBar {
    color: #00ff00;
    letter-spacing: 2px;
}

#batteryBar.low {
    color: #ff0000;
    animation: flashText 0.5s infinite;
}

@keyframes flashText {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

#keyCount {
    color: #ffd700;
}

.heartbeat {
    color: #888;
}

.heartbeat.danger {
    color: #ff0000;
    animation: pulse 0.4s infinite;
}

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

.message {
    color: #ff0000;
    font-size: 1.4em;
    font-weight: bold;
    text-shadow: 0 0 10px #ff0000;
    min-height: 1.6em;
    opacity: 0;
    transition: opacity 0.3s;
}

.message.show {
    opacity: 1;
}

/* 结束界面 */
.end-screen {
    background: #000;
}

.end-screen h2 {
    font-size: 3em;
    color: #8b0000;
    margin-bottom: 15px;
    text-shadow: 0 0 30px #ff0000;
}

.end-screen p {
    font-size: 1.2em;
    color: #888;
    margin-bottom: 30px;
}

/* 跳脸惊吓 */
.jumpscare {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.jumpscare.active {
    display: flex;
    animation: jumpscareFlash 0.25s ease-out;
}

.jumpscare-face {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle at 40% 35%, #fff 4%, transparent 5%),
                radial-gradient(circle at 60% 35%, #fff 4%, transparent 5%),
                radial-gradient(circle at 50% 55%, #000 15%, transparent 16%),
                #111;
    border-radius: 50%;
    box-shadow: 0 0 60px #ff0000, inset 0 0 60px #500000;
    animation: faceZoom 0.25s ease-out;
}

.jumpscare-face::before,
.jumpscare-face::after {
    content: '';
    position: absolute;
    background: #8b0000;
    width: 40px;
    height: 60px;
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
}

.jumpscare-face::before { left: 25%; }
.jumpscare-face::after { right: 25%; }

.jumpscare-text {
    margin-top: 30px;
    font-size: 3em;
    color: #ff0000;
    text-shadow: 0 0 20px #ff0000;
    animation: textShake 0.2s infinite;
}

@keyframes jumpscareFlash {
    0% { background: #fff; }
    20% { background: #500000; }
    100% { background: #000; }
}

@keyframes faceZoom {
    0% { transform: scale(0.1); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes textShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 屏幕血红闪烁 */
.blood-flash {
    animation: bloodFlash 0.4s ease-out;
}

@keyframes bloodFlash {
    0% { filter: brightness(1); }
    30% { filter: brightness(2) sepia(1) hue-rotate(-50deg) saturate(3); }
    100% { filter: brightness(1); }
}

/* 响应式 */
@media (max-width: 600px) {
    .title-screen h1 {
        font-size: 2.5em;
    }
    .hud {
        font-size: 0.85em;
        padding: 12px 15px;
    }
}
