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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', Meiryo, sans-serif;
    min-height: 100vh;
    width: 100vw;
    margin: 0;
    overflow-x: hidden;
    
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    
    -webkit-box-align: end;
    -webkit-align-items: flex-end;
    align-items: flex-end;
    
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    
    position: relative;
    padding-bottom: env(safe-area-inset-bottom);
    
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: -1;
    animation: none;
}

@media (min-width: 1000px) and (min-height: 700px) and (orientation: landscape) {
    body::before {
        background-image: url('backgroundDT.jpg');
    }
}

@media (min-width: 1000px) and (min-height: 700px) and (orientation: landscape) and (prefers-reduced-motion: no-preference) {
    body::before {
        animation: slowPan 60s ease-in-out infinite alternate;
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before {
        animation: none !important;
    }
}

@keyframes slowPan {
    0% {
        transform: scale(1.1) translateY(0);
    }
    100% {
        transform: scale(1.1) translateY(-5%);
    }
}

/* Language Selector */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1000;
    padding: 10px;
    background-color: rgba(50, 50, 50, 0.7);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.lang-btn {
    background: transparent;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover {
    border-color: rgba(232, 212, 184, 0.5);
    transform: scale(1.05);
}

.lang-btn:focus {
    outline: 2px solid #e8d4b8;
    outline-offset: 2px;
}

.lang-btn img {
    display: block;
    border-radius: 2px;
}

/* English button image states */
.lang-btn[data-lang="en"] .lang-default {
    display: block;
}

.lang-btn[data-lang="en"] .lang-pressed {
    display: none;
}

.lang-btn[data-lang="en"].active .lang-default {
    display: none;
}

.lang-btn[data-lang="en"].active .lang-pressed {
    display: block;
}

/* Japanese button always shows same image */
.lang-btn[data-lang="ja"].active {
    border-color: rgba(232, 212, 184, 0.8);
}

/* Language content visibility */
.lang-content {
    display: none;
}

.lang-content.active {
    display: block !important;
}

/* Mobile adjustments for language selector */
@media (max-width: 480px) {
    .language-selector {
        top: 10px;
        right: 10px;
        padding: 8px;
        gap: 8px;
    }
    
    .lang-btn img {
        width: 35px;
        height: 26px;
    }
}

/* Content Wrapper - Contains both credits and coffee button */
.content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    width: 90%;
    max-width: 400px;
}

.credits-container {
    width: 100%;
    max-height: 50dvh;
    max-height: 45vh;
    background-color: rgba(50, 50, 50, 0.85);
    padding: 25px 30px;
    border-radius: 12px;
    text-align: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid transparent;
    position: relative;
}

@supports not (height: 1dvh) {
    .credits-container {
        max-height: 45vh;
    }
}

@supports not (height: 1vh) {
    .credits-container {
        max-height: 300px;
    }
}

.credits-text {
    color: #e0e0e0;
    font-size: 16px;
    line-height: 1.8;
    letter-spacing: 0.5px;
}

/* Japanese text styling */
.lang-content[data-lang="ja"] {
    letter-spacing: 0.05em;
    line-height: 2;
}

#content-ja {
    letter-spacing: 0.05em;
    line-height: 2;
}

.credits-text p {
    margin-bottom: 10px;
}

.credits-text a {
    color: #e8d4b8;
    text-decoration: underline;
    transition: color 0.3s ease;
}

.credits-text a:hover {
    color: #f5e6d3;
}

/* Coffee Button - Outside container */
.coffee-button-wrapper {
    background: rgba(50, 50, 50, 0.85);
    padding: 15px 20px;
    border-radius: 8px;
    text-align: center;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.coffee-button-wrapper img {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    height: auto;
}

.coffee-button-wrapper a {
    text-decoration: none;
    display: inline-block;
    transition: transform 0.2s ease;
}

.coffee-button-wrapper a:hover {
    transform: scale(1.05);
}

@media (max-width: 480px) {
    .content-wrapper {
        width: 95%;
        max-width: 350px;
        gap: 12px;
        margin-bottom: 15px;
    }

    .credits-container {
        padding: 20px 25px;
    }
    
    .credits-text {
        font-size: 14px;
        line-height: 1.7;
    }

    .coffee-button-wrapper {
        padding: 12px 15px;
    }
}

@media (max-width: 360px) {
    .content-wrapper {
        width: 95%;
        max-width: 340px;
    }

    .credits-container {
        padding: 15px 20px;
    }
    
    .credits-text {
        font-size: 13px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .credits-container {
        max-height: 60vh;
        max-height: 60dvh;
    }
    
    .language-selector {
        top: 10px;
        right: 10px;
    }

    .content-wrapper {
        margin-bottom: 10px;
        gap: 10px;
    }

    .coffee-button-wrapper {
        padding: 10px 15px;
    }
}