/* ==========================================================================
   Crystal Beads Puzzle - Game Stylesheet (Light Elegant Aesthetic)
   ========================================================================== */

:root {
    --bg-main: #e6ede7;
    --bg-card: rgba(255, 255, 255, 0.92);
    --bg-card-border: rgba(148, 163, 184, 0.35);
    --primary: #7c3aed;
    --primary-light: #6d28d9;
    --primary-glow: rgba(124, 58, 237, 0.25);
    --accent: #ec4899;
    --accent-glow: rgba(236, 72, 153, 0.3);
    --success: #059669;
    --gold: #d97706;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-body: 'Zen Maru Gothic', 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow: hidden;
    font-size: 15px;
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(124, 58, 237, 0.05) 0%, transparent 45%),
        radial-gradient(circle at 90% 90%, rgba(16, 185, 129, 0.06) 0%, transparent 45%),
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.6) 0%, transparent 100%);
}

/* ==========================================================================
   Opening Splash Screen
   ========================================================================== */
.splash-screen {
    position: fixed;
    inset: 0;
    background: #e6ede7;
    background-image: 
        radial-gradient(circle at 50% 40%, rgba(124, 58, 237, 0.12) 0%, transparent 60%),
        radial-gradient(circle at 80% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.08) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
    max-width: 380px;
}

.splash-logo-icon {
    font-size: 3.5rem;
    margin-bottom: 0.8rem;
    animation: floatGlow 2s ease-in-out infinite alternate;
    filter: drop-shadow(0 6px 16px rgba(124, 58, 237, 0.35));
}

@keyframes floatGlow {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-8px) scale(1.08); }
}

.splash-title {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 900;
    letter-spacing: 1.5px;
    background: linear-gradient(135deg, #4338ca, #7c3aed, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.3rem;
}

.splash-subtitle {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 1.8rem;
}

.splash-indicator {
    width: 140px;
    height: 4px;
    background: rgba(148, 163, 184, 0.3);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.splash-progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: var(--radius-full);
    animation: splashProgress 1.4s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}

@keyframes splashProgress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(0); }
}

/* ==========================================================================
   Base Container & Screen Architecture
   ========================================================================== */
.game-container {
    max-width: 520px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 0.4rem 0.5rem;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

.game-screen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.game-screen.active {
    display: flex;
    animation: screenFadeIn 0.3s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Common App Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.9rem;
    min-height: 54px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: var(--radius-md);
    margin-bottom: 0.4rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.brand-title h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: 0.5px;
}

.brand-icon {
    font-size: 1.3rem;
}

.home-header-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Language Switcher Toggle */
.btn-lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.6rem;
    background: rgba(241, 245, 249, 0.9);
    border: 1.5px solid rgba(148, 163, 184, 0.45);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s cubic-bezier(0.25, 1, 0.5, 1);
    color: var(--text-muted);
}

.btn-lang-toggle:hover {
    background: rgba(255, 255, 255, 1);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(124, 58, 237, 0.15);
}

.btn-lang-toggle .lang-opt {
    transition: color 0.2s ease, font-weight 0.2s ease;
}

.btn-lang-toggle .lang-opt.active {
    color: var(--primary);
    font-weight: 900;
}

.btn-lang-toggle .lang-divider {
    color: rgba(148, 163, 184, 0.6);
    font-size: 0.72rem;
}

/* ==========================================================================
   Screen 1: Home Screen
   ========================================================================== */
.home-hero-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.4rem 1.8rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
    text-align: center;
    margin-bottom: 0.3rem;
    overflow: hidden;
}

/* Grade Selection Tabs */
.grade-tabs-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.3rem 0.4rem;
    background: rgba(241, 245, 249, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1.5px solid rgba(203, 213, 225, 0.8);
    border-radius: var(--radius-full);
    margin-bottom: 0.4rem;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.grade-tab-btn {
    appearance: none;
    border: none;
    outline: none;
    padding: 0.35rem 0.85rem;
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--text-muted);
    background: transparent;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.25, 1, 0.5, 1);
    white-space: nowrap;
}

