body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: linear-gradient(270deg, #e66465, #9198e5, #42e695, #e66465);
    background-size: 400% 400%;
    animation: BackgroundGradient 30s ease infinite;
}

#animation-container {
    position: absolute;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 5;
}

.centered-message {
    position: absolute;
    z-index: 6;
    font-size: 5em;
    color: white;
    text-shadow: 2px 2px 4px #000000;
}

.animated-image {
    position: absolute;
    width: 50px;
    height: auto;
    will-change: transform;
}

@keyframes BackgroundGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes rainbowText {
    0%, 100% { color: red; }
    14% { color: orange; }
    28% { color: yellow; }
    42% { color: green; }
    56% { color: blue; }
    70% { color: indigo; }
    84% { color: violet; }
}

.centered-message {
    position: absolute;
    z-index: 6;
    font-size: 5em;
    color: white;
    text-shadow: 2px 2px 4px #000000;
    animation: rainbowText 2s linear infinite, shake 0.2s infinite;
}

.glow {
	animation: glowEffect 0.5s forwards;
    filter: brightness(2.0);
}

.chat-box {
    position: fixed;
    bottom: calc(80px + 20px);
    right: 20px;
    width: 35vw;
    height: 70vh;
    min-width: 300px;
    min-height: 400px;
    max-width: 800px;
    max-height: 800px;
    background: linear-gradient(165deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 10000;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    animation: slideIn 0.3s ease-out;
    transition: width 0.3s ease, height 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.chat-header {
    padding: calc(10px + 0.5vh) calc(15px + 0.5vw);
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.85));
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    color: #fff;
    font-size: calc(16px + 0.3vw);
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.change-name-button {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    padding: 8px 15px;
    border-radius: 15px;
    color: white;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.3s ease;
}

.change-name-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.chat-content {
    flex: 1;
    overflow-y: auto;
    padding: calc(10px + 1vh);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-message {
    margin-bottom: 10px;
    padding: calc(8px + 0.5vh) calc(10px + 0.5vw);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s ease;
    font-size: calc(14px + 0.2vw);
}

.chat-message:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.message-username {
    font-weight: bold;
    color: #4ECDC4;
    margin-right: 10px;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
}

.message-time {
    font-size: 0.8em;
    color: rgba(255, 255, 255, 0.5);
}

.message-text {
    margin-top: 8px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

.chat-input {
    padding: calc(10px + 0.5vh);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 20px 20px;
}

.chat-input form {
    display: flex;
    gap: 10px;
}

.chat-input input {
    flex-grow: 1;
    padding: calc(8px + 0.3vh) calc(10px + 0.3vw);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    color: white;
    font-size: calc(14px + 0.2vw);
    transition: all 0.3s ease;
}

.chat-input input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.2);
}

.chat-input button {
    font-size: calc(14px + 0.2vw);
    padding: calc(8px + 0.3vh) calc(15px + 0.3vw);
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    border-radius: 15px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.chat-input button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    background: linear-gradient(45deg, #FF8E8E, #6EE7E0);
}

/* スクロールバーのカスタマイズ */
.chat-content::-webkit-scrollbar {
    width: 6px;
}

.chat-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-content::-webkit-scrollbar-thumb {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border-radius: 3px;
    border: 2px solid rgba(0, 0, 0, 0.2);
}

/* 管理者関連のスタイル */
.admin-badge {
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-right: 10px;
}

.admin-status {
    display: flex;
    align-items: center;
}

.admin-login, .admin-logout {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.3s ease;
}

.admin-login:hover, .admin-logout:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* チャットボタンのスタイルを修正 */
.chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 25px;
    font-size: 16px;
    min-width: 200px;
    max-width: 300px;
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    animation: buttonPulse 2s infinite;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    background: linear-gradient(45deg, #FF8E8E, #6EE7E0);
}

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

/* チャットボタンのテキストスタイル */
.chat-button span {
    font-size: 1em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 名前入力画面のスタイル */
.username-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    margin: 20px;
    z-index: 10002;
}

.username-prompt h4 {
    color: #fff;
    margin: 0;
    font-size: 1.1em;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.username-prompt input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    color: white;
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    outline: none;
}

.username-prompt button {
    padding: 12px 30px;
    background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
    border: none;
    border-radius: 15px;
    color: white;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    min-height: 44px;
}

.username-prompt button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    background: linear-gradient(45deg, #FF8E8E, #6EE7E0);
}

/* Turnstileモーダルのスタイル */
.captcha-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10003;
}

.captcha-content {
    background: rgba(0, 0, 0, 0.9);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.captcha-content h3 {
    color: white;
    margin-bottom: 15px;
}

.cancel-button {
    margin-top: 15px;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    color: white;
    cursor: pointer;
}

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

/* タッチデバイス用の調整を強化 */
@media (hover: none) and (pointer: coarse) {
    .chat-button,
    .change-name-button,
    .username-prompt button,
    .chat-input button {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        min-height: 44px;
        min-width: 44px;
    }

    .chat-input input,
    .username-prompt input {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        -webkit-tap-highlight-color: transparent;
    }

    /* タップ時のフィードバック */
    .chat-button:active,
    .change-name-button:active,
    .username-prompt button:active,
    .chat-input button:active {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* iPhoneのセーフエリア対応 */
@supports (padding: max(0px)) {
    .chat-box {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }

    .chat-button {
        bottom: max(15px, env(safe-area-inset-bottom));
    }
}

/* iPhoneのノッチ対応 */
@supports (padding: max(0px)) {
    @media screen and (max-width: 768px) {
        .chat-box {
            padding-top: max(0px, env(safe-area-inset-top));
            padding-bottom: max(0px, env(safe-area-inset-bottom));
        }
        
        .chat-header {
            padding-top: max(15px, env(safe-area-inset-top));
        }
        
        .chat-input {
            padding-bottom: max(15px, env(safe-area-inset-bottom));
        }
    }
}

/* タッチデバイス用の調整 */
@media (hover: none) and (pointer: coarse) {
    input[type="text"],
    input[type="submit"],
    button {
        font-size: 16px !important;
        touch-action: manipulation;
    }

    .chat-content {
        -webkit-overflow-scrolling: touch;
    }

    /* タップ時のハイライトを無効化 */
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* タッチデバイス用の調整 */
@media (hover: none) and (pointer: coarse) {
    .username-prompt input,
    .username-prompt button {
        font-size: 16px !important;
        touch-action: manipulation;
    }

    .username-prompt button:active {
        opacity: 0.7;
    }
}

/* タッチデバイス用の入力フィールドとボタンの調整 */
@media (hover: none) and (pointer: coarse) {
    .chat-input input {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        font-size: 16px !important;
        padding: 12px;
        border-radius: 8px;
        touch-action: manipulation;
    }

    .chat-input button {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        min-height: 44px;
        min-width: 44px;
        font-size: 16px !important;
        touch-action: manipulation;
        cursor: pointer;
    }

    .chat-input button:active {
        opacity: 0.7;
    }

    /* タップ時のハイライトを無効化 */
    .chat-input * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* 大画面用の調整 */
@media screen and (min-width: 1600px) {
    .chat-box {
        width: 30vw;
        height: 65vh;
        bottom: calc(80px + 20px);
        right: 30px;
    }

    .chat-button {
        right: 30px;
    }
}

/* 中画面用の調整 */
@media screen and (max-width: 1200px) {
    .chat-box {
        width: 45vw;
        height: 75vh;
        bottom: calc(50px + 20px);
        right: 20px;
    }

    .chat-button {
        left: auto;
        width: auto;
        min-width: 180px;
        margin: 0;
    }
}

/* 小画面用の調整 */
@media screen and (max-width: 768px) {
    .chat-box {
        width: calc(100vw - 40px);
        height: 70vh;
        bottom: calc(60px + 15px);
        right: 20px;
        min-width: auto;
    }

    .chat-button {
        left: 20px;
        right: 20px;
        width: auto;
        min-width: auto;
        max-width: none;
        margin: 0;
        font-size: 14px;
        white-space: normal;
        line-height: 1.2;
        bottom: 15px;
    }
}

/* さらに小さい画面用の調整 */
@media screen and (max-width: 480px) {
    .chat-box {
        width: calc(100vw - 20px);
        height: 65vh;
        right: 10px;
        bottom: calc(50px + 10px);
    }

    .chat-button {
        left: 10px;
        right: 10px;
        padding: 8px 10px;
        font-size: 13px;
        height: auto;
        min-height: 35px;
        bottom: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* 超小型画面用の調整 */
@media screen and (max-width: 320px) {
    .chat-box {
        width: calc(100vw - 10px);
        height: 60vh;
        right: 5px;
        bottom: calc(40px + 5px);
    }

    .chat-button {
        left: 5px;
        right: 5px;
        padding: 6px 8px;
        font-size: 12px;
        min-height: 30px;
        bottom: 5px;
    }

    .chat-header {
        padding: 8px 12px;
    }

    .chat-header h3 {
        font-size: 14px;
    }

    .chat-input {
        padding: 8px;
    }

    .chat-input input {
        font-size: 12px;
        padding: 6px 10px;
    }

    .chat-input button {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* 縦向き画面の調整 */
@media screen and (orientation: portrait) {
    .chat-box {
        height: 60vh;
    }
}

/* 横向き画面の調整 */
@media screen and (orientation: landscape) {
    .chat-box {
        height: calc(100vh - 80px);
        bottom: 50px;
    }

    .chat-button {
        bottom: 10px;
    }
}
