:root {
    --primary-color: #10b981;
    --primary-hover: #059669;
    --bg-gradient-start: #f0fdf4;
    --bg-gradient-end: #ecfdf5;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(255, 255, 255, 0.5);
    --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);
    --font-sans: 'Inter', 'Noto Sans JP', sans-serif;
    --accent-color: #34d399;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-gradient-start: #0f172a;
        --bg-gradient-end: #1e293b;
        --text-main: #f9fafb;
        --text-muted: #9ca3af;
        --card-bg: rgba(31, 41, 55, 0.7);
        --border-color: rgba(255, 255, 255, 0.1);
        --shadow-soft: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem;
    position: relative;
    overflow-x: hidden;
}

.background-glob {
    position: absolute;
    top: -10%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.15) 0%, rgba(0, 0, 0, 0) 70%);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
}

.container {
    width: 100%;
    max-width: 600px;
    z-index: 1;
}

/* Simple Header */
.app-header-simple {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 4rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}

.app-header-simple h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.tagline {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Calculator Card */
.calculator-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
}

/* Backpack Visual */
.backpack-visual {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.backpack-size-toggle {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.size-btn {
    padding: 0.5rem 1.25rem;
    border: 2px solid var(--primary-color);
    background: transparent;
    color: var(--primary-color);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.size-btn:hover {
    background: rgba(16, 185, 129, 0.1);
}

.size-btn.active {
    background: var(--primary-color);
    color: white;
}

.backpack-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 220px;
    height: 220px;
    margin: 0 auto 1rem;
}

.backpack-img {
    width: 200px;
    height: auto;
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
    transform-origin: center center;
}

/* ... existing code ... */

/* Emoji overlay container */
.emoji-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-wrap: wrap-reverse;
    /* Stack from bottom up */
    justify-content: center;
    align-items: center;
    gap: 0.25rem;
    width: 120px;
    /* Slightly wider to accommodate larger bag */
    pointer-events: none;
}

.backpack-img.inflate-1 {
    transform: scale(1.03);
}

.backpack-img.inflate-2 {
    transform: scale(1.06);
}

.backpack-img.inflate-3 {
    transform: scale(1.12);
}

.backpack-img.inflate-4 {
    transform: scale(1.18);
}

.backpack-img.inflate-5 {
    transform: scale(1.25);
}

/* Speech bubble */
.speech-bubble {
    position: absolute;
    top: -10px;
    left: -80px;
    background: white;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;

    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    z-index: 10;

    /* Default Hidden State */
    opacity: 0;
    transform: scale(0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Animations */
@keyframes float-up {
    0% {
        transform: translateY(0) scale(0);
        opacity: 0;
    }

    20% {
        opacity: 1;
        transform: translateY(-10px) scale(1.2);
    }

    100% {
        transform: translateY(-40px) scale(0);
        opacity: 0;
    }
}

@keyframes pulse-glow-purple {
    0% {
        filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0));
    }

    50% {
        filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.6));
    }

    100% {
        filter: drop-shadow(0 0 5px rgba(139, 92, 246, 0));
    }
}

.backpack-img.backpack-glow {
    animation: pulse-glow-purple 2s ease-out;
}

.speech-bubble.show {
    opacity: 1;
    transform: scale(1);
}

.speech-bubble::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    border: 8px solid transparent;
    border-left-color: white;
    border-right: none;
}

/* Speech Bubble Levels */
.speech-bubble.level-ok {
    color: #10b981;
}

.speech-bubble.level-warning {
    color: #f59e0b;
}

.speech-bubble.level-danger {
    color: #ef4444;
}

.speech-bubble.level-empty {
    color: #6b7280;
}

.speech-bubble.level-bestfit {
    color: white;
    background: linear-gradient(90deg, #8b5cf6, #ec4899);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    border: none;
}

.speech-bubble.level-bestfit::before {
    border-left-color: #ec4899;
    /* Match the right side of gradient or mix */
}

/* Sparkle effect */
.sparkle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    animation: float-up 1s ease-out forwards;
    box-shadow: 0 0 5px currentColor;
    z-index: 10;
}

/* Sparkle effect */
.sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #8b5cf6;
    border-radius: 50%;
    pointer-events: none;
    animation: sparkle 0.8s ease-out forwards;
}

@keyframes sparkle {
    0% {
        opacity: 1;
        transform: scale(0);
    }

    50% {
        opacity: 1;
        transform: scale(1.5);
    }

    100% {
        opacity: 0;
        transform: scale(0) translateY(-20px);
    }
}

