/* ===================================================================
 * Wizard Chess 3D — Global Styles & Design System
 * Theme: Obsidian & Gold Cathedral Glassmorphism
 * =================================================================== */

* {
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0b0a0e;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
}

#canvas-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    touch-action: none;
}

#canvas-container canvas {
    touch-action: none;
}

/* Luxury Typography Classes */
.font-regal-en {
    font-family: 'Cinzel Decorative', 'Cinzel', serif;
}
.font-regal-jp {
    font-family: 'Shippori Mincho', serif;
}
.gold-gradient-text {
    background: linear-gradient(180deg, #fff6d6 0%, #f3cf7a 38%, #c99738 78%, #f0ca6d 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 10px rgba(212, 175, 55, 0.28));
}

/* UI Layer Transitions */
.ui-layer {
    position: absolute;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1), transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
#top-hud {
    top: max(1rem, env(safe-area-inset-top));
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
}
#bottom-hud {
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
}
#btn-restore-ui {
    top: max(1rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
}
.ui-layer.ui-hidden-top {
    opacity: 0;
    pointer-events: none !important;
    transform: translateY(-18px);
}
.ui-layer.ui-hidden-bottom {
    opacity: 0;
    pointer-events: none !important;
    transform: translateY(18px);
}
.ui-interactive {
    pointer-events: auto;
}

/* Obsidian & Gold Glassmorphism Panels */
.obsidian-panel {
    background: linear-gradient(145deg, rgba(18, 17, 24, 0.88) 0%, rgba(10, 10, 15, 0.92) 100%);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(218, 178, 85, 0.28);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 238, 185, 0.14);
    color: #f3f4f6;
}
.obsidian-pill {
    background: rgba(15, 15, 20, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(218, 178, 85, 0.24);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border-radius: 9999px;
    color: #f3f4f6;
}

/* Interactive Buttons */
.luxury-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    background: linear-gradient(180deg, rgba(34, 32, 42, 0.85) 0%, rgba(19, 18, 25, 0.92) 100%);
    border: 1px solid rgba(218, 178, 85, 0.22);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    border-radius: 0.75rem;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
    white-space: nowrap;
    touch-action: manipulation;
}
.luxury-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(58, 49, 32, 0.9) 0%, rgba(32, 27, 19, 0.95) 100%);
    border-color: rgba(235, 195, 95, 0.65);
    color: #fff8e7;
    transform: translateY(-1.5px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.65), 0 0 14px rgba(229, 193, 88, 0.22);
}
.luxury-btn:active:not(:disabled) {
    transform: translateY(0px);
}
.luxury-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
}
.luxury-btn.active-mode {
    background: linear-gradient(180deg, rgba(82, 65, 28, 0.92) 0%, rgba(46, 36, 15, 0.96) 100%);
    border-color: rgba(245, 208, 105, 0.85);
    color: #ffe8a3;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6), 0 0 15px rgba(229, 193, 88, 0.3), inset 0 1px 0 rgba(255, 240, 190, 0.25);
}

/* Turn Indicator Gem */
.turn-gem {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    transition: all 0.35s ease;
}
.turn-gem.white-turn {
    background: radial-gradient(circle at 35% 35%, #ffffff, #d8d0c5);
    box-shadow: 0 0 12px #ffffff, 0 0 6px #e5c158;
}
.turn-gem.black-turn {
    background: radial-gradient(circle at 35% 35%, #4a4e69, #12131a);
    border: 1.5px solid #e5c158;
    box-shadow: 0 0 10px rgba(229, 193, 88, 0.65);
}
.turn-gem.check-alert {
    background: radial-gradient(circle at 35% 35%, #ff7b7b, #dc2626);
    box-shadow: 0 0 16px #ef4444, 0 0 6px #ffffff;
    animation: pulse-check 1.1s infinite alternate;
}
@keyframes pulse-check {
    0% { transform: scale(1); }
    100% { transform: scale(1.25); }
}

/* AI Thinking Breathing Pulse on Turn Gem */
.turn-gem.ai-thinking-pulse {
    animation: pulse-thinking 1.2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse-thinking {
    0%, 100% {
        transform: scale(1);
        opacity: 0.85;
        box-shadow: 0 0 10px rgba(229, 193, 88, 0.4);
    }
    50% {
        transform: scale(1.35);
        opacity: 1;
        box-shadow: 0 0 22px rgba(229, 193, 88, 0.95), 0 0 8px #fff8e7;
    }
}

/* Subtle vignette & cinematic grading overlay */
.vignette-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0) 56%, rgba(5,4,8,0.65) 100%);
}

/* Section Divider Label */
.dock-label {
    font-size: 0.65rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #c8a962;
    font-weight: 700;
}

/* Native <dialog> Modal Styling (Modern HTML5 Standard) */
dialog#promotion-dialog {
    margin: auto;
    padding: 0;
    background: transparent;
    border: none;
    outline: none;
    max-width: 28rem;
    width: calc(100% - 2rem);
    z-index: 50;
}

dialog#promotion-dialog::backdrop {
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: dialog-fade-in 0.25s ease-out;
}

dialog#promotion-dialog[open] {
    animation: dialog-pop-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialog-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes dialog-pop-in {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(12px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Responsive Fine-Tuning for Smaller Viewports */
@media (max-width: 1100px) {
    .luxury-btn {
        padding: 0.45rem 0.72rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    #top-hud {
        top: max(0.4rem, env(safe-area-inset-top));
        left: max(0.4rem, env(safe-area-inset-left));
        right: max(0.4rem, env(safe-area-inset-right));
        gap: 0.4rem;
    }
    #bottom-hud {
        bottom: max(0.4rem, env(safe-area-inset-bottom));
        left: max(0.4rem, env(safe-area-inset-left));
        right: max(0.4rem, env(safe-area-inset-right));
    }
    #btn-restore-ui {
        top: max(0.5rem, env(safe-area-inset-top));
        right: max(0.5rem, env(safe-area-inset-right));
    }
    .luxury-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.72rem;
        border-radius: 0.6rem;
    }
}
