:root {
    --bg: #f0f1f5;
    --bar-bg: rgba(255,255,255,0.92);
    --bar-border: rgba(0,0,0,0.08);
    --group-bg: rgba(0,0,0,0.04);
    --group-hover: rgba(0,0,0,0.07);
    --input-bg: rgba(0,0,0,0.04);
    --border: rgba(0,0,0,0.1);
    --border-focus: #6c6cf8;
    --accent: #6c6cf8;
    --accent2: #8b5cf6;
    --glow: rgba(108,108,248,0.25);
    --glow-soft: rgba(108,108,248,0.1);
    --green: #16a34a;
    --orange: #f7931a;
    --red: #dc2626;
    --text: #1a1a2e;
    --text2: #5a5a78;
    --text3: #9a9ab0;
    --r: 8px;
    --r-lg: 12px;
}

body {
    margin: 0;
    background-color: #f0f0f0;
    overflow: hidden;
    font-family: 'DM Sans', 'Noto Sans JP', sans-serif;
}

.u-hidden {
    display: none;
}

#three-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    display: block;
}

/* ===========================
   Loading Screen
   =========================== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

#loading-screen.hidden {
    display: none;
}

.loading-content {
    text-align: center;
}

/* 3D Cube Stack Container */
.cube-stack-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 30px;
}

.cube-stack {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform: rotateX(-25deg) rotateY(-40deg);
}

/* Cube size and gap */
:root {
    --cube-size: 40px;
    --cube-gap: 2px;
    --cube-total: 42px;
    /* cube-size + gap */
}

/* Individual Loading Cubes */
.loading-cube {
    position: absolute;
    width: var(--cube-size);
    height: var(--cube-size);
    left: 50%;
    top: 50%;
    transform-style: preserve-3d;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Cube faces */
.cube-face {
    position: absolute;
    width: var(--cube-size);
    height: var(--cube-size);
}

.cube-face.front {
    transform: translateZ(calc(var(--cube-size) / 2));
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.3);
}

.cube-face.back {
    transform: translateZ(calc(var(--cube-size) / -2)) rotateY(180deg);
}

.cube-face.top {
    transform: rotateX(90deg) translateZ(calc(var(--cube-size) / 2));
    box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.4);
}

.cube-face.bottom {
    transform: rotateX(-90deg) translateZ(calc(var(--cube-size) / 2));
}

.cube-face.left {
    transform: rotateY(-90deg) translateZ(calc(var(--cube-size) / 2));
}

.cube-face.right {
    transform: rotateY(90deg) translateZ(calc(var(--cube-size) / 2));
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.25);
}

/* Cube 0 - Red */
.cube-0 {
    --offset-x: -0.5;
    --offset-y: 0;
    --offset-z: -0.5;
}

.cube-0 .front {
    background: #dc2626;
}

.cube-0 .back {
    background: #991b1b;
}

.cube-0 .top {
    background: #ef4444;
}

.cube-0 .bottom {
    background: #7f1d1d;
}

.cube-0 .left {
    background: #b91c1c;
}

.cube-0 .right {
    background: #f87171;
}

/* Cube 1 - Orange */
.cube-1 {
    --offset-x: 0.5;
    --offset-y: 0;
    --offset-z: -0.5;
}

.cube-1 .front {
    background: #ea580c;
}

.cube-1 .back {
    background: #9a3412;
}

.cube-1 .top {
    background: #f97316;
}

.cube-1 .bottom {
    background: #7c2d12;
}

.cube-1 .left {
    background: #c2410c;
}

.cube-1 .right {
    background: #fb923c;
}

/* Cube 2 - Yellow */
.cube-2 {
    --offset-x: -0.5;
    --offset-y: 0;
    --offset-z: 0.5;
}

.cube-2 .front {
    background: #ca8a04;
}

.cube-2 .back {
    background: #854d0e;
}

.cube-2 .top {
    background: #eab308;
}

.cube-2 .bottom {
    background: #713f12;
}

.cube-2 .left {
    background: #a16207;
}

.cube-2 .right {
    background: #facc15;
}

/* Cube 3 - Green */
.cube-3 {
    --offset-x: 0.5;
    --offset-y: 0;
    --offset-z: 0.5;
}

.cube-3 .front {
    background: #16a34a;
}

.cube-3 .back {
    background: #166534;
}

.cube-3 .top {
    background: #22c55e;
}

.cube-3 .bottom {
    background: #14532d;
}

.cube-3 .left {
    background: #15803d;
}

.cube-3 .right {
    background: #4ade80;
}

/* Cube 4 - Blue */
.cube-4 {
    --offset-x: -0.5;
    --offset-y: 1;
    --offset-z: -0.5;
}

.cube-4 .front {
    background: #2563eb;
}

.cube-4 .back {
    background: #1e40af;
}

.cube-4 .top {
    background: #3b82f6;
}

.cube-4 .bottom {
    background: #1e3a8a;
}

.cube-4 .left {
    background: #1d4ed8;
}

.cube-4 .right {
    background: #60a5fa;
}