.capacity-fill.best-fit {
    animation: pulse-glow 0.8s ease-in-out;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    }

    50% {
        box-shadow: 0 0 15px 5px rgba(139, 92, 246, 0.4);
    }
}



.emoji-overlay-item {
    font-size: 1.2rem;
    opacity: 0.7;
    animation: fadeInEmoji 0.3s ease-out;
}

@keyframes fadeInEmoji {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 0.7;
        transform: scale(1);
    }
}

.capacity-badge {
    display: none;
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    transition: all 0.3s ease;
}

.capacity-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 999px;
    margin: 0 auto;
    overflow: hidden;
}

.capacity-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 999px;
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
}

.capacity-fill.shake {
    animation: shake 0.15s ease-in-out 2;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

.debug-info {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    display: none;
}

.debug-info.show {
    display: block;
}

.capacity-note {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.65rem;
    color: rgba(107, 114, 128, 0.6);
}

/* Preset Scenarios */
.preset-section {
    margin-bottom: 1.5rem;
}

.preset-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.preset-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.preset-btn:hover {
    background: var(--bg-color);
    transform: translateY(-1px);
}

.preset-btn:active {
    transform: translateY(0);
}

/* Item Section */
.item-section {
    margin-bottom: 1.5rem;
}

.item-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-align: center;
}

/* Perfect Match Card */
.perfect-match-container {
    margin-bottom: 2rem;
    margin-top: 0.5em;
    animation: slide-down 0.5s ease-out;
}

@keyframes slide-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.match-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.match-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: transparent;
    z-index: -1;
    border-radius: 20px;
    opacity: 0;
}

.match-badge {
    background: white;
    color: #8b5cf6;
    border: 2px solid #8b5cf6;
    padding: 0.25rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
    box-shadow: 0 2px 5px rgba(139, 92, 246, 0.2);
}

.match-product {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.match-img {
    width: 140px;
    height: auto;
    object-fit: contain;
    margin-bottom: 1rem;
    /* filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.1)); */
    transition: transform 0.3s ease;
}

.match-card:hover .match-img {
    transform: scale(1.05) rotate(-2deg);
}

.match-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.match-specs {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    background: rgba(0, 0, 0, 0.03);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.match-cta {
    background: var(--text-main);
    color: white;
    text-decoration: none;
    padding: 0.75rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    width: 100%;
}

.match-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.match-cta span {
    margin-left: 0.5rem;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.5em;
}

.item-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem 0.5rem;
    background: rgba(255, 255, 255, 0.6);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 80px;
}

.item-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
}

.item-btn.selected {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.item-btn.selected .item-emoji {
    animation: bounce 0.3s ease;
}

@keyframes bounce {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }
}

.item-emoji {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.item-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}

.item-capacity {
    font-size: 0.55rem;
    color: rgba(107, 114, 128, 0.5);
    margin-top: 0.1rem;
    display: none;
}

.item-capacity.show {
    display: block;
}

/* Capacity Toggle */
.capacity-toggle {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    /* Align right */
    gap: 0.3rem;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.75rem;
    /* Smaller */
    margin-top: 1.5rem;
    opacity: 0.6;
    /* Fainter */
    transition: opacity 0.2s;
}

.capacity-toggle:hover {
    opacity: 1;
}

.capacity-approx-note {
    text-align: right;
    /* Align right */
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
    opacity: 0.6;
    display: none;
}

.capacity-approx-note.show {
    display: block;
}

.capacity-toggle input {
    cursor: pointer;
}

/* Selected Section */
.selected-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(16, 185, 129, 0.05);
    border-radius: 16px;
}

.selected-section h3 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.selected-tag {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Results */
.results-container {
    text-align: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(52, 211, 153, 0.1));
    border-radius: 20px;
    animation: fadeInScale 0.5s ease-out;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.result-main {
    margin-bottom: 1rem;
}

.result-main .result-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.result-main .result-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-alternatives {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.result-alt {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.alt-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.alt-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Affiliate Section */
.affiliate-section {
    margin-bottom: 2rem;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.affiliate-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

.brand-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    justify-items: center;
}

.brand-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

.brand-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-soft);
}

.brand-image-area {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.brand-card h3 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.brand-capacity {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.brand-cta {
    margin-top: auto;
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
}

/* Footer */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 2rem;
}

.app-footer a {
    color: var(--text-muted);
    margin-left: 1rem;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .item-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .item-btn {
        padding: 0.75rem 0.25rem;
        min-height: 70px;
    }

    .item-emoji {
        font-size: 1.5rem;
    }

    .backpack-img {
        width: 140px;
    }

    .result-main .result-value {
        font-size: 2.5rem;
    }
}