body {
    font-family: "DIN Alternate", "Noto Sans JP", sans-serif;
}

:lang(ja) {
    font-family: "Noto Sans JP", sans-serif;
}

:lang(en) {
    font-family: "DIN Alternate", sans-serif;
}

/* ===============================
   基本設定
================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Arial", sans-serif;
}

body {
    background-color: #f5f5f5;
}

/* ===============================
   ヘッダー
================================ */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: white;
    border-bottom: 2px solid #ccc;
    height: 60px;
    overflow: hidden;
}

.logo-left img,
.logo-right img {
    max-height: 40px;
    object-fit: contain;
    object-position: center;
}

/* ===============================
   メインコンテンツ: 2x2 グリッド
================================ */
main {
    background: white;
    padding: 10px;
    height: calc(100vh - 60px);
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 6.5fr 3.5fr;
    gap: 10px;
    width: 90%;
    max-width: 1200px;
    height: 100%;
}

.grid-cell {
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    padding: 15px;
}

/* ===============================
   セル1: 毛細血管画像 (左上)
================================ */
.cell-image {
    position: relative;
}

.cell-image .image-score-container {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
}

.cell-image .image-score-mobile {
    display: none;
}

.date-container {
    display: flex;
    justify-content: flex-end;
}

.date-overlay {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
}

/* ===============================
   セル2: アドバイス画像 (右上)
================================ */
.cell-advice {
    display: flex;
    flex-direction: column;
}

.advice-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
}

.advice-title span {
    font-size: 11px;
    color: gray;
    margin-left: 6px;
}

.advice-image {
    flex: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

.advice-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.advice-disclaimer {
    font-size: 10px;
    color: #999;
    text-align: center;
    margin-top: 4px;
    flex-shrink: 0;
}

/* ===============================
   セル3: スコア (左下)
================================ */
.cell-score {
    display: flex;
    flex-direction: column;
}

.score-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
}

.score-title span {
    font-size: 11px;
    color: gray;
    margin-left: 6px;
}

.calc-result-container {
    flex: 1;
    display: flex;
    gap: 10px;
    min-height: 0;
    height: 100%;
    background: transparent;
}

.cell-score .prameter-overlay {
    flex: 5;
    min-width: 0;
}

.cell-score .score-value-overlay {
    flex: 3;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: flex-end;
    padding-right: 20px;
}

.cell-score .score-bar {
    position: absolute;
    right: 0;
    bottom: 0;
    height: 80%;
}

/* ===============================
   セル4: 所見 + QR (右下)
================================ */
.cell-finding {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finding-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.finding-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 8px;
}

.finding-title span {
    font-size: 11px;
    color: gray;
    margin-left: 6px;
}

.finding-text {
    font-size: 13px;
    line-height: 1.7;
    color: #444;
}

.finding-qr-row {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.finding-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-shrink: 0;
}

.finding-qr img {
    width: 96px;
    height: 96px;
    display: block;
}

.qr-label {
    font-size: 10px;
    color: #888;
    margin-top: 4px;
}

/* ===============================
   識別子フッター (スタッフ照合用)
================================ */
.identifier-footer {
    position: fixed;
    right: 8px;
    bottom: 4px;
    color: #999;
    font-size: 10px;
    line-height: 1.3;
    text-align: right;
    pointer-events: none;
    z-index: 10;
}

.identifier-footer span {
    margin-left: 6px;
}

/* ===============================
   レスポンシブ対応 (スマホ: 縦並び)
================================ */
@media (max-width: 768px) {
    main {
        height: auto;
        overflow: auto;
    }

    html, body {
        overflow: auto;
    }

    .grid-container {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: auto;
        gap: 10px;
    }

    .grid-cell {
        flex: none;
        height: auto;
    }

    /* モバイル表示順: 画像→スコア→タイプ(所見)→アドバイス */
    .cell-image   { order: 1; }
    .cell-score   { order: 2; }
    .cell-finding { order: 3; }
    .cell-advice  { order: 4; }

    .cell-image {
        min-height: 250px;
    }

    .cell-image .image-score-container {
        display: none;
    }

    .cell-image .image-score-mobile {
        display: block;
    }

    .image-score-mobile {
        position: relative;
    }

    .score-image-mobile {
        width: 100%;
        height: auto;
        display: block;
    }

    .date-overlay-mobile {
        position: absolute;
        top: 8px;
        right: 8px;
        background: rgba(0, 0, 0, 0.5);
        color: white;
        padding: 4px 10px;
        border-radius: 4px;
        font-size: 12px;
    }

    .advice-image {
        flex: none;
        height: auto;
    }

    .advice-image img {
        width: 100%;
        height: auto;
    }

    .finding-qr {
        display: none;
    }
}
