/* ============================================================
   基本設定・リセット
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    /* iOSのSafariでフォントサイズが自動調整されるのを防ぐ */
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
                 "Yu Gothic", "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* iOSのSafariでタップ時に青いハイライトが出るのを防ぐ */
    -webkit-tap-highlight-color: transparent;
}

/* ============================================================
   ヘッダー・フッター
   ============================================================ */
.site-header {
    background: #1a3a5c;
    color: white;
    padding: 14px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 800px;
    margin: 0 auto;
}

.site-title {
    color: white;
    text-decoration: none;
    font-size: 1rem;
    font-weight: bold;
}

.site-main {
    flex: 1;
    padding: 20px 16px;
}

.site-footer {
    background: #1a3a5c;
    color: #aaa;
    text-align: center;
    padding: 14px;
    font-size: 0.85rem;
}

/* ============================================================
   共通コンテナ
   ============================================================ */
.page-container {
    max-width: 800px;
    margin: 0 auto;
}

.page-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: #1a3a5c;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid #1a3a5c;
}

/* ============================================================
   トップページ
   ============================================================ */
.top-page {
    max-width: 480px;
    margin: 32px auto;
    text-align: center;
}

.top-title {
    font-size: 1.5rem;
    color: #1a3a5c;
    margin-bottom: 12px;
    line-height: 1.4;
}

.top-subtitle {
    color: #666;
    margin-bottom: 36px;
}

.top-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* ============================================================
   ボタン（最小タッチ領域44px確保）
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 24px;
    border-radius: 10px;
    border: 2px solid transparent;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: opacity 0.15s, transform 0.1s;
    -webkit-appearance: none;
    appearance: none;
}

.btn:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.btn-large {
    min-height: 52px;
    padding: 14px 32px;
    font-size: 1.05rem;
}

.btn-primary {
    background: #1a3a5c;
    color: white;
    border-color: #1a3a5c;
}

.btn-secondary {
    background: white;
    color: #1a3a5c;
    border-color: #1a3a5c;
}

.btn-danger {
    background: #e53e3e;
    color: white;
    border-color: #e53e3e;
}

.btn-mode {
    background: white;
    color: #1a3a5c;
    border-color: #ccc;
    flex: 1;
}

.btn-mode.active {
    background: #1a3a5c;
    color: white;
    border-color: #1a3a5c;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-block {
    display: flex;
    width: 100%;
}

/* ============================================================
   管理メニュー
   ============================================================ */
.admin-menu {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 360px;
    margin: 28px auto;
}

/* ============================================================
   フォームセクション
   ============================================================ */
.form-section {
    background: white;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.section-title {
    font-size: 1rem;
    font-weight: bold;
    color: #1a3a5c;
    margin-bottom: 14px;
}

.section-note {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 12px;
}

.section-label {
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 10px;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 1rem;
    min-height: 44px;
}

.radio-label small {
    font-size: 0.8rem;
    color: #888;
    margin-left: 4px;
}

.mode-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sub-section {
    background: #f8f9fb;
    border-radius: 8px;
    padding: 14px;
    margin-top: 12px;
}

.yearmonth-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    background: white;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #ddd;
    min-height: 44px;
}

/* フォーム入力欄（iOSの自動ズームを防ぐため16px以上） */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 18px;
}

.form-group {
    flex: 1;
    min-width: 140px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px; /* iOSの自動ズーム防止のため16px固定 */
    -webkit-appearance: none;
    appearance: none;
    background: white;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    min-height: 100px;
    resize: vertical;
    -webkit-appearance: none;
}

.form-textarea-sm {
    min-height: 64px;
}

.text-input-row {
    display: flex;
    gap: 12px;
}

.text-input-col {
    flex: 1;
}

.choice-input-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px;
    background: #f8f9fb;
    border-radius: 8px;
}

.radio-correct {
    padding-top: 12px;
    min-width: 28px;
}

.input-number {
    width: 80px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
}