.grade-tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.6);
}

.grade-tab-btn.active {
    color: #ffffff;
    background: linear-gradient(135deg, #7c3aed, #4338ca);
    box-shadow: 0 3px 10px rgba(124, 58, 237, 0.35);
    font-weight: 900;
    transform: translateY(-1px);
}

.collection-grade-tabs {
    margin: 0.3rem auto 0.6rem;
    max-width: 320px;
}

/* Centered Stage Hero Container */
.home-stage-hero-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 2.5rem 1rem;
}

.stage-selector-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    width: 100%;
    max-width: 360px;
}

.stage-badge-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-width: 180px;
}

.btn-icon-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #e2e8f0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.btn-icon-nav:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.35);
    border-color: rgba(167, 139, 250, 0.6);
    color: #ffffff;
    transform: scale(1.08);
}

.btn-icon-nav:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-icon-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.stage-cleared-tag {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    display: none;
    align-items: center;
    gap: 0.3rem;
}

.stage-cleared-tag.is-cleared {
    display: inline-flex;
    background: rgba(16, 185, 129, 0.16);
    border: 1px solid rgba(52, 211, 153, 0.4);
    color: #34d399;
}

.next-stage-badge {
    font-family: var(--font-heading);
    font-size: clamp(2.8rem, 8.5vw, 4rem);
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #1e293b 0%, #4338ca 45%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.1;
    filter: drop-shadow(0 4px 18px rgba(124, 58, 237, 0.18));
}

.next-stage-badge.coming-sometime {
    font-size: clamp(1.8rem, 5.5vw, 2.7rem);
    letter-spacing: 1.5px;
    background: linear-gradient(135deg, #475569 0%, #6366f1 50%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 14px rgba(99, 102, 241, 0.2));
}

.home-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-width: 320px;
}

