:root {
    /* Colors */
    --bg-color: #0a0a0a;
    --card-bg: #141414;
    --text-primary: #ffffff;
    --text-secondary: #a1a1a1;
    --accent: #ffffff;
    --border-color: rgba(255, 255, 255, 0.06);
    --glass-bg: rgba(20, 20, 20, 0.7);

    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;

    /* Spacing */
    --section-padding: 180px 40px;
    --container-max-width: 1200px;

    /* Transitions */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Liquid Nav Runtime Variables */
    --nav-progress: 0;
    --nav-lag-y: 0px;
    --nav-stretch-x: 1;
    --nav-stretch-y: 1;
    --nav-sway-x: 0px;
    --nav-bottom-offset: 8px;
    --nav-compact-width: 108px;
    --nav-expanded-width: 208px;
    --nav-width-delta: 100px;
    --theme-burst-layer: none;
}

[data-theme="light"] {
    --bg-color: #f7f7f7;
    --card-bg: #eaeaea;
    --text-primary: #121212;
    --text-secondary: #555555;
    --accent: #000000;
    --border-color: rgba(0, 0, 0, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.85);
}

[data-theme="rainbow"] {
    --bg-color: #1a0b2e;
    /* A perfectly balanced, full-spectrum rainbow gradient */
    --bg-gradient: linear-gradient(90deg,
            #ff2a2a,
            /* Red */
            #ff7a00,
            /* Orange */
            #ffc900,
            /* Yellow */
            #2eea2e,
            /* Green */
            #00a8ff,
            /* Blue */
            #8a2be2,
            /* Indigo */
            #e056fd,
            /* Violet */
            #ff2a2a
            /* Red (Required for seamless looping) */
        );
    /* Very wide background so we only see a portion of the gradient at a time */
    --bg-size: 800% 100%;
    /* Smooth, linear, infinite scrolling */
    --bg-anim: rainbowMotion 20s linear infinite;
    --card-bg: rgba(0, 0, 0, 0.75);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.85);
    --accent: #ffffff;
    --border-color: rgba(255, 255, 255, 0.2);
    /* Dark, highly-blurred glass to let color through but keep text readable */
    --glass-bg: rgba(10, 10, 15, 0.6);
}

/* Scroll horizontally across the giant background to reveal all colors smoothly */
@keyframes rainbowMotion {
    0% {
        background-position: 100% 0%;
        /* Start at the end (Red) */
    }

    100% {
        background-position: 0% 0%;
        /* Scroll backwards through to the start (Red) */
    }
}

/* Submenu Popup Styles */
.submenu-container {
    position: fixed;
    bottom: calc(var(--nav-bottom-offset, 8px) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(18px) scale(0.86);
    transform-origin: 50% 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    filter: blur(6px);
    transition: transform 0.48s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.34s ease,
        border-radius 0.48s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.34s ease;
}

.submenu-container.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(-10px) scale(1);
    filter: blur(0px);
}

.submenu-container.closing {
    pointer-events: none;
}

.submenu-container.morphing {
    will-change: transform, opacity, border-radius, filter;
}

.submenu-item {
    padding: 12px 24px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

.submenu-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(5px);
}

.submenu-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.submenu-item .nav-icon {
    width: 20px;
    height: 20px;
    margin-bottom: 0;
}

.current-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.current-indicator.hidden {
    display: none !important;
}


* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

body {
    background-color: var(--bg-color);
    background-image: var(--theme-burst-layer, none), var(--bg-gradient, none);
    background-size: auto, var(--bg-size, auto);
    animation: none, var(--bg-anim, none);
    color: var(--text-primary);
    font-family: var(--font-main);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

h1,
h2,
h3 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition-smooth);
}

ul {
    list-style: none;
}

.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography Utilities */
.text-secondary {
    color: var(--text-secondary);
}

.uppercase {
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.8rem;
}

/* Section Layout */
section.container {
    padding: 240px 20px;
}

/* Premium Components */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-color);
}

