:root {
    --primary-color: #2563eb;
    --primary-color-hover: #1d4ed8;
    --secondary-color: #f1f5f9;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --accent-color: #f59e0b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

#app-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 2rem;
}

.app-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* Input Card */
.input-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.input-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.input-header h2 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.input-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.input-control-sm {
    margin-bottom: 0;
    gap: 0.5rem;
}

.qty-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
    background: white;
    font-size: 1.5rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: var(--secondary-color);
    border-color: var(--primary-color);
}

.qty-btn-sm {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
}

.qty-input {
    width: 80px;
    height: 56px;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-color);
    background: var(--bg-color);
}
.qty-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.qty-input-sm {
    width: 60px;
    height: 42px;
    font-size: 1.2rem;
}

/* Breakdown Section */
.breakdown-section {
    background: var(--secondary-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.breakdown-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    text-align: center;
}

.breakdown-hint {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.8rem;
}

.breakdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.breakdown-row + .breakdown-row {
    border-top: 1px solid var(--border-color);
}

.breakdown-label {
    font-size: 1rem;
    font-weight: 500;
    min-width: 80px;
}

.primary-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background-color: var(--primary-color-hover);
}
.primary-btn:active {
    transform: translateY(2px);
}

/* Loading */
.loading-area {
    text-align: center;
    margin-top: 1.5rem;
}
.spinner {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 0.5rem;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results */
.results-title {
    font-size: 1.25rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.size-info {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.ranking-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rank-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s;
    position: relative;
    overflow: hidden;
}
.rank-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.rank-badge {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    border-bottom-right-radius: var(--radius-md);
}

.rank-1 { background: linear-gradient(135deg, #fbbf24, #d97706); } /* Gold */
.rank-2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); } /* Silver */
.rank-3 { background: linear-gradient(135deg, #fca5a5, #b91c1c); } /* Bronze */
.rank-other { background: var(--text-muted); }

.rank-card-content {
    margin-left: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.shop-info {
    flex: 1;
}

.shop-name {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-color);
    text-decoration: none;
    display: inline-block;
    margin-bottom: 0.25rem;
}
.shop-name:hover {
    text-decoration: underline;
}

.plan-name {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-color);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-md);
    display: inline-block;
}

.bag-size-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.price-info {
    text-align: right;
}

.total-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}
.total-price span {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Capacity Hint */
.capacity-hint {
    text-align: center;
    font-size: 0.85rem;
    color: #b45309;
    background: #fef3c7;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
}

/* Footer */
.app-footer {
    margin-top: 3rem;
    text-align: center;
}

#share-area {
    background: #e0f2fe;
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.share-text {
    font-weight: 700;
    color: #0369a1;
    margin-bottom: 1rem;
}

.tw-share-btn {
    display: inline-block;
    background: #000;
    color: white;
    text-decoration: none;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-full);
    font-weight: 700;
    transition: background 0.2s;
}
.tw-share-btn:hover { background: #333; }

.timestamp {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.update-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

/* Guide Character */
.guide-character {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 0.3s;
}

.guide-character img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-md);
    border: 2px solid white;
}

@media (min-width: 768px) {
    .guide-character img {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .guide-character {
        bottom: 0.5rem;
        right: 0.5rem;
    }
    .guide-character img {
        width: 60px;
        height: 60px;
    }
}
