:root {
    /* --- Palette: Sumi & Shinchu (Ink & Brass) --- */
    --c-bg: #0f1012;         /* Deep Sumi */
    --c-bg-sub: #16171a;     /* Lighter Sumi */
    
    /* Surface Colors with Transparency for Washi Effect */
    --c-washi: rgba(35, 36, 40, 0.65); 
    --c-washi-inset: rgba(10, 11, 13, 0.4);
    --c-border: rgba(255, 255, 255, 0.06);
    --c-border-highlight: rgba(255, 255, 255, 0.1);

    /* Text */
    --c-text-main: #e6e6e6;  /* Soft White */
    --c-text-muted: #8c9096; /* Ash Grey */
    
    /* Accents */
    --c-gold: #b7a078;       /* Brass/Dried Bamboo */
    --c-gold-dim: #6e6046;   /* Dark Brass */
    --c-gold-glow: rgba(183, 160, 120, 0.2);
    
    --c-moss: #6a7f58;       /* Aged Moss */
    --c-ember: #cc5d4d;      /* Vermilion */
    
    /* --- Physics & Motion --- */
    /* Custom Ease: Slow start, fast middle, very slow settle */
    --ease-fluid: cubic-bezier(0.2, 0.0, 0.2, 1.0);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    
    --font-serif: 'Zen Old Mincho', serif;
    --font-sans: 'Inter', sans-serif;
    
    /* Dynamic Tilt (Set by JS) */
    --tilt-x: 0deg;
    --tilt-y: 0deg;
}

/* --- Base Reset & Typography --- */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; user-select: none; }

body {
    background-color: var(--c-bg);
    color: var(--c-text-main);
    font-family: var(--font-sans);
    height: 100vh; height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
    background-image: radial-gradient(circle at 50% 100%, #1a1c22 0%, var(--c-bg) 60%);
}

/* Typography Utilities */
.serif-title { font-family: var(--font-serif); font-weight: 500; letter-spacing: 0.15em; }
.text-muted { color: var(--c-text-muted); }
.small-text { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
.tiny { font-size: 0.65rem; opacity: 0.7; display: block; }
.text-gold { color: var(--c-gold); }
.text-moss { color: var(--c-moss); }
.text-ember { color: var(--c-ember); }

/* Vertical Writing (Tategaki) */
.tategaki { 
    writing-mode: vertical-rl; 
    text-orientation: upright; 
    letter-spacing: 0.3em; 
}
.vertical-layout { display: flex; flex-direction: row-reverse; gap: 12px; align-items: flex-start; }

/* Text Gradient for Titles */
.text-gradient {
    background: linear-gradient(to bottom, #fff, #999);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Layers & Backgrounds --- */
#canvas-yuishiki { position: fixed; inset: 0; z-index: -10; pointer-events: none; }

/* Noise Overlay (Washi Texture) */
.noise-overlay {
    position: fixed; inset: 0; z-index: -5; pointer-events: none;
    opacity: 0.07;
    background: transparent;
    filter: url('#washi-noise'); /* Links to SVG filter */
}

.vignette-overlay {
    position: fixed; inset: 0; z-index: -4; pointer-events: none;
    background: radial-gradient(circle at center, transparent 40%, rgba(0,0,0,0.8) 120%);
}

/* --- Layout --- */
.app-container { 
    width: 100%; height: 100%; position: relative; overflow: hidden; 
    display: flex; flex-direction: column; pointer-events: none; 
}
.app-container > * { pointer-events: auto; }

@media (min-width: 768px) {
    body { display: flex; align-items: center; justify-content: center; }
    .app-container { 
        max-width: 450px; height: 92vh; 
        border-radius: 4px; 
        border: 1px solid var(--c-border);
        background: rgba(15, 16, 18, 0.4);
        box-shadow: 0 40px 80px rgba(0,0,0,0.6);
        backdrop-filter: blur(20px);
    }
}

/* --- Washi-Morphism Components --- */
.washi-card {
    background: var(--c-washi);
    backdrop-filter: blur(40px) saturate(90%);
    border: 1px solid var(--c-border);
    border-top: 1px solid var(--c-border-highlight);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.05),
        inset 0 0 40px rgba(0,0,0,0.2),
        0 10px 30px rgba(0,0,0,0.3);
    transition: transform 0.4s var(--ease-fluid), border-color 0.4s;
    position: relative; overflow: hidden;
}

.washi-inset {
    background: var(--c-washi-inset);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.03);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

.divider-line {
    border: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-border-highlight), transparent);
    margin: 20px 0;
    opacity: 0.5;
}

/* Buttons */
.button-primary {
    background: linear-gradient(135deg, var(--c-gold), var(--c-gold-dim));
    color: #1a1a1a; border: none; padding: 18px; border-radius: 6px;
    font-weight: 600; cursor: pointer; font-family: var(--font-serif); 
    font-size: 1rem; letter-spacing: 0.2em;
    box-shadow: 0 4px 20px var(--c-gold-glow);
    transition: all 0.6s var(--ease-fluid);
    position: relative; overflow: hidden;
}
.button-primary:hover {
    box-shadow: 0 8px 30px rgba(183, 160, 120, 0.3);
    transform: translateY(-1px);
}
.button-primary:active { transform: scale(0.98); filter: brightness(0.9); transition-duration: 0.1s; }

.button-start {
    background: transparent; border: 1px solid var(--c-gold); color: var(--c-gold);
    padding: 16px 48px; font-family: var(--font-serif); font-size: 1.1rem;
    letter-spacing: 0.25em; cursor: pointer; transition: 0.5s var(--ease-fluid);
    position: relative; overflow: hidden; border-radius: 4px;
}
.button-start:hover { background: var(--c-gold-glow); letter-spacing: 0.35em; }

.button-outline {
    background: transparent; border: 1px solid var(--c-border);
    color: var(--c-text-main); padding: 14px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center; gap: 10px; 
    cursor: pointer; transition: 0.4s var(--ease-fluid);
}
.button-outline:hover { background: rgba(255,255,255,0.03); border-color: var(--c-text-muted); }

.button-ghost { background: none; border: none; color: var(--c-text-muted); padding: 12px; cursor: pointer; transition: 0.3s; font-size: 0.9rem; letter-spacing: 0.1em; }

.glass-btn {
    background: rgba(255,255,255,0.03); border: 1px solid var(--c-border);
    width: 50px; height: 50px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-text-main); cursor: pointer; transition: 0.4s var(--ease-fluid);
}
.glass-btn:hover { background: rgba(255,255,255,0.08); transform: scale(1.05); }