.form-display {
    padding: 10px 12px;
    background: #f0f4f8;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    color: #555;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.form-actions-center {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* ============================================================
   出題画面
   ============================================================ */
.question-label {
    font-size: 0.9rem;
    font-weight: bold;
    color: #1a3a5c;
    text-align: center;
    margin-bottom: 10px;
    letter-spacing: 0.05em;
}

.progress-bar-wrap {
    margin-bottom: 18px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 6px;
}

.timer-display {
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a3a5c;
    min-width: 40px;
    text-align: right;
}

.timer-danger {
    color: #e53e3e !important;
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

.progress-bar {
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #1a3a5c;
    border-radius: 4px;
    transition: width 0.3s;
}

.question-text {
    background: white;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.question-en {
    font-size: 1.05rem;
    line-height: 1.9;
    margin-bottom: 8px;
}

.question-ja {
    color: #666;
    font-size: 0.9rem;
}

/* 単語タップ対象 */
.tap-word {
    display: inline;
    cursor: pointer;
}

/* 解答表示後のみ下線を付けて「タップできる」と分かるようにする */
.answer-revealed .tap-word {
    border-bottom: 1px dotted #1a3a5c;
}

/* 単語タップ時の日本語訳ポップアップ */
.word-popup {
    position: absolute;
    background: #1a3a5c;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    white-space: nowrap;
    z-index: 200;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

.choices-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 18px;
}

.choice-item {
    background: white;
    border-radius: 10px;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: border-color 0.2s;
}

.choice-item.correct-highlight {
    border-color: #38a169;
    background: #f0fff4;
}

.choice-number {
    font-weight: bold;
    color: #1a3a5c;
    font-size: 1.1rem;
    min-width: 24px;
    flex-shrink: 0;
}

.choice-en {
    font-size: 1rem;
    line-height: 1.7;
}

.choice-ja {
    font-size: 0.85rem;
    color: #666;
    margin-top: 4px;
}

/* マークシート */
.marksheet {
    background: white;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.marksheet-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 14px;
}

.marksheet-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.mark-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid #1a3a5c;
    background: white;
    color: #1a3a5c;
    font-size: 1.4rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-appearance: none;
    flex-shrink: 0;
}

.mark-btn.active {
    background: #1a3a5c;
    color: white;
    transform: scale(1.12);
}

.mark-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.practice-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 8px;
}

/* ============================================================
   結果画面
   ============================================================ */
.result-summary {
    display: flex;
    gap: 14px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.result-card {
    flex: 1;
    min-width: 140px;
    background: white;
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.result-label {
    font-size: 0.85rem;
    color: #666;
}

.result-value {
    font-size: 2rem;
    font-weight: bold;
    color: #1a3a5c;
}

.detail-table-wrap {
    background: white;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   テーブル
   ============================================================ */
.table-wrap {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    overflow-x: auto; /* 横スクロール対応 */
}

.data-table,
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 300px;
}

.data-table th,
.detail-table th {
    background: #1a3a5c;
    color: white;
    padding: 12px 14px;
    text-align: center;
    font-weight: bold;
    white-space: nowrap;
}

.data-table td,
.detail-table td {
    padding: 12px 14px;
    text-align: center;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.detail-table td.correct {
    color: #38a169;
    font-weight: bold;
    font-size: 1.2rem;
}

.detail-table td.incorrect {
    color: #e53e3e;
    font-weight: bold;
    font-size: 1.2rem;
}

/* 連絡内容テーブル */
.contacts-table .contact-message {
    text-align: left;
    white-space: pre-wrap;
    word-break: break-all;
    max-width: 240px;
}

/* ============================================================
   英単語確認
   ============================================================ */
.vocab-count {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 12px;
}

.vocab-table th {
    white-space: nowrap;
}

.vocab-word {
    font-weight: bold;
    text-align: left;
}

.vocab-meaning {
    text-align: left;
}

.vocab-stars {
    text-align: center;
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: #d69e2e;
    white-space: nowrap;
}

.sort-link {
    color: white;
    text-decoration: none;
    white-space: nowrap;
}

.sort-link:hover {
    opacity: 0.8;
}

.sort-link.active {
    text-decoration: underline;
}

.btn-speak {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.btn-speak:active {
    background: #e8f0f8;
}

/* ============================================================
   英単語管理（登録・修正）
   ============================================================ */
.vocab-register-header {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    padding: 0 2px;
}

.vocab-col-label {
    flex: 1;
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
}

.vocab-col-label-sm {
    width: 130px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
}

.vocab-register-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: flex-start;
}

.vocab-register-row .form-input {
    flex: 1;
}

.form-select-sm {
    width: 130px;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    -webkit-appearance: none;
    background: white;
    flex-shrink: 0;
}

.col-check {
    width: 48px;
    text-align: center;
}

.col-freq {
    text-align: center;
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: #d69e2e;
    white-space: nowrap;
}

.row-selected {
    background: #f0f7ff;
}

/* ============================================================
   アラート・メッセージ
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 0.95rem;
}

.alert-success {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.alert-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.alert-warning {
    background: #fffaf0;
    color: #975a16;
    border: 1px solid #fbd38d;
    white-space: pre-line;
}

.empty-message {
    color: #666;
    text-align: center;
    padding: 40px 0;
    font-size: 1rem;
}

/* ============================================================
   モーダル（確認ポップアップ）
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-box {
    background: white;
    border-radius: 14px;
    padding: 32px 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-message {
    font-size: 1.1rem;
    font-weight: bold;
    color: #1a3a5c;
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================================
   送信完了ページ
   ============================================================ */
.center-content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.complete-box {
    text-align: center;
}

.complete-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.complete-message {
    font-size: 1.3rem;
    font-weight: bold;
    color: #1a3a5c;
    margin-bottom: 32px;
}

/* ============================================================
   必須・任意バッジ
   ============================================================ */
.required-badge {
    display: inline-block;
    background: #e53e3e;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

.optional-badge {
    display: inline-block;
    background: #718096;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 4px;
    margin-left: 6px;
    vertical-align: middle;
}

/* ============================================================
   ログイン画面
   ============================================================ */
.login-form {
    max-width: 380px;
    margin: 0 auto;
}

/* ============================================================
   レスポンシブ（iPhone 15基準 393px）
   ============================================================ */
@media (max-width: 480px) {
    .page-title {
        font-size: 1.2rem;
    }

    .top-title {
        font-size: 1.25rem;
    }

    .mode-buttons {
        flex-direction: column;
    }

    .text-input-row {
        flex-direction: column;
    }

    .form-row {
        flex-direction: column;
    }

    .choice-input-row {
        flex-direction: column;
    }

    .result-value {
        font-size: 1.6rem;
    }

    .mark-btn {
        width: 54px;
        height: 54px;
        font-size: 1.2rem;
    }

    .marksheet-buttons {
        gap: 12px;
    }

    .vocab-register-header {
        display: none;
    }

    .vocab-register-row {
        flex-direction: column;
        gap: 6px;
        border-bottom: 1px solid #eee;
        padding-bottom: 12px;
    }

    .vocab-col-label-sm,
    .form-select-sm {
        width: 100%;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}
