* {
  box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
}

article {
    margin-right: auto;
    margin-left: auto;
    padding: 10px;
    flex: 1;
}

@media (min-width: 640px) {
  article {
    width: 600px;
  }
}

h1, h2, h3 {
    color: #431b00;
    text-align: center;
}

h1 {
  font-size: 22px;
  padding: 20px;
  border: 8px solid #e6e0e6;
  border-radius: 6px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

nav {
    padding: 20px 0;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    text-align: center;
}

@media (max-width: 480px) {
  nav {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
    gap: 8px;
  }
}

nav a {
    display: inline-block;
    width: 100px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    color: black;
    font-size: small;
    text-align: center;
    box-shadow: 1px 1px 1px #aaa;
}

p {
    text-align: center;
    font-size: small;
    line-height: 1.5em;
}

p.info {
    text-align: left;
}

ul {
    font-size: small;
    line-height: 2.5em;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
    font-size: small;
    max-width: 600px;
}

tr:nth-child(odd) {
    background-color: #f0f0f0;
}

th, td {
    margin: 0;
    padding: 12px 8px;
    font-size: small;
}

th {
    background-color: white;
}

td {
    line-height: 1.8em;
}

.ceiling, .floor {
    height: 40px;
    width: 100%;
    padding: 10px;
    color: white;
    background-color: #431b00;
    box-shadow: 0 0 4px rgba(0,0,0,.8);
    font-size: small;
}

.ceiling {
    margin: 0 0 20px 0;
}

.ceiling a {
    color: white;
}

.floor {
    margin: 20px 0 0 0;
    text-align: center;
}

.type1, .type2 {
    width: 100%;
}

.type1 td:first-child {
    width: 50px;
    text-align: right;
}

.type2 td:first-child {
    width: 80px;
    text-align: right;
}

.type3 {
    margin-left: auto;
    margin-right: auto;
}

.type4 {
    margin-left: auto;
    margin-right: auto;
}

.type4 td:nth-child(2) {
    width: 80px;
    text-align: center;
}

#project_history + table {
    margin-left: auto;
    margin-right: auto;
}

.name {
    white-space: nowrap;
}

/* メインの履歴 */

/* 一月分 */
.month {
    border: 1px solid #ccc;
    border-radius: 6px;
    overflow: hidden;
    font-size: small;
    max-width: 600px;
}

.row:nth-child(even) {
    background-color: #f0f0f0;
}

/* チェックボックス自体は非表示にする */
.toggle-checkbox {
    display: none;
}

/* 3つのブロックを横並びにするコンテナ */
.cell-wrapper {
    display: flex;
    overflow: hidden;
}

/* 各ブロックの共通設定 */
.cell {
    padding: 12px 8px;
    display: grid;
    grid-template-columns: 2fr 1fr;
    align-content: center;
}

.cell-left {
    width: 12%;
    min-width: 60px;
    display: flex;
    justify-content: right;
    align-items: center;
    flex-shrink: 0;
}

.cell-center {
    width: 44%;
}

.cell-right {
    width: 44%;
}

.th {
    width: 44%;
    padding: 8px;
    text-align: center;
    font-weight: bold;
}

.th-day {
    width: 12%;
}

/* --- 中央・右ブロックの通常時スタイル --- */
.text-left {
    grid-column: 1;
    text-align: left;
    /* 一定幅以上の場合は3点リーダーにする設定 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-right {
    grid-column: 2;
    text-align: right;
}

/* 正解者一覧（通常時は非表示） */
.winners {
    grid-column: 1 / -1; /* 横幅一杯に広げる */
    display: none;
    gap: 5px;
    margin-top: 10px;
}

/* 各タグ（インラインで並び、途中で改行させない） */
.winner {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap; /* 1個のテキストの途中での改行を防止 */
}

.normal_winner {
    background-color: #fff9f0;
    border: 1px solid #efe9e0;
}

.hard_winner {
    background-color: #fff0f9;
    border: 1px solid #f5e6ed;
}

/* ===================================================
  ★タップ（チェックオン）時のスタイル変化
=================================================== */

/* 中央・右ブロックを2カラムから「1列（縦並び）」に変更 */
.toggle-checkbox:checked + .cell-wrapper .cell-center,
.toggle-checkbox:checked + .cell-wrapper .cell-right {
    grid-template-columns: 1fr; 
    align-content: start;
}

/* 1行目：左揃えだったテキストを全表示（制限解除） */
.toggle-checkbox:checked + .cell-wrapper .text-left {
    grid-column: 1;
    max-width: none;
    white-space: normal; /* 折り返しを許可して全部見せる */
    margin-bottom: 5px;
    font-weight: bold;
}
.toggle-checkbox:checked + .cell-wrapper .text-left::before {
    content: "正解: ";
}

/* 2行目：右揃えだったテキストを左揃えにし、頭に「正解者数」を付与 */
.toggle-checkbox:checked + .cell-wrapper .text-right {
    grid-column: 1;
    text-align: left;
    margin-bottom: 5px;
}
.toggle-checkbox:checked + .cell-wrapper .text-right::before {
    content: "正解者数: ";
}

/* 3行目：隠されていたテキスト（タグ）を表示 */
.toggle-checkbox:checked + .cell-wrapper .winners {
    display: flex;
    flex-wrap: wrap; /* 入り切らない場合はタグ単位で改行 */
}