.button {
    display: inline-block;
    padding: 12px 32px;
    border: 1px solid var(--text-primary);
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.button:hover {
    background: var(--text-primary);
    color: var(--bg-color);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.8s ease-out forwards;
}

/* Hero Headline Language Crossfade */
.hero-headline {
    overflow: hidden;
}

.headline-text {
    display: block;
    transition: opacity 0.6s ease, transform 0.6s ease, filter 0.6s ease;
}

.headline-en {
    animation: headlineFadeEN 10s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.headline-jp {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    animation: headlineFadeJP 10s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes headlineFadeEN {

    0%,
    42% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }

    48%,
    92% {
        opacity: 0;
        transform: translateY(-12px);
        filter: blur(4px);
    }

    98%,
    100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

@keyframes headlineFadeJP {

    0%,
    42% {
        opacity: 0;
        transform: translateY(12px);
        filter: blur(4px);
    }

    48%,
    92% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }

    98%,
    100% {
        opacity: 0;
        transform: translateY(12px);
        filter: blur(4px);
    }
}

/* Grid System */
.grid {
    display: grid;
    gap: 30px;
}

@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Bottom Navigation (Floating) */
.bottom-nav {
    position: fixed;
    bottom: calc(var(--nav-bottom-offset, 8px) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    width: clamp(var(--nav-compact-width, 108px),
            calc(var(--nav-expanded-width, 208px) - (var(--nav-progress, 0) * var(--nav-width-delta, 100px))),
            var(--nav-expanded-width, 208px));
    max-width: calc(100vw - 24px);
    padding: calc(5px - (var(--nav-progress, 0) * 1.5px)) calc(14px - (var(--nav-progress, 0) * 5px));
    border-radius: 9999px;
    transform: translateX(calc(-50% + var(--nav-sway-x, 0px))) translateY(var(--nav-lag-y, 0px)) scaleX(var(--nav-stretch-x, 1)) scaleY(var(--nav-stretch-y, 1));
    transform-origin: bottom center;
    z-index: 1000;
    display: flex;
    justify-content: center;
    gap: calc(6px * (1 - var(--nav-progress, 0)));
    align-items: center;
    opacity: 1;
    will-change: transform, width, padding, border-radius, opacity, filter;
    transition: width 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        padding 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        border-radius 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.24s ease,
        filter 0.28s ease;
}

#main-nav[data-nav-mode="compact"],
#main-nav[data-nav-mode="submenu"] {
    gap: 0;
}

.bottom-nav.secondary-inactive .nav-secondary {
    pointer-events: none;
}

#main-nav[data-nav-mode="expanded"] {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#main-nav[data-nav-mode="compact"] {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#main-nav[data-nav-mode="submenu"] {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#main-nav.nav-shell-seeded {
    opacity: 0;
    filter: blur(7px);
    transform: translateX(calc(-50% + var(--nav-sway-x, 0px))) translateY(var(--nav-lag-y, 0px)) scale(0.35);
    pointer-events: none;
}

.nav-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    flex: 0 1 auto;
}

.nav-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: 165px;
    overflow: hidden;
    opacity: clamp(0, calc(1 - (var(--nav-progress, 0) * 1.35)), 1);
    transform: translateX(calc(var(--nav-progress, 0) * 10px)) scale(calc(1 - (var(--nav-progress, 0) * 0.16)));
    transform-origin: right center;
    transition: opacity 0.28s ease,
        transform 0.3s cubic-bezier(0.32, 0.72, 0, 1),
        max-width 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

#main-nav[data-nav-mode="compact"] .nav-secondary,
#main-nav[data-nav-mode="submenu"] .nav-secondary {
    max-width: 0;
    opacity: 0;
    transform: translateX(10px) scale(0.84);
    pointer-events: none;
    gap: 0;
}

.nav-divider {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 1px;
}

#menu-toggle,
#lang-toggle,
#theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    outline: none;
    font-family: inherit;
}

#menu-toggle {
    transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#main-nav[data-nav-mode="compact"] #menu-toggle,
#main-nav[data-nav-mode="submenu"] #menu-toggle {
    width: 100%;
    justify-content: center;
    transform: scale(0.98);
}

#main-nav[data-nav-mode="compact"] .current-indicator,
#main-nav[data-nav-mode="submenu"] .current-indicator {
    flex-direction: row;
    gap: 7px;
}

#main-nav[data-nav-mode="compact"] #menu-toggle span,
#main-nav[data-nav-mode="submenu"] #menu-toggle span {
    font-size: 0.72rem;
}

#main-nav[data-nav-mode="compact"] .nav-primary,
#main-nav[data-nav-mode="submenu"] .nav-primary {
    width: 100%;
    justify-content: center;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-secondary);
    opacity: 0.8;
}

.bottom-nav .nav-item>span,
.bottom-nav .nav-item .current-indicator>span {
    line-height: 1;
}

.nav-item.active,
.nav-item:hover {
    color: var(--text-primary);
    opacity: 1;
}

.nav-item:hover .nav-icon {
    transform: scale(1.15);
    transition: transform 0.2s ease;
}