.btn-play-huge {
    padding: 0.95rem 1.4rem;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

.play-icon {
    font-size: 1.2rem;
}

.btn-collection-link {
    background: #ffffff;
    border: 1.5px solid rgba(148, 163, 184, 0.4);
    color: var(--text-main);
    padding: 0.75rem 1.2rem;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 800;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.btn-collection-link:hover {
    background: #f8fafc;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.12);
}

/* ==========================================================================
   Screen 2: Gameplay Layout
   ========================================================================== */
.header-stage-info {
    display: flex;
    align-items: center;
}

.game-stage-title,
.current-stage-chip {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: 0.5px;
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
}

.header-right-tools {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.capsule-progress-badge {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-main);
    font-weight: 800;
}

.capsule-progress-badge .count-popped {
    color: var(--primary);
    font-size: 1.35rem;
    font-weight: 900;
    letter-spacing: 0.5px;
}

.capsule-progress-badge .sep {
    color: rgba(100, 116, 139, 0.45);
    margin: 0 1px;
    font-size: 1.1rem;
}

.capsule-progress-badge .count-total {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-icon-tool {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-icon-tool:hover {
    background: #ffffff;
    transform: scale(1.08);
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-icon-tool:active {
    transform: scale(0.92);
}

/* Main Bead Puzzle Viewport: Board + Stock Area Below */
.game-viewport.bead-layout {
    flex: 1;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    position: relative;
    overflow: hidden;
    padding: 0.1rem 0;
}

/* Unified Board + Stock Unit */
.game-board-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    box-sizing: border-box;
    flex: 0 0 auto;
}

/* 1. Bead Board Frame (スタイリッシュ・スリム装飾枠 / 角丸なし) */
.bead-board-frame {
    flex: 0 0 auto;
    min-height: 0;
    min-width: 0;
    position: relative;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: var(--board-aspect, 26 / 38);
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 0;
    overflow: visible;
    box-shadow: 
        0 10px 25px -4px rgba(15, 23, 42, 0.18),
        0 4px 10px -2px rgba(15, 23, 42, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.8) inset;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* 外側と内側のスタイリッシュなスリム装飾フレーム */
.bead-board-frame::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 1px solid rgba(71, 85, 105, 0.4);
    pointer-events: none;
    z-index: 10;
}

.bead-board-frame::after {
    content: '';
    position: absolute;
    inset: 1px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    pointer-events: none;
    z-index: 10;
}

#beadCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: pointer;
    touch-action: none;
}

/* 2. Stock Area Card (画像下のストックエリア) */
.stock-area-card {
    width: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1.5px solid rgba(148, 163, 184, 0.45);
    border-radius: 0;
    padding: 0.35rem 0.4rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.stock-lanes-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

/* Individual Color Dedicated Lane (Horizontal 20-slot bar) */
.stock-lane {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 3px 4px;
    border-radius: 6px;
    border: 1.5px dashed rgba(148, 163, 184, 0.65);
    background: rgba(248, 250, 252, 0.65);
    cursor: pointer;
    box-sizing: border-box;
    position: relative;
    transition: border 0.3s cubic-bezier(0.25, 1, 0.5, 1), 
                box-shadow 0.3s cubic-bezier(0.25, 1, 0.5, 1),
                background 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.stock-lane:hover {
    background: rgba(255, 255, 255, 0.92);
}

/* Lane has assigned bead color: Solid border with color fade! */
.stock-lane.has-color {
    border-style: solid;
    border-width: 2px;
    border-color: var(--lane-border-color, #f43f5e);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px var(--lane-glow-color, rgba(244, 63, 94, 0.25));
}

.stock-lane-slots {
    display: grid;
    grid-template-columns: repeat(24, 1fr);
    gap: 2px;
    justify-items: center;
    align-items: center;
    width: 100%;
}

.stock-slot {
    width: 100%;
    max-width: 16px;
    aspect-ratio: 1;
    border-radius: var(--radius-full);
    background: radial-gradient(circle at 50% 50%, #e2e8f0 0%, #cbd5e1 100%);
    border: 1px solid rgba(100, 116, 139, 0.3);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    pointer-events: none; /* Clicking lane is handled on parent lane level */
}

.stock-slot .stock-bead {
    width: 86%;
    height: 86%;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.25);
    box-shadow: 
        1px 2px 4px rgba(0, 0, 0, 0.45),
        inset -1px -1px 3px rgba(0, 0, 0, 0.45);
    position: relative;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stock-slot .stock-bead::after {
    display: none;
}

/* Sparkle Layer */
.sparkle-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
}

/* Flying Bead Travel FX */
.flying-bead-fx {
    position: fixed;
    top: 0;
    left: 0;
    width: 14px;
    height: 14px;
    margin-left: -7px;
    margin-top: -7px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 9999;
    box-shadow: 
        1px 2px 4px rgba(0, 0, 0, 0.45),
        inset -1px -1px 3px rgba(0, 0, 0, 0.45);
    transition: transform 0.52s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

.flying-bead-fx::after {
    display: none;
}

/* ==========================================================================
   Screen 3: Collection Screen (4x4 Grid in Descending Order)
   ========================================================================== */
.collection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-back {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.4);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-full);
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: #ffffff;
    border-color: var(--primary);
    transform: translateX(-2px);
}

.collection-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collection-title-wrap h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

.collection-count-badge {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--primary);
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.collection-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: var(--radius-lg);
    padding: 0.8rem;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

.collection-intro {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 0.75rem;
}

/* 4x4 Grid */
.collection-grid-4x4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
    width: 100%;
}

.collection-item {
    aspect-ratio: 26 / 38;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    background: #0f172a;
    border: 1.5px solid #334155;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.collection-item:hover {
    transform: scale(1.06);
    border-color: var(--primary);
    box-shadow: 0 8px 18px rgba(124, 58, 237, 0.25);
    z-index: 5;
}

.collection-item .thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.collection-item .stage-num-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    font-family: var(--font-heading);
    font-size: 0.65rem;
    font-weight: 900;
    color: #ffffff;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 1px 4px;
    border-radius: 3px;
}

.collection-empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.collection-empty-state .empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.6rem;
    opacity: 0.7;
}

.collection-empty-state .empty-title {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.3rem;
}

.collection-empty-state .empty-desc {
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 280px;
}

/* ==========================================================================
   Modals & Lightbox
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.open,
.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #ffffff;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    max-width: 420px;
    width: 100%;
    color: var(--text-main);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.open .modal-card,
.modal-backdrop.active .modal-card {
    transform: scale(1);
}

/* Fullscreen Artwork Lightbox */
.modal-lightbox {
    background: rgba(10, 12, 20, 0.88);
    backdrop-filter: blur(16px);
    padding: 0.8rem;
}

.lightbox-wrapper {
    position: relative;
    max-width: 440px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.btn-close-lightbox {
    position: absolute;
    top: -12px;
    right: -6px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    z-index: 20;
    transition: all 0.2s ease;
}

.btn-close-lightbox:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.1);
}

.lightbox-image-container {
    width: 100%;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #334155;
    background: #0f172a;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.lightbox-img {
    max-width: 100%;
    max-height: 72vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.lightbox-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.6rem 1rem;
    border-radius: var(--radius-md);
    color: #ffffff;
}

.lightbox-info h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
}

