/* Google Fonts */
body {
    font-family: 'Noto Sans JP', "Helvetica Neue", Arial, sans-serif;
    background-color: #f4f6f9;
    color: #333;
    margin: 0;
    padding: 20px;
}

#ranking-app {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #0073aa, #005a87);
    color: #fff;
    padding: 25px 20px;
    text-align: center;
}

.app-header h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.4;
}

.subtitle {
    margin: 8px 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

/* Input Area */
.input-area {
    padding: 20px;
}

.input-section {
    margin-bottom: 25px;
}

.section-title {
    font-size: 0.95rem;
    font-weight: bold;
    color: #0073aa;
    border-left: 4px solid #0073aa;
    padding-left: 10px;
    margin-bottom: 15px;
}

.input-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fdfdfd;
    border: 1px solid #eee;
    padding: 10px 15px;
    border-radius: 8px;
}

.input-label {
    font-size: 0.95rem;
    font-weight: bold;
    color: #444;
}

.note {
    font-size: 0.8em;
    font-weight: normal;
    color: #888;
    margin-left: 4px;
}

/* Qty Control */
.qty-control {
    display: flex;
    align-items: center;
    gap: 5px;
}

.qty-control button {
    width: 44px;
    /* Apple HIG Minimum */
    height: 44px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2rem;
    /* Larger symbol */
    color: #0073aa;
    transition: all 0.2s;
    touch-action: manipulation;
    /* Prevent double-tap zoom */
}

.qty-control button:hover {
    background: #eef7fc;
    border-color: #0073aa;
}

.qty-input {
    width: 40px;
    text-align: center;
    border: none;
    font-size: 1.1rem;
    font-weight: bold;
    background: transparent;
    pointer-events: none;
    /* Controlled by buttons */
}

/* Switches & Options */
.option-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    margin-bottom: 10px;
    background: #fdfdfd;
    border: 1px solid #eee;
    border-radius: 8px;
}

.switch-area {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #cce5ff;
}

.switch-label {
    font-weight: bold;
    color: #005a87;
}

/* Toggle Switch CSS */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    /* bottom-left */
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: #0073aa;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Calculate Button */
.calc-btn-area {
    margin-top: 30px;
}

.calc-btn {
    width: 100%;
    background: #ff9800;
    color: #fff;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 16px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 0 #e65100;
    transition: all 0.1s;
    letter-spacing: 0.1em;
}

.calc-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #e65100;
}

/* Results */
.result-area {
    border-top: 1px solid #eee;
    background: #fafafa;
}

.rank-row {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    background: #fff;
    transition: background 0.2s;
}

.rank-row:last-child {
    border-bottom: none;
}

.rank-badge {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.rank-1 {
    background: #ffd700;
    box-shadow: 0 4px 6px rgba(255, 215, 0, 0.3);
}

.rank-2 {
    background: #c0c0c0;
}

.rank-3 {
    background: #cd7f32;
}

.rank-other {
    background: #eee;
    color: #888;
    font-size: 0.9rem;
}

.shop-info {
    flex: 1;
}

.shop-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 6px;
    display: block;
    text-decoration: none;
}

.shop-name:hover {
    text-decoration: underline;
    color: #0073aa;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.tag {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    color: #fff;
    font-weight: 500;
}

.tag-pack {
    background: #2ecc71;
}

.tag-child {
    background: #e91e63;
}

.tag-ship {
    background: #3498db;
}

.tag-storage {
    background: #9b59b6;
}

.price-area {
    text-align: right;
    min-width: 90px;
}

.total-price {
    font-size: 1.4rem;
    font-weight: bold;
    color: #d32f2f;
}

.sub-price {
    display: block;
    font-size: 0.8rem;
    color: #888;
}

/* Footer Timestamp */
.timestamp-area {
    text-align: right;
    padding: 10px 20px;
    color: #999;
    font-size: 0.8rem;
    background: #fdfdfd;
    border-top: 1px solid #eee;
}

#force-update-btn {
    text-decoration: none;
    color: #999;
    margin-left: 5px;
    font-size: 1rem;
}

#force-update-btn:hover {
    color: #0073aa;
}

/* Share Button */
.tw-share-btn {
    display: inline-block;
    background: #000;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.tw-share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.3);
}

/* Mobile Adjustments */
@media (max-width: 400px) {
    .rank-row {
        flex-direction: column;
        position: relative;
    }

    .rank-badge {
        position: absolute;
        top: 15px;
        left: 15px;
        width: 24px;
        height: 24px;
        font-size: 0.9rem;
    }

    .shop-info {
        padding-left: 35px;
        /* space for badge */
        width: 100%;
    }

    .price-area {
        width: 100%;
        text-align: right;
        border-top: 1px dashed #eee;
        padding-top: 10px;
    }
}