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

body {
    font-family: 'Gincu', monospace;
    background: linear-gradient(135deg, #23272b 0%, #3a4147 50%, #3a4147 100%);
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

/* メインメッセージ */
.main-message {
    position: absolute;
    top: 50%;
    left: 48%;
    transform: translate(-50%, -50%) rotate(-2deg);
    text-align: center;
    z-index: 3;
    color: #bdbcb6;
    white-space: nowrap;
}

.error-code {
    font-size: 12rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
    text-shadow:
        0 0 32px #bdbcb6,
        0 0 18px #bdbcb6,
        0 0 8px #bdbcb6,
        0 0 2px #bdbcb6;
    white-space: nowrap;
}

.message-text {
    font-size: 5rem;
    font-weight: 400;
    line-height: 1.5;
    text-shadow:
        0 0 24px #bdbcb6,
        0 0 12px #bdbcb6,
        0 0 4px #bdbcb6;
    white-space: nowrap;
}

.grass {
    position: absolute;
    left: 50px;
    bottom: 0;
    margin: 0;
    padding: 0;
    z-index: 2;
}

.grass img {
    display: block;
    margin: 0;
    padding: 0;
    width: 20%;
    height: auto;
    min-width: 80px;
}

/* 水滴アニメーション */
.water-drops {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.water-drop {
    position: absolute;
    background: #7db8e8;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    opacity: 0;
    box-shadow:
        0 0 8px rgba(125, 184, 232, 0.5),
        inset -2px -2px 4px rgba(255, 255, 255, 0.4),
        inset 1px 1px 2px #ffffff99;
}

#broken-display {
    position: absolute;
    bottom: 0;
    right: 10vw;
    width: 8vw;
    height: 3vh;
    z-index: 10;
    transform: skew(-70deg);
    cursor: pointer;
    background: linear-gradient(180deg, #222 60%, #444 100%);
    border: 0.1rem solid #888;
    filter: grayscale(0.5) brightness(0.8) contrast(1.2);
}

#broken-display p {
    color: #bbb;
    font-size: 0.8rem;
    line-height: 0.5rem;
    text-align: center;
    margin-top: 0.2rem;
    user-select: none;
    font-family: monospace;
}

#spark-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.spark-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(0.5px);
    box-shadow: 0 0 6px currentColor;
}

.spark-trail {
    position: absolute;
    width: 1px;
    height: 8px;
    pointer-events: none;
    background: linear-gradient(to bottom, currentColor, transparent);
    opacity: 0.8;
}

@keyframes spark-fade {
    0% {
        opacity: 1;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(0.3);
    }
}

/* DisplayMessenger スタイル */
.message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 10000;
    transition: background 0.3s ease;
}

.message-overlay.visible {
    background: rgba(0, 0, 0, 0.3);
}

.message-window {
    position: fixed;
    right: 3vw;
    bottom: 5vh;
    width: 4px;
    height: 20vh;
    background: #0aa;
    z-index: 10001;
    opacity: 0;
    box-shadow: 0 0 20px #0aa;
    transition: all 0.5s ease-out;
    border-radius: 8px;
    border: 2px solid #0aa;
}

.message-window.expanded {
    width: min(80vw, 800px);
    height: min(40vh, 400px);
    background: linear-gradient(135deg, #001122, #003344);
    opacity: 0.75;
}

.message-content {
    position: absolute;
    top: 0.2rem;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.2rem;
    color: #fff;
    font-family: 'Gincu', monospace;
    font-size: 2rem;
    line-height: 1.6;
    overflow-y: auto;
    padding: 10px;
    opacity: 0;
    transition: opacity 0.3s ease 0.3s;
}

.message-window.expanded .message-content {
    opacity: 1;
}

.close-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    color: #0aa;
    font-size: 4rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: background 0.2s;
    opacity: 0;
    transition: opacity 0.3s ease 0.3s, background 0.2s;
}

.message-window.expanded .close-button {
    opacity: 1;
}

.close-button:hover {
    background: rgba(0, 255, 255, 0.2);
}

.crack {
    position: absolute;
    right: 10vw;
    top: 60px;
    margin: 0;
    padding: 0;
    z-index: 0;
}

.crack img {
    display: block;
    margin: 0;
    padding: 0;
    width: min(20vh, 30vw);
    height: auto;
    min-width: 80px;
}

@keyframes message-flicker {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.message-window.flickering {
    animation: message-flicker 0.1s ease-in-out;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .main-message {
        left: 50%;
        top: 45%;
    }

    .error-code {
        font-size: 5rem;
    }

    .message-text {
        font-size: 2rem;
    }

    .grass img {
        width: 100px;
        min-width: 80px;
        max-width: 120px;
        /* モバイル上限追加 */
    }

    #broken-display {
        right: 15vw;
        width: 15vw;
        min-width: 80px;
        height: 3vh;
        min-height: 35px;
    }
}

@media (max-width: 480px) {
    .error-code {
        font-size: 3rem;
    }

    .message-text {
        font-size: 1.2rem;
    }

    .grass {
        left: 20px;
    }

    .grass img {
        width: 80px;
        min-width: 60px;
        max-width: 100px;
        /* モバイル上限追加 */
    }

    #broken-display {
        right: 10px;
        width: 100px;
        height: 40px;
        min-height: 40px;
    }

    #broken-display p {
        font-size: 0.6rem;
        line-height: 0.4rem;
        margin-top: 0.3rem;
    }
}