:root {
  --text: #111;
  --muted: #666;
  --bg: #fff;
  --border: #bbb;
  --sub: #999;
  --panel: #f5f5f5;
  --blue: #1976D2;
  --blue-strong: #0e5fb0;
  --gray-btn: #777;
  --gray-btn-strong: #555;
  --danger: #c62828;
  --answered-bg: #F0F0F0;
  --answered-text: #999;
  --answered-border: #CCC;
  --select-bg: #E6F2FF;
  --select-border: #1976D2;
}

* {
    box-sizing: border-box;
}
html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans JP", sans-serif;
}

/* 共通 */
.page {
    min-height: 100vh;
}
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 16px;
}
.container.narrow {
    max-width: 720px;
}
.container.wide {
    max-width: 1200px;
}
.h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 8px 0 12px;
}
.mb12 {
    margin-bottom: 12px;
}
.muted {
    color: var(--muted);
    font-size: 14px;
}
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 入力系 */
.label {
    display: block;
    font-weight: 700;
    margin: 8px 0 6px;
}
input, textarea,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
}
textarea {
    resize: vertical;
}
input[readonly] {
    background: #fafafa;
}

.btn {
    display: inline-block;
    padding: 14px 18px;
    border-radius: 8px;
    font-weight: 800;
    border: 1px solid #bbb;
    background: #eee;
    color: #000;
    cursor: pointer;
    min-width: 160px;
    text-align: center;
    user-select: none;
    transition: transform .02s ease;
}
.btn:active {
    transform: scale(0.98);
}
.btn.primary {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
    min-width: 240px;
}
.btn.big {
    width: 360px;
    height: 102px;
    font-size: 27px;
    padding-top: 8px;
    padding-bottom: 8px;
}
.btn.danger {
    background: var(--bg);
    color: var(--text);
    border-color: var(--border);
}
.actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
}
.row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.row.gap {
    gap: 8px;
}

#cat-button {
    margin-top: 30px;
}

.error-block {
    border-radius: 8px;
    padding: 10px 12px;
    margin: 12px 0;
}

/* ツールバー */
.toolbar {
    position: sticky;
    top: 0;
    background: var(--panel);
    border-bottom: 1px solid #ddd;
    z-index: 5;
}
.toolbar .title {
    font-weight: 800;
}

/* 質問入力 */
.q-card {
    border: 2px solid #000;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    background: #fff;
}
.q-head {
    font-size: 22px;
    font-weight: 800;
    text-decoration: underline;
    margin-bottom: 8px;
}
.q-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
    align-items: start;
    margin-bottom: 12px;
}
.counter {
    text-align: right;
    font-size: 12px;
    color: var(--muted);
}
.field-err {
    color: #c00;
    font-size: 13px;
    margin-top: 4px;
}
.cat-errors {
    margin-top: 8px;
}

/* コピーUI */
.copybox {
    margin-top: 8px;
}
.copyrow {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* 実行レイアウト */
.layout {
    width: 90%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}
.score-panel {
    position: sticky;
    top: 0;
    padding: 16px;
/*    border-right: 2px solid #000;*/
    background: #fff;
    width: 260px;
}
.score-title {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 8px;
}
.team-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.team {
    border: 2px solid #000;
    border-radius: 12px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    padding: 20px 10px;
}
.team-name {
    font-size: 24px;
    font-weight: 800;
}
.team-score {
    font-size: 36px;
    font-weight: 900;
}
.minus {
    color: #c00;
}

#reset {
    margin-top: 30px;
}

.main-panel {
    padding: 16px;
}
.view.hidden {
    display: none;
}

.board {
    display: grid;
    gap: 12px;
}
.board[style]{} /* 予約（JSで列数変更） */

.cat-col {
/*    border: 2px solid #000;
    border-radius: 12px;*/
    overflow: hidden;
}
.cat-name {
    font-size: 29px;
    font-weight: 800;
    border: 2px solid #000;
    border-radius: 12px;
    padding: 12px 10px;
    text-align: center;
}

.cell {
  width: 100%;
    padding: 17px;
    border: 2px solid #000;
    border-radius: 12px;
    background: #fff;
    font-size: 60px;
    font-weight: 800;
    cursor: pointer;
    text-align: center;
    outline: none;
    display: block;
    margin: 12px 0;
}

.cell:hover {
    background: #f2f2f2;
}