.glass-icon-btn {
    background: transparent; border: 1px solid var(--c-border);
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: var(--c-text-muted); cursor: pointer; transition: 0.3s;
}
.glass-icon-btn.small { width: 32px; height: 32px; border-radius: 8px; font-size: 0.8rem; }
.icon-btn { background: none; border: none; color: var(--c-text-muted); cursor: pointer; padding: 8px; font-size: 1.1rem; }

/* Inputs */
.input-clean {
    width: 100%; background: none; border: none; 
    border-bottom: 1px solid var(--c-border);
    color: var(--c-gold); font-size: 1.3rem; padding: 12px 0; 
    outline: none; font-family: var(--font-serif);
    transition: border-color 0.5s var(--ease-fluid); border-radius: 0; text-align: center;
}
.input-clean:focus { border-bottom-color: var(--c-gold); }

/* --- Views & Navigation --- */
.view { 
    position: absolute; inset: 0; padding: 0 32px 120px; 
    overflow-y: auto; opacity: 0; pointer-events: none; 
    transition: 0.8s var(--ease-fluid); 
    transform: translateY(15px); display: none; filter: blur(5px);
}
.view.active { opacity: 1; pointer-events: auto; transform: translateY(0); display: block; filter: blur(0); }

.view-header { 
    display: flex; justify-content: space-between; align-items: flex-start; 
    margin-bottom: 40px; padding-top: 60px; padding-bottom: 20px;
    position: sticky; top: 0; z-index: 10; pointer-events: none;
}
.view-header > * { pointer-events: auto; }
.asymmetry-header { align-items: flex-start; }

