/* ポップアップフォーム */
#popup-form-wrapper.popup-form-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    z-index: 1000;
    width: 354px;
    max-width: 90vw;
    transform-origin: bottom right;
}

#popup-form-wrapper .popup-form-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0px 2.68px 2.68px rgba(0, 0, 0, 0.30);
    width: 100%;
    max-width: 354px;
    height: auto;
    min-height: 591px;
    max-height: 94vh;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    animation: popupFormSlideIn 0.3s ease-out;
    transition: height 0.15s ease-out;
}

#popup-form-wrapper .popup-form-container.expanded {
    height: auto !important;
    max-height: 94vh;
    overflow: auto;
    overflow-x: hidden;
    transform-origin: bottom right;
    transition: height 0.15s ease-out;
}

@keyframes popupFormSlideIn {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

#popup-form-wrapper .popup-form-header {
    background: #008BD9;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    position: relative;
    padding: 14px 22px;
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

#popup-form-wrapper .header-image {
    height: 85px;
    object-fit: contain;
    margin: 0 auto;
    max-width: 100%;
}

#popup-form-wrapper .title-section {
    display: flex;
    justify-content: center;
    align-items: baseline;
    white-space: nowrap;
    margin-top: 10px;
}

#popup-form-wrapper .title-free-text {
    color: #F5EF00;
    font-size: 16px;
    font-weight: bold;
}

#popup-form-wrapper .title-download-text {
    color: #F5EF00;
    font-size: 24px;
    font-weight: bold;
}

#popup-form-wrapper .speech-bubble-arrow {
    position: absolute;
    bottom: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 20px solid transparent;
    border-right: 20px solid transparent;
    border-top: 20px solid #008BD9;
    z-index: 1;
}

#popup-form-wrapper .close-btn {
    width: 47px;
    height: 48px;
    position: absolute;
    top: -6px;
    right: -6px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #008BD9;
    z-index: 10;
    border-radius: 50%;
    transition: all 0.2s ease;
    padding: 0;
}

#popup-form-wrapper .close-btn svg {
    width: 47px;
    height: 47px;
    display: block;
    z-index: 10;
}

#popup-form-wrapper .close-btn::before {
    content: '';
    width: 35.25px;
    height: 36px;
    background: white;
    border: 2px solid #008BD9;
    border-radius: 50%;
    position: absolute;
    z-index: -1;
}

#popup-form-wrapper .close-btn:hover {
    transform: scale(1.1);
}

#popup-form-wrapper .form-content {
    width: 100%;
    max-width: 315px;
    height: auto;
    margin: 0 auto;
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: none;
    overflow: visible;
}

#popup-form-wrapper .form-content::-webkit-scrollbar {
    width: 6px;
}

#popup-form-wrapper .form-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#popup-form-wrapper .form-content::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#popup-form-wrapper .form-content::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

#popup-form-wrapper .popup-form-container.expanded::-webkit-scrollbar {
    width: 6px;
}

#popup-form-wrapper .popup-form-container.expanded::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#popup-form-wrapper .popup-form-container.expanded::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#popup-form-wrapper .popup-form-container.expanded::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

#popup-form-wrapper .form-group {
    width: 100%;
    max-width: 247px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

#popup-form-wrapper .label-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

#popup-form-wrapper .form-group label {
    color: #333333;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.28px;
    margin: 0;
}

#popup-form-wrapper .required-badge {
    width: 35px;
    height: 18px;
    background: white;
    border-radius: 3.75px;
    outline: 1.20px #E75400 solid;
    outline-offset: -1.20px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #E75400;
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 0.20px;
}

#popup-form-wrapper .form-group input {
    width: 100%;
    max-width: 247px;
    height: 30px;
    padding: 8px 10px;
    background: #F5FDFF;
    border-radius: 1.34px;
    outline: 0.67px #C5C5C5 solid;
    outline-offset: -0.67px;
    border: 0.67px #C5C5C5 solid;
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    font-size: 14px;
    transition: outline 0.2s ease, border 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
}

