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

body {
    font-family: "Microsoft YaHei", Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #fff;
    overflow-x: hidden;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.title {
    font-size: 28px;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin-bottom: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.stat-card.danger-zone {
    border-color: rgba(255, 107, 107, 0.6);
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
    animation: dangerPulse 2s ease-in-out infinite;
}

@keyframes dangerPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 107, 107, 0.6);
    }
}

.danger-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    animation: bounce 1s ease infinite;
}

.danger-timer {
    font-size: 11px;
    color: #ff6b6b;
    margin-top: 3px;
    font-weight: bold;
}

.stat-title {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #ffd700;
}

.stat-info {
    font-size: 12px;
    color: #ff6b6b;
    margin-top: 5px;
}

.bar-container {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
}

.bar {
    height: 100%;
    transition: width 0.3s ease, background 0.3s ease;
    border-radius: 10px;
}

.merit-bar {
    background: linear-gradient(90deg, #ffd700, #ffed4e);
}

.merit-bar.danger {
    background: linear-gradient(90deg, #ff6b6b, #ee5a6f);
}

.stamina-bar {
    background: linear-gradient(90deg, #00d4ff, #0099ff);
}

.stamina-bar.warning {
    background: linear-gradient(90deg, #ffcc00, #ffaa00);
}

.stamina-bar.exhausted {
    background: linear-gradient(90deg, #ff6b6b, #ee5a6f);
}

.exhausted-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #fff;
    pointer-events: none;
}

.game-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
}

.family-group {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.family-member {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.grandpa {
    width: 150px;
    height: 150px;
    position: relative;
    transition: transform 0.15s ease-out;
}

.helper {
    width: 120px;
    height: 120px;
    position: relative;
    transition: transform 0.15s ease-out;
}

.family-member.kowtow-left .grandpa,
.family-member.kowtow-left .helper {
    transform: rotate(-20deg) scale(0.95);
}

.family-member.kowtow-right .grandpa,
.family-member.kowtow-right .helper {
    transform: rotate(20deg) scale(0.95);
}

.grandpa.exhausted,
.helper.exhausted {
    filter: grayscale(0.5) brightness(0.7);
}

.family-emoji {
    font-size: 120px;
    display: block;
    text-align: center;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.helper .family-emoji {
    font-size: 100px;
}

.family-label {
    margin-top: 5px;
    font-size: 14px;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.merit-multiplier {
    position: absolute;
    top: -10px;
    right: -10px;
    background: linear-gradient(135deg, #ff6b6b, #ffd700);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    padding: 4px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.6);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 107, 107, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 4px 16px rgba(255, 107, 107, 0.9);
    }
}

.controls {
    text-align: center;
    margin-bottom: 20px;
}

.control-hint {
    font-size: 16px;
    color: #aaa;
    margin-bottom: 10px;
}

.exhausted-hint {
    font-size: 14px;
    color: #ff6b6b;
    font-weight: bold;
    margin-bottom: 10px;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.button-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 15px;
}

.kowtow-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 15px 30px;
    font-size: 18px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.kowtow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.kowtow-btn:active {
    transform: translateY(0);
}

.kowtow-btn.mobile-active {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.kowtow-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: linear-gradient(135deg, #666 0%, #444 100%);
}

.event-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 20px;
}

.event-title {
    font-size: 16px;
    color: #ffd700;
    margin-bottom: 10px;
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.event-item {
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    animation: fadeIn 0.5s ease;
    border-left: 4px solid;
    line-height: 1.6;
}

.event-item.rarity-c {
    background: rgba(100, 149, 237, 0.2);
    border-color: #6495ED;
}

.event-item.rarity-b {
    background: rgba(50, 205, 50, 0.2);
    border-color: #32CD32;
}

.event-item.rarity-a {
    background: rgba(255, 215, 0, 0.2);
    border-color: #FFD700;
}

.event-item.rarity-sr {
    background: rgba(147, 112, 219, 0.2);
    border-color: #9370DB;
}

.event-item.rarity-ssr {
    background: rgba(255, 69, 0, 0.2);
    border-color: #FF4500;
}

.event-item.rarity-curse {
    background: rgba(139, 0, 0, 0.3);
    border-color: #8B0000;
}

.rarity-tag {
    font-weight: bold;
    margin-right: 8px;
    font-size: 13px;
}

.event-name {
    font-weight: bold;
    margin-right: 8px;
}

.event-desc {
    color: #ddd;
    font-style: italic;
}

.rarity-c .rarity-tag {
    color: #6495ED;
}

.rarity-b .rarity-tag {
    color: #32CD32;
}

.rarity-a .rarity-tag {
    color: #FFD700;
}

.rarity-sr .rarity-tag {
    color: #9370DB;
}

.rarity-ssr .rarity-tag {
    color: #FF4500;
}

.rarity-curse .rarity-tag {
    color: #8B0000;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    z-index: 1000;
    min-width: 300px;
    max-width: 500px;
    border: 2px solid #ff4444;
}

.notification h2 {
    font-size: 32px;
    color: #ff4444;
    margin-bottom: 15px;
}

.notification p {
    font-size: 18px;
    margin-bottom: 10px;
}

.restart-btn {
    background: #ffd700;
    color: #000;
    border: none;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 20px;
    font-weight: bold;
    transition: transform 0.2s;
}

.restart-btn:hover {
    transform: scale(1.05);
}

.view-events-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px 30px;
    font-size: 18px;
    border-radius: 25px;
    cursor: pointer;
    margin-top: 15px;
    font-weight: bold;
    transition: transform 0.2s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.view-events-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

/* 事件记录浮层样式 */
.event-history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.event-history-overlay.active {
    display: flex;
}

.event-history-container {
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.98) 0%, rgba(22, 33, 62, 0.98) 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.5);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideUp {
    0% {
        transform: translateY(50px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

.event-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 215, 0, 0.3);
}

.event-history-title {
    font-size: 24px;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.event-history-stats {
    background: rgba(255, 215, 0, 0.1);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.event-history-stats p {
    font-size: 14px;
    color: #ddd;
    margin: 5px 0;
}

.event-history-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.event-history-list::-webkit-scrollbar {
    width: 8px;
}

.event-history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.event-history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 215, 0, 0.3);
    border-radius: 10px;
}

.event-history-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 215, 0, 0.5);
}

.event-history-item {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 12px;
    border-left: 4px solid;
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
}

.event-history-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.event-history-item.rarity-c {
    border-color: #6495ED;
}

.event-history-item.rarity-b {
    border-color: #32CD32;
}

.event-history-item.rarity-a {
    border-color: #FFD700;
}

.event-history-item.rarity-sr {
    border-color: #9370DB;
}

.event-history-item.rarity-ssr {
    border-color: #FF4500;
}

.event-history-item.rarity-curse {
    border-color: #8B0000;
}

.event-order {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 8px;
}

.event-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    font-size: 16px;
}

.event-empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.particle {
    position: absolute;
    pointer-events: none;
    font-size: 24px;
    font-weight: bold;
    animation: float-up 1.2s ease-out forwards;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

@keyframes float-up {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateY(-120px) scale(1.5);
        opacity: 0;
    }
}

.event-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    padding: 25px 35px;
    border-radius: 15px;
    text-align: center;
    z-index: 999;
    min-width: 250px;
    max-width: 500px;
    animation: eventPop 0.5s ease;
    pointer-events: none;
}

@keyframes eventPop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.event-notification.rarity-c {
    border: 3px solid #6495ED;
    box-shadow: 0 0 30px rgba(100, 149, 237, 0.6);
}

.event-notification.rarity-b {
    border: 3px solid #32CD32;
    box-shadow: 0 0 30px rgba(50, 205, 50, 0.6);
}

.event-notification.rarity-a {
    border: 3px solid #FFD700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
}

.event-notification.rarity-sr {
    border: 3px solid #9370DB;
    box-shadow: 0 0 30px rgba(147, 112, 219, 0.6);
}

.event-notification.rarity-ssr {
    border: 3px solid #FF4500;
    box-shadow: 0 0 30px rgba(255, 69, 0, 0.6);
}

.event-notification.rarity-curse {
    border: 3px solid #8B0000;
    box-shadow: 0 0 30px rgba(139, 0, 0, 0.8);
    animation: cursePop 0.5s ease, curseShake 0.5s ease 0.5s;
}

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

@keyframes cursePop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.event-notification h3 {
    font-size: 24px;
    margin-bottom: 10px;
}

.event-notification p {
    font-size: 16px;
    color: #ddd;
    line-height: 1.5;
}

.footer {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 20px;
}

/* 开场剧情页面样式 */
.story-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.5s ease;
    overflow-y: auto;
}

.story-overlay.hidden {
    display: none;
}

.story-container {
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(22, 33, 62, 0.95) 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 0 50px rgba(255, 215, 0, 0.3);
    border: 2px solid rgba(255, 215, 0, 0.5);
    animation: storyPop 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow-y: auto;
    margin: auto;
}

@keyframes storyPop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.story-title {
    font-size: 28px;
    color: #ffd700;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    font-weight: bold;
    animation: titleGlow 2s ease-in-out infinite;
}

@keyframes titleGlow {
    0%, 100% {
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
    50% {
        text-shadow: 0 0 30px rgba(255, 215, 0, 0.9);
    }
}

.story-emoji {
    text-align: center;
    font-size: 60px;
    margin-bottom: 15px;
    animation: bounce 1s ease infinite;
}

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

.story-content {
    font-size: 16px;
    line-height: 1.7;
    color: #ddd;
    text-align: left;
    margin-bottom: 25px;
}

.story-content p {
    margin-bottom: 12px;
}

.story-highlight {
    color: #ffd700;
    font-weight: bold;
}

.story-danger {
    color: #ff6b6b;
    font-weight: bold;
    animation: dangerBlink 1.5s ease-in-out infinite;
}

@keyframes dangerBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.start-btn {
    display: block;
    width: 100%;
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #000;
    border: none;
    padding: 15px 30px;
    font-size: 20px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.5);
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 215, 0, 0.7);
}

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

/* 响应式设计 */
@media (max-height: 700px) {
    .story-container {
        padding: 20px;
    }
    
    .story-title {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .story-emoji {
        font-size: 50px;
        margin-bottom: 10px;
    }
    
    .story-content {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .story-content p {
        margin-bottom: 10px;
    }
    
    .start-btn {
        font-size: 16px;
        padding: 12px 25px;
    }
}

@media (max-width: 600px) {
    .story-container {
        padding: 25px 20px;
    }

    .story-title {
        font-size: 22px;
    }

    .story-emoji {
        font-size: 50px;
    }

    .story-content {
        font-size: 15px;
    }

    .start-btn {
        font-size: 18px;
        padding: 14px 28px;
    }

    .title {
        font-size: 22px;
    }
    .stat-value {
        font-size: 20px;
    }
    .grandpa {
        width: 120px;
        height: 120px;
    }
    .helper {
        width: 100px;
        height: 100px;
    }
    .family-emoji {
        font-size: 100px;
    }
    .helper .family-emoji {
        font-size: 80px;
    }
    .kowtow-btn {
        padding: 12px 20px;
        font-size: 16px;
    }

    .event-history-container {
        padding: 20px;
    }

    .event-history-title {
        font-size: 20px;
    }
}

@media (max-width: 400px) {
    .story-title {
        font-size: 20px;
    }
    
    .story-content {
        font-size: 14px;
    }
    
    .start-btn {
        font-size: 16px;
        padding: 12px 24px;
    }

    .notification {
        padding: 20px;
        min-width: 250px;
    }

    .notification h2 {
        font-size: 24px;
    }

    .notification p {
        font-size: 16px;
    }

    .restart-btn, .view-events-btn {
        font-size: 16px;
        padding: 10px 25px;
    }
}

/* 新增移动端兼容样式 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr; /* 调整为两列 */
        gap: 8px;
        margin-bottom: 15px;
    }



    .stat-card {
        padding: 8px;
    }

    .stat-title {
        font-size: 12px;
        margin-bottom: 3px;
    }

    .stat-value {
        font-size: 18px;
    }

    .stat-info {
        font-size: 10px;
        margin-top: 3px;
    }

    .bar-container {
        height: 16px;
        margin-top: 4px;
    }

    .kowtow-btn {
        padding: 15px 20px;
        font-size: 16px;
    }

    .control-hint {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .game-area {
        margin-bottom: 15px;
    }

    .family-group {
        margin-bottom: 20px;
    }
}

@media (hover: none) {
    .kowtow-btn:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
}