/* Navigation */
.bottom-nav { 
    position: absolute; bottom: 30px; left: 24px; right: 24px; height: 80px; 
    pointer-events: none; display: flex; justify-content: center; z-index: 100;
}
.nav-links {
    flex-grow: 1; height: 64px;
    background: rgba(15,16,18,0.85); backdrop-filter: blur(30px);
    border: 1px solid var(--c-border); border-radius: 24px;
    display: flex; justify-content: space-around; align-items: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5); pointer-events: auto;
    padding: 0 10px;
}
.nav-item { 
    color: rgba(255,255,255,0.3); font-size: 1.2rem; 
    transition: 0.5s var(--ease-fluid); padding: 12px; 
    position: relative;
}
.nav-item.active { color: var(--c-gold); transform: translateY(-4px); }
.nav-item.active::after {
    content: ''; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; background: var(--c-gold); border-radius: 50%;
    box-shadow: 0 0 8px var(--c-gold);
}
.nav-spacer { width: 60px; }

.fab-container {
    position: absolute; bottom: 32px; left: 50%; transform: translateX(-50%);
    pointer-events: auto;
}
.fab-btn {
    width: 72px; height: 72px; border-radius: 50%;
    background: var(--c-bg); border: 1px solid var(--c-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
}
.fab-icon {
    width: 56px; height: 56px; border-radius: 50%;
    background: #e6e6e6; color: #1a1a1a;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
    transition: 0.4s var(--ease-fluid);
}
.fab-btn:active .fab-icon { transform: scale(0.9); background: var(--c-gold); }

/* --- Specific Views --- */

/* Flow: Gomagi Cards */
.gomagi-stack { display: flex; flex-direction: column; gap: 20px; padding-bottom: 80px; perspective: 1000px; min-height: 200px; }
.gomagi-card {
    width: 100%; min-height: 90px; position: relative;
    background: var(--c-washi);
    border-left: 3px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
    transition: transform 0.1s; touch-action: none;
    transform: rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
    transform-style: preserve-3d;
    cursor: grab;
}
.gomagi-card::before {
    /* Paper texture overlay */
    content: ''; position: absolute; inset: 0; 
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E");
    opacity: 0.3; pointer-events: none;
}
.gomagi-card.touch-active { transform: scale(0.98); box-shadow: 0 20px 40px rgba(0,0,0,0.5); border-left-color: var(--c-gold); z-index: 50; }

.wood-sugi { border-left-color: #5d5348; }
.wood-hinoki { border-left-color: #d1c0a5; }
.wood-kyara { border-left-color: #8c7150; }

/* Hearth */
#hearth-container { display: flex; justify-content: center; margin-bottom: 30px; height: 140px; position: relative; z-index: 5; }
.hearth-circle {
    width: 120px; height: 120px; border-radius: 50%; 
    border: 1px dashed rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: center;
    transition: 0.5s var(--ease-bounce); position: relative; overflow: hidden;
    background: radial-gradient(circle, rgba(20,20,20,0.5), transparent 70%);
}
.hearth-circle.active-drop { 
    border: 1px solid var(--c-ember); transform: scale(1.1); 
    background: rgba(204, 93, 77, 0.05);
    box-shadow: 0 0 50px rgba(204, 93, 77, 0.2);
}
.hearth-inner-glow { position: absolute; inset: 0; background: radial-gradient(circle, #ff5e00 0%, transparent 60%); opacity: 0; transition: 0.3s; mix-blend-mode: screen; }
.active-drop .hearth-inner-glow { opacity: 0.6; }
.hearth-label { opacity: 0.4; transition: 0.3s; font-size: 0.9rem; }
.active-drop .hearth-label { opacity: 0; }

/* Garden */
.garden-wrapper { 
    width: 100%; height: 50vh; border-radius: 4px; 
    position: relative; overflow: hidden; background: #08090a; 
}
.garden-overlay-vignette { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle, transparent 40%, #08090a 100%); z-index: 2; }
.garden-info {
    position: absolute; top: 20px; right: 20px; z-index: 4;
    display: flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,0.4); padding: 6px 14px; border-radius: 20px; 
    border: 1px solid rgba(255,255,255,0.05); backdrop-filter: blur(10px);
}
.online-dot { width: 6px; height: 6px; background: var(--c-gold); border-radius: 50%; box-shadow: 0 0 10px var(--c-gold); animation: pulse 3s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.chart-bars { display: flex; align-items: flex-end; justify-content: space-between; height: 100px; gap: 6px; padding: 0 12px; }
.chart-bar { flex: 1; background: rgba(255,255,255,0.05); border-radius: 2px; transition: height 1.2s var(--ease-fluid); min-height: 2px; }
.chart-bar.active { background: linear-gradient(to top, var(--c-gold-dim), var(--c-gold)); box-shadow: 0 0 15px var(--c-gold-glow); }

/* Dial UI */
.incense-dial-wrapper { display: flex; justify-content: center; height: 240px; }
.incense-dial { width: 220px; height: 220px; border-radius: 50%; position: relative; touch-action: none; cursor: grab; align-self: center; }
.dial-track { position: absolute; inset: 0; border: 1px solid rgba(255,255,255,0.06); border-radius: 50%; pointer-events: none; }
.dial-progress { 
    position: absolute; inset: -1px; border-radius: 50%; 
    background: conic-gradient(var(--c-gold) var(--dial-deg, 90deg), transparent 0); 
    mask: radial-gradient(transparent 69%, black 70%); -webkit-mask: radial-gradient(transparent 69%, black 70%);
    pointer-events: none; opacity: 0.8;
}
.dial-rotator { position: absolute; inset: 0; pointer-events: none; transform: rotate(var(--dial-deg, 0deg)); }
.dial-handle { 
    width: 20px; height: 20px; background: var(--c-bg); border: 2px solid var(--c-gold); 
    border-radius: 50%; position: absolute; top: -10px; left: -10px; 
    box-shadow: 0 0 15px var(--c-gold-glow);
}
.dial-mins-big { font-size: 3.5rem; font-family: var(--font-serif); line-height: 1; }

.wood-options { display: flex; gap: 12px; justify-content: center; }
.wood-btn { 
    width: 60px; height: 100px; border: 1px solid var(--c-border); 
    background: rgba(255,255,255,0.02); color: var(--c-text-muted); border-radius: 4px; 
    cursor: pointer; display: flex; justify-content: center; align-items: center; 
    transition: 0.4s; font-family: var(--font-serif);
}
.wood-btn.active { border-color: var(--c-gold); color: var(--c-gold); background: rgba(183, 160, 120, 0.05); transform: translateY(-4px); }

/* Focus Overlay */
.overlay-fullscreen {
    position: fixed; inset: 0; z-index: 2000; background: #000;
    display: flex; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 1s var(--ease-fluid);
}
.overlay-fullscreen.active { opacity: 1; pointer-events: auto; }
.focus-bg-layer { position: absolute; inset: 0; background: radial-gradient(circle at 50% 100%, #16171a, #000); opacity: 0.95; }
.focus-layout { 
    position: absolute; inset: 0; display: flex; justify-content: center; 
    padding: 40px; z-index: 10; 
}
.focus-meta { position: absolute; top: 15%; right: 10%; text-align: right; }
.incense-interactive-area { width: 100%; height: 100%; display: flex; justify-content: center; align-items: flex-end; padding-bottom: 80px; }
.focus-controls { position: absolute; bottom: 60px; left: 50%; transform: translateX(-50%); z-index: 30; }
.zanshin-layer { 
    position: absolute; inset: 0; z-index: 2020; 
    display: flex; align-items: center; justify-content: center; 
    background: rgba(0,0,0,0.8); backdrop-filter: blur(20px) grayscale(100%); 
    opacity: 0; pointer-events: none; transition: opacity 0.8s; 
}
.zanshin-layer.active { opacity: 1; pointer-events: auto; }
.zanshin-text { font-size: 5rem; letter-spacing: 0.5em; text-shadow: 0 0 50px rgba(183, 160, 120, 0.4); }

/* Enso */
.enso-overlay { cursor: crosshair; }
.enso-guide { 
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); 
    text-align: center; pointer-events: none; opacity: 0.4; 
}

/* Intro & Modals */
.intro-layer { background: var(--c-bg); z-index: 9999; }
.intro-content { text-align: center; display: flex; flex-direction: column; align-items: center; }
.kamon-wrapper { 
    width: 120px; height: 120px; border: 1px solid var(--c-border); border-radius: 50%;
    position: relative; display: flex; align-items: center; justify-content: center;
}
.kamon-symbol { font-family: var(--font-serif); font-size: 3rem; color: var(--c-text-main); }
.enso-loader {
    position: absolute; inset: -4px; border: 1px solid transparent; border-radius: 50%;
    border-top-color: var(--c-gold); animation: spin 4s infinite linear;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

.vertical-title-block { display: flex; gap: 16px; align-items: flex-start; justify-content: center; height: 180px; }
.separator-line.vertical { width: 1px; height: 100%; background: var(--c-border-highlight); }

/* Animation Utils */
.fade-in-up { animation: fadeInUp 1.2s var(--ease-fluid) forwards; opacity: 0; transform: translateY(40px); }
.delay-1 { animation-delay: 0.1s; } .delay-2 { animation-delay: 0.2s; } .delay-3 { animation-delay: 0.4s; }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

.modal-backdrop { 
    position: fixed; inset: 0; background: rgba(0,0,0,0.8); 
    backdrop-filter: blur(15px); z-index: 3000; 
    display: flex; align-items: center; justify-content: center; 
    opacity: 0; pointer-events: none; transition: 0.6s var(--ease-fluid); 
}
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal-container { 
    width: 90%; max-width: 400px; max-height: 80vh; overflow-y: auto;
    transform: translateY(60px) scale(0.95); transition: 0.8s var(--ease-fluid); 
}
.modal-backdrop.active .modal-container { transform: translateY(0) scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--c-border); }

/* Status Dot */
.status-dot { width: 8px; height: 8px; background: #333; border-radius: 50%; transition: 0.3s; }
.status-dot.active { background: var(--c-gold); box-shadow: 0 0 10px var(--c-gold); }

/* Ink Ripple */
.ink-ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(0,0,0,0.4) 0%, transparent 70%);
    pointer-events: none;
    transform: scale(0);
    animation: rippleSpread 1.5s var(--ease-fluid) forwards;
    z-index: 9999;
}
@keyframes rippleSpread {
    0% { transform: scale(0); opacity: 0.6; }
    100% { transform: scale(4); opacity: 0; }
}

/* Toast */
.toast-wrapper { position: fixed; top: 12%; left: 0; right: 0; display: flex; justify-content: center; z-index: 5000; pointer-events: none; }
.toast {
    background: rgba(15, 16, 18, 0.9); backdrop-filter: blur(20px);
    border: 1px solid var(--c-border); padding: 12px 30px; border-radius: 50px;
    font-family: var(--font-serif); color: var(--c-gold); letter-spacing: 0.1em; font-size: 0.9rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    animation: toastPop 0.8s var(--ease-fluid);
}
@keyframes toastPop { from { opacity: 0; transform: translateY(-20px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Cards Face */
.memory-card { width: 240px; height: 340px; margin: 0 auto; position: relative; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.memory-card.flipped { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--c-washi); border: 1px solid var(--c-border); box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.face.back { transform: rotateY(180deg); background: #1a1a1c; border: 1px solid var(--c-gold-dim); }
.card-inner { padding: 30px; text-align: center; }
.card-text { font-family: var(--font-serif); font-size: 1.4rem; line-height: 1.6; }

.toggle-switch {
    background: rgba(255,255,255,0.05); color: #666; 
    padding: 6px 16px; border-radius: 20px; font-size: 0.75rem; 
    cursor: pointer; transition: 0.4s; border: 1px solid transparent;
}
.toggle-switch.active { background: rgba(183, 160, 120, 0.1); color: var(--c-gold); border-color: var(--c-gold-dim); }

.hidden { display: none !important; }
.flex-row { display: flex; } .justify-between { justify-content: space-between; } .justify-center { justify-content: center; } .align-center { align-items: center; } .text-center { text-align: center; }
.full-width { width: 100%; } .flex-grow { flex-grow: 1; }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; } .mt-8 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.25rem; } .mb-2 { margin-bottom: 0.5rem; } .mb-3 { margin-bottom: 0.75rem; } .mb-4 { margin-bottom: 1rem; } .mb-6 { margin-bottom: 1.5rem; } .mb-8 { margin-bottom: 2rem; }
.p-4 { padding: 1rem; } .p-8 { padding: 2rem; } .px-4 { padding-left: 1rem; padding-right: 1rem; } .py-12 { padding-top: 3rem; padding-bottom: 3rem; } .gap-3 { gap: 0.75rem; } .ml-3 { margin-left: 0.75rem; }
.clickable { cursor: pointer; transition: transform 0.2s; } .clickable:active { transform: scale(0.97); }