#popup-form-wrapper .form-group input:focus {
    outline: 0.67px #008BD9 solid;
    outline-offset: -0.67px;
    border: 0.67px #008BD9 solid;
}

#popup-form-wrapper .form-group input.error {
    background: #FFF5F5;
}

#popup-form-wrapper .form-group input.error:focus {
    outline: 0.67px #E75400 solid;
    outline-offset: -0.67px;
    border: 0.67px #E75400 solid;
}

#popup-form-wrapper .confirm-label {
    color: #4D4D4D;
    font-size: 13px;
    font-weight: 400 !important;
    line-height: 20px;
    letter-spacing: 0.28px;
    margin-top: 1px;
}

body #popup-form-wrapper .form-content .privacy-policy {
    width: 246px;
    margin: 0 auto;
    color: #333333;
    font-size: 10px;
    font-weight: normal;
    line-height: 16px;
    margin-top: 6px;
}

body #popup-form-wrapper .form-content .privacy-policy a {
    color: #008BD9;
    text-decoration: underline;
}

#popup-form-wrapper .form-actions {
    align-self: stretch;
    padding: 16px 0;
    position: relative;
    overflow: visible;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-top: auto;
}

#popup-form-wrapper .submit-btn {
    width: 100%;
    max-width: 270px;
    height: 42px;
    padding: 12px;
    background: #E85DBC;
    box-shadow: 0px 2.68px 3.34px rgba(0, 0, 0, 0.10);
    border-radius: 20px;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: #F5FDFF;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.10);
}

#popup-form-wrapper .submit-btn:hover {
    background: #FFA5E2;
}

#popup-form-wrapper .submit-btn:hover .submit-btn-icon-arrow {
    fill: #FFA5E2;
}

#popup-form-wrapper .error-message {
    color: #E75400;
    font-size: 12px;
    display: none;
    line-height: 1.4;
    padding: 4px 0;
    animation: errorMessageSlideIn 0.3s ease-out;
    min-height: 16px;
}

@keyframes errorMessageSlideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#popup-form-wrapper .thank-you-text {
    color: #333333;
    font-size: 14px;
    font-weight: normal;
    line-height: 21px;
    word-wrap: break-word;
    margin-top: 22px;
    margin-bottom: 24px;
}

#popup-form-wrapper .button-container {
    width: 100%;
    max-width: 315px;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

#popup-form-wrapper .button-content {
    justify-content: center;
    align-items: center;
    gap: 1px;
    display: flex;
    width: 100%;
}

#popup-form-wrapper .download-btn {
    align-self: stretch;
    width: 100%;
    height: 62px;
    background: #E85DBC;
    box-shadow: 0px 4px 5px rgba(0, 0, 0, 0.10);
    border-radius: 40px;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    display: flex;
    cursor: pointer;
    border: none;
    margin: 0 auto;
    padding: 0 20px;
}

#popup-form-wrapper .download-btn:hover {
    background: #FFA5E2;
}

#popup-form-wrapper .download-btn:hover::before {
    border-color: #FFA5E2;
}

#popup-form-wrapper .download-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 35px;
    height: 36px;
    margin-left: auto;
}

#popup-form-wrapper .download-btn-text {
    color: #F5FDFF;
    font-size: 20px;
    font-weight: bold;
    word-wrap: break-word;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.10);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-align: center;
}

#popup-form-wrapper .server-error {
    text-align: center;
    padding: 20px;
    color: #E75400;
}

#popup-form-wrapper .error-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

#popup-form-wrapper .close-error-btn {
    width: 120px;
    height: 42px;
    margin: 15px auto 0;
    background: #6C757D;
    box-shadow: 0px 2.68px 3.34px rgba(0, 0, 0, 0.10);
    border-radius: 20px;
    border: none;
    cursor: pointer;
    display: block;
    color: #F5FDFF;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.10);
    transition: all 0.2s ease;
}