/* Menu Modal */
.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.menu-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--text-main);
    font-weight: 700;
}

.btn-close-menu {
    background: rgba(0, 0, 0, 0.06);
    border: none;
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.btn-close-menu:hover {
    background: rgba(0, 0, 0, 0.12);
    color: var(--text-main);
}

.menu-actions-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.menu-action-btn {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-action-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.1);
}

.menu-action-btn .action-icon {
    font-size: 1.8rem;
}

.menu-action-btn .action-text strong {
    display: block;
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.menu-action-btn .action-text p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0;
}

/* Victory Modal */
.victory-card {
    text-align: center;
}

.confetti-icon {
    font-size: 3rem;
    margin-bottom: 0.4rem;
    animation: bounce 1s infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-8px) scale(1.1); }
}

.victory-header h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #d97706, #ec4899, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.4rem;
}

.victory-header p {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 1.2rem;
}

.unlocked-artwork-frame {
    position: relative;
    width: 100%;
    max-width: 240px;
    margin: 0 auto 1.2rem;
    border-radius: 0;
    overflow: hidden;
    border: 2px solid #d97706;
    box-shadow: 0 8px 30px rgba(217, 119, 6, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
}

.unlocked-img {
    max-width: 100%;
    max-height: 260px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.victory-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
}

.stat-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 0.75rem;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-main);
}

.victory-actions-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Game Over Modal */
.gameover-card {
    max-width: 380px;
    text-align: center;
    border: 2px solid #ef4444;
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.25);
}

.gameover-header {
    margin-bottom: 1.5rem;
}

.gameover-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: bounce 1s infinite alternate;
}

.gameover-header h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    color: #ef4444;
    margin-bottom: 0.4rem;
}

.gameover-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.gameover-actions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Rules Modal */
.rules-card {
    max-width: 440px;
}

.rules-header {
    text-align: center;
    margin-bottom: 1.2rem;
}

.rules-icon {
    font-size: 2.2rem;
    margin-bottom: 0.3rem;
}

.rules-header h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--text-main);
    font-weight: 800;
}

.rules-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.4rem;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-md);
}

