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

body {
    font-family: 'MS Gothic', 'MS PGothic', 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', sans-serif;
    background-color: #f5f5f5;
    padding: 10px;
    color: #333;
    margin: 0;
    min-height: 100vh;
}

.container {
    width: 1123px; /* A4横向きの幅 (297mm at 96dpi) */
    min-height: 794px; /* A4横向きの高さ (210mm at 96dpi) */
    margin: 0 auto;
    background-color: white;
    padding: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    /* 自動スケーリング用 */
    transform-origin: top left;
    transition: transform 0.3s ease;
}

.header {
    margin-bottom: 2px;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 0;
}

.title-section {
    flex: 0 0 auto;
    text-align: left;
}

.title-image {
    max-width: 140px;
    height: auto;
    display: block;
    margin-bottom: 2px;
}

.json-load-section {
    margin-top: 1px;
}

.json-load-btn {
    padding: 2px 5px;
    font-size: 8px;
    background-color: #4caf50;
    color: white;
    border: 1px solid #333;
    border-radius: 2px;
    cursor: pointer;
    font-weight: bold;
}

.json-load-btn:hover {
    background-color: #45a049;
}

.json-load-btn:active {
    background-color: #3d8b40;
}

.team-info {
    flex: 0 0 auto;
    border: 1px solid #333;
    padding: 2px;
    background-color: #fff;
}

.info-table {
    width: auto;
    border-collapse: collapse;
    margin-bottom: 2px;
    font-size: 8px;
}

.info-table td {
    padding: 1px 3px;
    border: 1px solid #ccc;
    font-size: 8px;
    white-space: nowrap;
}

.info-table td:first-child,
.info-table td:nth-child(3) {
    background-color: #e8e8e8;
    font-weight: bold;
    width: auto;
    min-width: 40px;
}

.info-input {
    width: 45px;
    border: none;
    padding: 1px 2px;
    font-size: 8px;
    background-color: transparent;
}

.team-signature {
    margin-top: 1px;
    font-size: 8px;
}

.team-signature label {
    font-weight: bold;
    margin-right: 2px;
    font-size: 8px;
}

.signature-input {
    width: 120px;
    padding: 1px 2px;
    border: 1px solid #ccc;
    font-size: 8px;
}

.main-content {
    margin-top: 2px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* 装備の点検（左上固定位置） */
#equipment-inspection {
    margin-bottom: 2px;
    flex-shrink: 0;
}

/* ミッションエリアのラッパー */
.missions-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
    flex: 1;
    min-height: 0;
    align-items: start; /* 各カラムを上端から配置 */
}

/* 左右のカラム */
.missions-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 0;
    overflow: visible;
    align-self: start; /* 各カラムを明示的に上端から配置 */
}

/* 右カラムは上から詰めて配置 */
#missions-right {
    justify-content: flex-start;
    align-items: stretch;
}

/* 固定セクションを下部に配置 */
#missions-right .fixed-section {
    flex-shrink: 0;
}

/* 採点結果を右カラムの最下部に配置 */
.score-result {
    flex-shrink: 0;
}

/* スペーサー要素のスタイル */
.fixed-sections-spacer {
    flex: 1 1 auto;
    min-height: 0;
}

.mission-section {
    border: 1px solid #333;
    background-color: #fff;
    break-inside: avoid;
    flex-shrink: 0;
}

/* 固定セクションのスタイルは上記の#missions-right .fixed-sectionで定義 */

.mission-title {
    background-color: #4caf50;
    color: white;
    padding: 2px 4px;
    font-size: 9px;
    font-weight: bold;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 2px;
    line-height: 1.1;
}

.mission-title .penalty-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    /* 画像ファイル: file_00000000bf5472099e3de0a45c0f0817.png を penalty-icon.png にリネームしてください */
    background-image: url('penalty-icon.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    vertical-align: middle;
    margin-left: 3px;
}

.mission-content {
    padding: 3px;
}

.criterion {
    margin-bottom: 2px;
    padding: 2px;
    background-color: #f9f9f9;
    border-left: 1px solid #4caf50;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.criterion-disabled {
    opacity: 0.5;
    background-color: #e0e0e0;
    border-left-color: #999;
}

.criterion-disabled .criterion-label {
    color: #666;
}

.criterion-disabled input[type="radio"],
.criterion-disabled input[type="number"] {
    cursor: not-allowed;
}

.criterion-label {
    font-weight: bold;
    margin-bottom: 1px;
    font-size: 7px;
    line-height: 1.1;
}

.criterion-input {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-wrap: wrap;
}

.radio-group {
    display: flex;
    gap: 3px;
    align-items: center;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    font-size: 7px;
}

.radio-group input[type="radio"] {
    cursor: pointer;
}

.number-input-group {
    display: flex;
    align-items: center;
    gap: 2px;
}

.number-input-group label {
    font-size: 7px;
}

.number-input {
    width: 35px;
    padding: 1px 2px;
    border: 1px solid #ccc;
    font-size: 7px;
    text-align: center;
}

.score-result {
    margin-top: auto;
    border: 1px solid #333;
    background-color: #fff;
}

.score-result .mission-title {
    margin-bottom: 0;
}

.score-result .mission-content {
    padding: 6px 4px 12px 4px;
    text-align: center;
    background-color: #f0f0f0;
    min-height: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative; /* フッターの基準点 */
}

.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.score-label {
    font-size: 28px;
    font-weight: bold;
    color: #333;
    line-height: 1;
}

.score-value {
    font-size: 28px;
    font-weight: bold;
    color: #4caf50;
    min-width: 60px;
    text-align: center;
    line-height: 1;
}

.score-result .footer {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 7px;
    color: #999;
    text-align: right;
    line-height: 1;
}

.score-result .footer a {
    color: #666;
    text-decoration: none;
}

.score-result .footer a:hover {
    color: #4caf50;
    text-decoration: underline;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 5mm;
    }
    
    html {
        background-color: white;
        padding: 0;
        margin: 0;
        height: 100%;
        overflow: hidden;
    }
    
    body {
        background-color: white;
        padding: 0;
        margin: 0;
        height: 100%;
        /* 印刷時に96%に縮小して、縁が欠けても内容が収まるようにする */
        zoom: 0.96;
        overflow: hidden;
    }
    
    .container {
        box-shadow: none;
        padding: 8px;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 100vh !important;
        min-height: auto !important;
        margin: 0;
        overflow: hidden;
        page-break-after: avoid !important;
        page-break-inside: avoid;
    }
    
    .header,
    .main-content {
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    
    .missions-wrapper {
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    
    .missions-column {
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    
    .mission-section {
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    
    .score-result {
        page-break-before: avoid;
        page-break-after: avoid;
    }
    
    /* 2枚目のページを完全に防止 */
    * {
        page-break-after: avoid !important;
    }
    
    .container::after {
        content: none !important;
    }
}

@media screen and (max-width: 1200px) {
    body {
        padding: 5px;
    }
    
    .container {
        width: 1123px;
        min-width: 1123px;
        max-width: 1123px;
        transform: scale(0.9);
        transform-origin: top center;
    }
    
    .header-content {
        flex-direction: column;
    }
    
    .team-info {
        width: 100%;
        margin-left: 0;
    }
    
    .missions-grid {
        grid-template-columns: 1fr;
    }
}