#popup-form-wrapper .close-error-btn::before {
    content: '';
    width: 35px;
    height: 36px;
    background: white;
    border: 2px solid #E85DBC;
    border-radius: 50%;
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: -1;
}

#popup-form-wrapper .close-error-btn:hover {
    background: #5A6268;
}

#popup-form-wrapper .close-error-btn:hover::before {
    border-color: #d54da8;
}

@media (max-width: 768px) {
    #popup-form-wrapper.popup-form-wrapper {
        right: 0;
        left: 0;
        margin: 0 auto;
        max-width: 90vw;
        overflow: hidden;
        position: fixed;
        z-index: 9999;
        bottom: 0;
        top: auto;
    }

    #popup-form-wrapper .popup-form-container {
        width: 100%;
        height: 75vh;
        max-height: 75vh;
        min-height: auto;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        position: relative;
        box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.3) !important;
        -webkit-box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.3) !important;
    }
    
    #popup-form-wrapper .popup-form-header {
        width: 100%;
    }
    
    #popup-form-wrapper .form-content {
        width: 100%;
        height: auto;
        overflow: visible;
        padding-bottom: 20px;
        max-width: none;
    }
    
    #popup-form-wrapper .form-group {
        width: 100%;
    }
    
    #popup-form-wrapper .form-group input {
        width: 100%;
    }
    
    #popup-form-wrapper .button-container {
        width: 100%;
        max-width: none;
        padding: 16px 20px;
    }
    
    #popup-form-wrapper .submit-btn {
        width: 100%;
        max-width: 270px;
        font-size: 16px;
    }

    #popup-form-wrapper .form-actions {
        padding: 16px 0 20px 0;
    }

    #popup-form-wrapper .thank-you-text {
        padding: 0 22px;
    }
}

/* SPのスクロール制御 */
@media (max-width: 768px) {
    body.popup-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
    }
}

/* iOS 調整 */
@supports (-webkit-touch-callout: none) {
    #popup-form-wrapper .form-group input {
        border: 0.67px #C5C5C5 solid !important;
        outline: none !important;
    }
    
    #popup-form-wrapper .form-group input:focus {
        border: 0.67px #008BD9 solid !important;
        outline: none !important;
    }
    
    #popup-form-wrapper .form-group input.error:focus {
        border: 0.67px #E75400 solid !important;
        outline: none !important;
    }
}

#popup-form-wrapper .no-wrap-responsive {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

#popup-form-wrapper .submit-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#popup-form-wrapper .submit-text {
    flex: 1;
    text-align: center;
    margin-right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#popup-form-wrapper .submit-btn-icon {
    flex-shrink: 0;
    margin-left: auto;
    width: 26px;
    height: 26px;
}

#popup-form-wrapper .form-actions .submit-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 270px;
    height: 42px;
    padding: 12px;
    background: #E85DBC;
    box-shadow: 0px 2.68px 3.34px rgba(0, 0, 0, 0.10);
    border-radius: 20px;
    border: none;
    cursor: pointer;
    color: #F5FDFF;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.10);
}

#popup-form-wrapper .form-actions .submit-btn:hover {
    background: #FFA5E2;
}

#popup-form-wrapper .form-actions .submit-btn:hover .submit-btn-icon-arrow {
    fill: #FFA5E2;
}

body #popup-form-wrapper .form-actions .submit-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 270px;
    height: 42px;
    padding: 12px;
    background: #E85DBC;
    box-shadow: 0px 2.68px 3.34px rgba(0, 0, 0, 0.10);
    border-radius: 20px;
    border: none;
    cursor: pointer;
    color: #F5FDFF;
    font-size: 16px;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.10);
}

body #popup-form-wrapper .form-actions .submit-btn .submit-text {
    flex: 1;
    text-align: center;
    margin-right: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #F5FDFF;
    font-size: 16px;
    font-weight: bold;
}