.cat1 {
    background: #ffc0cb;
}
button.cat1:hover {
    background: #ff69b4;
}
.cat2 {
    background: #ffdab9;
}
button.cat2:hover {
    background: #ffa500;
}
.cat3 {
    background: #98fb98;
}
button.cat3:hover {
    background: #32cd32;
}
.cat4 {
    background: #afeeee;
}
button.cat4:hover {
    background: #00bfff;
}
.cat5 {
    background: #dda0dd;
}
button.cat5:hover {
    background: #ba55d3;
}
.cell.selected {
    background: var(--select-bg);
    border-color: var(--select-border);
}
.cell.answered {
    background: var(--answered-bg);
    color: var(--answered-text);
    border-color: var(--answered-border);
    cursor: default;
}
.cell:focus {
    outline: 3px solid #000;
}

/* 問題・答え画面 */
.center {
    display: grid;
    place-items: center;
    gap: 20px;
    min-height: calc(100vh - 32px);
    text-align: center;
}
.q-text {
    font-size: 112px;
    font-weight: 900;
    max-width: 80vw;
}
.a-text {
    font-size: 112px;
    font-weight: 900;
    max-width: 80vw;
}
.judge {
    margin: 8px 0 16px;
}
.judge-rows {
    display: grid;
    gap: 8px;
}
.judge-table {
    border-collapse: collapse;
}
.judge-table td {
    padding: 8px 12px;
    text-align: center;
    vertical-align: middle;
}
.jteam-name {
    font-size: 24px;
    font-weight: 800;
}
.jteam-score {
    font-size: 32px;
    font-weight: 900;
}
.jbtn {
    padding: 12px 16px;
    border: 2px solid #000;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    background: #eee;
    white-space: nowrap;
}
.jbtn.active {
    background: #ffd2c8;
    color: #fff;
}
.jlabel {
    font-size: 18px;
    font-weight: 800;
    writing-mode: vertical-rl;
}

/* 小物 */
.toolbar-actions {
    display: flex;
    gap: 8px;
}

/* ===== 作成画面ボードグリッド ===== */
.create-board-wrap {
  overflow-x: auto;
  padding-bottom: 8px;
}
.create-board {
  display: grid;
  gap: 8px;
  min-width: fit-content;
}
.create-cell-base {
  min-width: 120px;
  border: 1px solid #ccc;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.create-cat-cell {
  min-height: 72px;
  font-size: 18px;
  cursor: pointer;
  background: #f5f5f5;
}
button.create-cat-cell.cat1:hover, button.create-cat-cell.cat1:focus { background: #ffaabb !important; }
button.create-cat-cell.cat2:hover, button.create-cat-cell.cat2:focus { background: #ffcc99 !important; }
button.create-cat-cell.cat3:hover, button.create-cat-cell.cat3:focus { background: #77dd77 !important; }
button.create-cat-cell.cat4:hover, button.create-cat-cell.cat4:focus { background: #88dddd !important; }
button.create-cat-cell.cat5:hover, button.create-cat-cell.cat5:focus { background: #cc88cc !important; }
.create-cat-cell.empty { color: #999; border-style: dashed; }
.create-diff-label {
  min-height: 72px;
  font-size: 20px;
  background: #f5f5f5;
  cursor: default;
  min-width: 68px;
}
.create-q-cell {
  min-height: 72px;
  font-size: 18px;
  line-height: 1.4;
  cursor: pointer;
  background: #fff;
  flex-direction: column;
}
.create-q-cell:hover,
.create-q-cell:focus { background: #f2f2f2; }
.create-q-cell.filled { background: var(--select-bg); border-color: var(--select-border); }
.create-q-cell.filled:hover,
.create-q-cell.filled:focus { background: #d0e8ff; }
.create-add-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 1px solid #bbb;
  background: #eee;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}
.create-add-btn:hover,
.create-add-btn:focus { background: #aad4ff !important; outline: 3px solid var(--blue); }
.create-del-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-family: inherit;
}
.create-del-btn:hover { background: #fff0f0; }
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.popup-card {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 16px;
  padding: 24px;
  width: 90vw;
  max-width: 460px;
}
.popup-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 16px;
}
input:focus,
textarea:focus {
  outline: 3px solid var(--blue) !important;
  outline-offset: 1px;
  background: #e8f4ff !important;
  border-color: var(--blue) !important;
}
.btn:focus {
  outline: 3px solid var(--blue) !important;
  outline-offset: 2px;
  background: #cce4ff !important;
}
.btn.primary:focus {
  background: var(--blue-strong) !important;
  color: #fff !important;
}