.rule-badge {
    background: var(--primary);
    color: #ffffff;
    font-family: var(--font-heading);
    font-weight: 800;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.rule-text strong {
    display: block;
    color: var(--text-main);
    font-size: 0.92rem;
    margin-bottom: 2px;
}

.rule-text p {
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.35;
    margin: 0;
}

/* Common Buttons */
.btn {
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn:disabled,
.btn[disabled] {
    opacity: 0.42;
    cursor: not-allowed !important;
    pointer-events: none !important;
    transform: none !important;
    box-shadow: none !important;
    filter: grayscale(0.5);
}

.btn-primary {
    width: 100%;
    padding: 0.85rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    font-size: 1.05rem;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 22px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    width: 100%;
    padding: 0.8rem;
    background: #ffffff;
    border: 1.5px solid rgba(148, 163, 184, 0.4);
    color: var(--text-main);
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-ghost {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.btn-ghost:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.04);
}

.btn-sm {
    width: auto;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Toast */
.toast-box {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
    pointer-events: none;
}

.toast-item {
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    color: #ffffff;
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: toastIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes toastIn {
    from { transform: translateY(20px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ==========================================================================
   Tile Puzzle Workspace & Controls
   ========================================================================== */
.puzzle-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.puzzle-viewport .game-board-unit {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0;
}

.puzzle-canvas-wrapper {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
    background: #0f172a;
    border: 1.5px solid rgba(148, 163, 184, 0.25);
    border-radius: var(--radius-md);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#puzzleCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: grab;
}

#puzzleCanvas.is-panning {
    cursor: grabbing !important;
}

/* Header & Tool Elements */
.brand-logo-mark {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3.5px;
    width: 16px;
    height: 14px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-main);
    border-radius: 1px;
}

.progress-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-right: 3px;
}

.text-icon {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.05rem;
    color: var(--text-main);
}

.action-icon-shape {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.08);
    color: var(--primary);
}

.action-icon-shape .text-symbol {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.15rem;
}

/* Home Brand Emblem */
.home-brand-emblem {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1.5rem auto 1.5rem;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1.5px solid rgba(148, 163, 184, 0.35);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.home-brand-emblem .emblem-symbol {
    animation: floatGlow 2.5s ease-in-out infinite alternate;
    filter: drop-shadow(0 8px 18px rgba(124, 58, 237, 0.3));
    margin-bottom: 0.8rem;
}

.home-brand-emblem .emblem-sub {
    font-family: var(--font-heading);
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 2.5px;
    color: var(--text-muted);
}

/* Pouch System (画面右下の袋) */
.puzzle-pouch-container {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 25;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 6px 16px rgba(0, 0, 0, 0.25));
}

.puzzle-pouch-container:hover {
    transform: translateY(-4px) scale(1.08);
}

.puzzle-pouch-container:active {
    transform: translateY(1px) scale(0.96);
}

.puzzle-pouch-container.pouch-drag-hover {
    transform: scale(1.18);
    filter: drop-shadow(0 0 20px rgba(124, 58, 237, 0.85));
    animation: pouchPulse 0.6s infinite alternate;
}

@keyframes pouchPulse {
    from { transform: scale(1.12); }
    to { transform: scale(1.22); }
}

.pouch-img-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
}

.pouch-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.pouch-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 2;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    font-family: var(--font-heading);
    font-size: 0.78rem;
    font-weight: 900;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.5), 0 0 0 2px #ffffff;
    animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes badgePop {
    0% { transform: scale(0.4); }
    100% { transform: scale(1); }
}

.pouch-label {
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 800;
    color: #4c1d95;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 8px;
    border-radius: var(--radius-full);
    margin-top: -3px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

/* Empty Collection Message */
.collection-empty-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1.5rem;
    text-align: center;
    gap: 0.8rem;
    color: var(--text-muted);
}

.collection-empty-message .empty-icon {
    font-size: 3.5rem;
    opacity: 0.6;
}

.collection-empty-message p {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.6;
}

.victory-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-weight: 600;
}


