body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    line-height: 1.6;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 20px auto;
    padding: 30px;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

h1, h2, h3 {
    color: #005a9c;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

h1 {
    text-align: center;
    font-size: 2.2em;
}

h2 {
    font-size: 1.8em;
    margin-top: 30px;
}

h3 {
    font-size: 1.4em;
    color: #333;
    border-bottom: 1px solid #eee;
    margin-top: 25px;
}

/* 契約書本文 */
.document-content {
    background-color: #fdfdfd;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 20px;
    margin-top: 15px;
    max-height: 400px; /* 長文対策: スクロール可能にする */
    overflow-y: auto;
    font-family: "MS Mincho", "Hiragino Mincho ProN", serif;
}

.document-content p, 
.document-content li,
.document-content div {
    margin-bottom: 1em;
}

.document-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.document-content th, 
.document-content td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
    vertical-align: top;
}

.document-content th {
    background-color: #f9f9f9;
}

/* 同意チェックボックス */
.agreement-check {
    margin-top: 20px;
    padding: 15px;
    background-color: #e6f7ff;
    border: 1px solid #b3e0ff;
    border-radius: 5px;
    font-weight: bold;
}

.agreement-check label {
    cursor: pointer;
    display: flex;
    align-items: center;
}

.agreement-check input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.3);
}

/* 署名欄セクション */
#signature-section {
    margin-top: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #005a9c;
}

.form-group input[type="text"],
.form-group input[type="email"] { /* 便宜上Emailも想定 */
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box; /* パディングを含めて幅100%にする */
    font-size: 1em;
}

.form-group input[type="text"]:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 5px rgba(0,123,255,0.25);
}

/* ★ 修正点: (必須) の文字化け対策 */
.form-group.required label .required-mark {
    color: #d9534f;
    font-weight: normal;
    font-size: 0.9em;
    margin-left: 8px;
}

/* ★ 修正点: 以前の ::after ルールを削除 (HTML側に移動したため) */
/* .form-group.required label::after { ... } */


.form-group-static {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #eee;
}

.form-group-static p {
    margin: 5px 0;
}

/* 署名パッド */
.signature-pad-wrapper {
    position: relative;
    width: 100%;
    height: 250px; /* ★ 修正点: canvasの高さはここで定義 */
    border: 2px dashed #ccc;
    border-radius: 5px;
    background-color: #fff;
    box-sizing: border-box;
    /* ★ 修正点: スマホでのスクロールと署名操作の競合を防ぐ */
    touch-action: none; 
    -ms-touch-action: none;
}

#signature-canvas {
    width: 100%;
    height: 100%;
    /* ★ 修正点: cursor: crosshair を削除 */
    /* cursor: crosshair; */
}

.signature-pad-actions {
    text-align: right;
    margin-top: 10px;
}

.button {
    padding: 10px 18px;
    font-size: 1em;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.button-clear {
    background-color: #f0ad4e;
    color: white;
}
.button-clear:hover {
    background-color: #ec971f;
}

.button-submit {
    background-color: #4CAF50; /* 緑 */
    color: white;
    font-size: 1.2em;
    padding: 15px 30px;
    width: 100%;
    margin-top: 20px;
}

.button-submit:hover {
    background-color: #45a049;
}

.button-submit:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* ------------------------------------------------ */
/* ★ 修正点: 送信中・完了メッセージ (ローディング画面) */
/* ------------------------------------------------ */
#loading-overlay {
    display: none; /* JSで制御 */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 背景を半透明の黒に */
    z-index: 9998;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* 中央に表示するボックス */
.loading-box {
    background-color: #ffffff;
    padding: 30px 40px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 90%;
    width: 400px;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #005a9c;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 0 auto; /* ボックス内で中央寄せ */
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: #333;
}
.loading-subtext {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

/* ------------------------------------------------ */
/* ★ 修正点: 送信中・完了メッセージ (ローディング画面 ここまで) */
/* ------------------------------------------------ */


#message-area {
    margin-top: 20px;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
}
#message-area.success {
    background-color: #dff0d8;
    border: 1px solid #d6e9c6;
    color: #3c763d;
}
#message-area.error {
    background-color: #f2dede;
    border: 1px solid #ebccd1;
    color: #a94442;
}

.download-link {
    display: inline-block;
    margin-top: 15px;
    padding: 12px 25px;
    background-color: #007bff;
    color: #fff;
    text-decoration: none;
    font-weight: bold;
    border-radius: 5px;
}
.download-link:hover {
    background-color: #0056b3;
}

/* レスポンシブ対応 */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 20px;
    }
    h1 { font-size: 1.8em; }
    h2 { font-size: 1.5em; }
    .document-content {
        max-height: 300px;
        padding: 15px;
    }
    .signature-pad-wrapper {
        height: 200px;
    }
    /* ★ 修正点: ローディングボックスも小さく */
    .loading-box {
        width: 85%;
        padding: 25px;
    }
}