@keyframes wiggle {
    0% {
        transform: scale(1) rotate(0deg);
    }

    15% {
        transform: scale(1.3) rotate(-12deg);
    }

    30% {
        transform: scale(0.85) rotate(10deg);
    }

    45% {
        transform: scale(1.15) rotate(-6deg);
    }

    60% {
        transform: scale(0.95) rotate(4deg);
    }

    75% {
        transform: scale(1.05) rotate(-2deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

.nav-item-wiggle .nav-icon {
    animation: wiggle 0.6s ease-in-out;
}

.nav-icon {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
}

/* Icon Button & Expanding Pill */
.icon-btn {
    position: relative;
    height: 60px;
    min-width: 60px;
    /* Base size as a circle */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 30px;
    /* Liquid pill shape */
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    /* Springy fluid ease */
    border: 1px solid var(--border-color);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-primary);
    cursor: pointer;
    overflow: hidden;
    padding: 0 18px;
    /* Inner padding keeping the 24px SVG centered in a 60px circle */
    white-space: nowrap;
}

.icon-text {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    padding: 0 24px;
    /* Expand padding */
}

[data-theme="light"] .icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn:hover .icon-text {
    max-width: 150px;
    opacity: 1;
    margin-left: 10px;
    /* Push text to the right of the icon */
}

.icon-btn:hover svg {
    animation: wiggle 0.6s ease-in-out;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    padding: 40px;
    border-radius: 16px;
    transform: translateY(0) scale(1);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-container {
    transform: translateY(20px) scale(0.95);
}

.modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

/* Cookie Consent */
.menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 8px 15px;
    opacity: 0.5;
}

.animated-cookie {
    position: fixed;
    bottom: calc(28px + var(--nav-bottom-offset, 8px) + env(safe-area-inset-bottom, 0px));
    /* Aligned vertically with the bottom nav */
    left: 50%;
    margin-left: -25px;
    /* Center alignment */
    z-index: 9999;
    width: 50px;
    height: 50px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    pointer-events: none;
    opacity: 0;
}

.animated-cookie.rolling {
    animation: rollIntoMenu 0.8s cubic-bezier(0.25, 1, 0.3, 1) forwards;
}

@keyframes rollIntoMenu {
    0% {
        transform: translateY(-80px) rotate(0deg) scale(1.5);
        opacity: 0;
    }

    15% {
        opacity: 1;
    }

    75% {
        transform: translateY(-20px) rotate(-360deg) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(10px) rotate(-720deg) scale(0);
        opacity: 0;
    }
}

.cookie-popup {
    position: fixed;
    bottom: calc(var(--nav-bottom-offset, 8px) + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) scale(1) translateY(0);
    width: 320px;
    padding: 24px;
    border-radius: 24px;
    z-index: 1001;
    transform-origin: 50% 100%;
    opacity: 1;
    filter: blur(0);
    transition: transform 0.46s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.34s ease,
        border-radius 0.46s cubic-bezier(0.22, 1, 0.36, 1),
        filter 0.34s ease;
}

@media (prefers-reduced-motion: reduce) {

    .bottom-nav,
    .submenu-container {
        transition-duration: 0.18s !important;
        animation: none !important;
    }

    .nav-item-wiggle .nav-icon {
        animation-duration: 0.25s;
    }
}

.cookie-popup.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) scale(0.35, 0.4) translateY(10px);
    border-radius: 9999px;
    filter: blur(8px);
}

.cookie-pill-btn {
    width: 100%;
    padding: 12px 24px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font-main);
    letter-spacing: 0.03em;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.cookie-pill-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: scale(1.02);
}

.cookie-pill-btn:active {
    transform: scale(0.97);
}

[data-theme="light"] .cookie-pill-btn {
    background: rgba(0, 0, 0, 0.06);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

[data-theme="light"] .cookie-pill-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
    border-radius: 34px;
}

[data-theme="light"] .toggle-switch .slider {
    background-color: rgba(0, 0, 0, 0.2);
}

.toggle-switch .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked+.slider {
    background-color: #4CAF50;
}

.toggle-switch input:focus+.slider {
    box-shadow: 0 0 1px #4CAF50;
}

.toggle-switch input:checked+.slider:before {
    transform: translateX(20px);
}

.toggle-switch.disabled .slider {
    background-color: rgba(76, 175, 80, 0.5);
    cursor: not-allowed;
}

.toggle-switch.disabled .slider:before {
    background-color: rgba(255, 255, 255, 0.7);
}