/* Cube 5 - Purple */
.cube-5 {
    --offset-x: 0.5;
    --offset-y: 1;
    --offset-z: -0.5;
}

.cube-5 .front {
    background: #7c3aed;
}

.cube-5 .back {
    background: #5b21b6;
}

.cube-5 .top {
    background: #8b5cf6;
}

.cube-5 .bottom {
    background: #4c1d95;
}

.cube-5 .left {
    background: #6d28d9;
}

.cube-5 .right {
    background: #a78bfa;
}

/* Cube 6 - Pink */
.cube-6 {
    --offset-x: -0.5;
    --offset-y: 1;
    --offset-z: 0.5;
}

.cube-6 .front {
    background: #db2777;
}

.cube-6 .back {
    background: #9d174d;
}

.cube-6 .top {
    background: #ec4899;
}

.cube-6 .bottom {
    background: #831843;
}

.cube-6 .left {
    background: #be185d;
}

.cube-6 .right {
    background: #f472b6;
}

/* Cube 7 - Teal */
.cube-7 {
    --offset-x: 0.5;
    --offset-y: 1;
    --offset-z: 0.5;
}

.cube-7 .front {
    background: #0d9488;
}

.cube-7 .back {
    background: #115e59;
}

.cube-7 .top {
    background: #14b8a6;
}

.cube-7 .bottom {
    background: #134e4a;
}

.cube-7 .left {
    background: #0f766e;
}

.cube-7 .right {
    background: #2dd4bf;
}

/* Cube 8 - Rose */
.cube-8 {
    --offset-x: -0.5;
    --offset-y: 2;
    --offset-z: -0.5;
}

.cube-8 .front {
    background: #e11d48;
}

.cube-8 .back {
    background: #9f1239;
}

.cube-8 .top {
    background: #f43f5e;
}

.cube-8 .bottom {
    background: #881337;
}

.cube-8 .left {
    background: #be123c;
}

.cube-8 .right {
    background: #fb7185;
}

/* Cube 9 - Cyan */
.cube-9 {
    --offset-x: 0.5;
    --offset-y: 2;
    --offset-z: -0.5;
}

.cube-9 .front {
    background: #0891b2;
}

.cube-9 .back {
    background: #155e75;
}

.cube-9 .top {
    background: #06b6d4;
}

.cube-9 .bottom {
    background: #164e63;
}

.cube-9 .left {
    background: #0e7490;
}

.cube-9 .right {
    background: #22d3ee;
}

/* Cube 10 - Lime */
.cube-10 {
    --offset-x: -0.5;
    --offset-y: 2;
    --offset-z: 0.5;
}

.cube-10 .front {
    background: #65a30d;
}

.cube-10 .back {
    background: #3f6212;
}

.cube-10 .top {
    background: #84cc16;
}

.cube-10 .bottom {
    background: #365314;
}

.cube-10 .left {
    background: #4d7c0f;
}

.cube-10 .right {
    background: #a3e635;
}

/* Cube 11 - Fuchsia */
.cube-11 {
    --offset-x: 0.5;
    --offset-y: 2;
    --offset-z: 0.5;
}

.cube-11 .front {
    background: #9333ea;
}

.cube-11 .back {
    background: #6b21a8;
}

.cube-11 .top {
    background: #a855f7;
}

.cube-11 .bottom {
    background: #581c87;
}

.cube-11 .left {
    background: #7e22ce;
}

.cube-11 .right {
    background: #c084fc;
}

/* Active state - cube visible and in position */
.loading-cube.active {
    opacity: 1;
}

/* Floor shadow */
.cube-shadow {
    position: absolute;
    width: 180px;
    height: 180px;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.15) 0%, transparent 70%);
    transform: rotateX(90deg) translateZ(-80px);
    filter: blur(15px);
    left: 50%;
    top: 50%;
    margin-left: -90px;
    margin-top: -90px;
}

/* Loading Text */
.loading-text {
    color: #333;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% {
        content: '';
    }

    25% {
        content: '.';
    }

    50% {
        content: '..';
    }

    75% {
        content: '...';
    }

    100% {
        content: '';
    }
}

/* Progress Bar */
.loading-progress {
    width: 250px;
    margin: 0 auto;
}

.progress-bar {
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    background-size: 200% 100%;
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.progress-text {
    color: rgba(0, 0, 0, 0.5);
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .loading-cube {
        transition: opacity 0.2s;
    }

    .loading-dots::after {
        animation: none;
        content: '...';
    }

    .progress-fill {
        animation: none;
    }
}

/* Header Bar */
.header-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0 12px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1200;
    box-sizing: border-box;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.header-bar.has-king-cube {
    background:
        linear-gradient(90deg, rgba(186, 117, 23, 0.12), rgba(255, 255, 255, 0.97) 32%),
        rgba(255, 255, 255, 0.97);
    box-shadow: 0 2px 8px rgba(44, 44, 42, 0.14), inset 0 -1px 0 rgba(186, 117, 23, 0.22);
}