body #popup-form-wrapper .form-actions .submit-btn .submit-btn-icon {
    flex-shrink: 0;
    margin-left: auto;
    width: 26px;
    height: 26px;
}

body #popup-form-wrapper .form-actions .submit-btn:hover {
    background: #FFA5E2;
}

body #popup-form-wrapper .form-actions .submit-btn:hover .submit-btn-icon-arrow {
    fill: #FFA5E2;
}

#popup-form-wrapper .form-content .privacy-policy a {
    display: inline-block;
}

#popup-form-wrapper p#server-error-text {
    font-size: 16px;
    padding: 20px 0;
}

/* 最小化状態 */
#popup-form-wrapper.popup-form-wrapper.minimized {
    height: auto;
    bottom: 20px;
    right: 20px;
}

#popup-form-wrapper.popup-form-wrapper.minimized .popup-form-container {
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: hidden;
    border-radius: 10px;
    background: white;
    display: block;
    transition: none;
}

#popup-form-wrapper.popup-form-wrapper.minimized .popup-form-container:hover {
    transform: none;
    box-shadow: 0px 4px 20px rgba(0, 0, 0, 0.3);
}

#popup-form-wrapper.popup-form-wrapper.minimized .form-content {
    display: none;
}

#popup-form-wrapper.popup-form-wrapper.minimized .close-btn {
    display: flex;
    width: 47px;
    height: 48px;
    background: transparent;
    border: none;
    cursor: pointer;
    justify-content: center;
    align-items: center;
    color: #008BD9;
    z-index: 10;
    border-radius: 50%;
    transition: none;
    padding: 0;
}

#popup-form-wrapper.popup-form-wrapper.minimized .close-btn svg {
    width: 47px;
    height: 47px;
    fill: #008BD9;
}

#popup-form-wrapper.popup-form-wrapper.minimized .close-btn::before {
    content: '';
    width: 35.25px;
    height: 36px;
    background: white;
    border: 2px solid #008BD9;
    border-radius: 50%;
    position: absolute;
    z-index: -1;
}

#popup-form-wrapper.popup-form-wrapper.minimized .close-btn:hover {
    transform: scale(1.1);
}

#popup-form-wrapper.popup-form-wrapper.minimized .popup-form-header {
    background: #008BD9;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

#popup-form-wrapper.popup-form-wrapper.minimized .title-section {
    display: flex;
    background: #FFFFFF;
    padding: 11px 23px;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    justify-content: center;
    align-items: baseline;
}

#popup-form-wrapper.popup-form-wrapper.minimized .title-free-text {
    color: #E85DBC;
    font-size: 16px;
    font-weight: bold;
}

#popup-form-wrapper.popup-form-wrapper.minimized .title-download-text {
    color: #E85DBC;
    font-size: 24px;
    font-weight: bold;
}

#popup-form-wrapper.popup-form-wrapper.minimized .speech-bubble-arrow {
    display: none;
}

#popup-form-wrapper.popup-form-wrapper.minimized .header-image {
    height: auto;
    padding: 14px 22px 0 26px;
}

@media (max-width: 768px) {
    #popup-form-wrapper.popup-form-wrapper.minimized {
        bottom: 10px;
        right: 0;
        left: 0;
        margin: 0 auto;
    }
}

@media (max-width: 375px) {
    #popup-form-wrapper.popup-form-wrapper .title-free-text,
    #popup-form-wrapper.popup-form-wrapper.minimized .title-free-text {
        font-size: 4.2vw;
    }

    #popup-form-wrapper.popup-form-wrapper .title-download-text,
    #popup-form-wrapper.popup-form-wrapper.minimized .title-download-text {
        font-size: 6.4vw;
    }
}

@media (max-width: 768px) {
    #popup-form-wrapper.popup-form-wrapper {
        display: none;
    }
}
