/* じっこうきのうゲーム 共通スタイル
   評価者向け画面は読みやすさ優先、児童向けの舞台は刺激だけを大きく置く。 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --line: #dde2ea;
  --ink: #1f2430;
  --ink-weak: #5c6577;
  --accent: #3f6bd6;
  --accent-ink: #ffffff;
  --danger: #c0392b;
  --ok: #2f9e6f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 8px 24px rgba(31, 36, 48, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

.app-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 26px;
  letter-spacing: .02em;
  margin: 0;
}

.app-header p {
  margin: 0;
  color: var(--ink-weak);
  font-size: 14px;
}

h2 {
  font-size: 18px;
  margin: 0 0 12px;
}

h3 {
  font-size: 16px;
  margin: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--ink-weak);
  font-size: 13px;
  letter-spacing: .08em;
}

.lead {
  color: var(--ink-weak);
  margin: 0 0 16px;
}

.muted { color: var(--ink-weak); }
.warn { color: var(--danger); }

/* ---- 入力 ---- */

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--ink-weak);
  margin-bottom: 14px;
}

input[type="text"],
input[type="date"],
select,
textarea {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(63, 107, 214, .35);
  outline-offset: 1px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}

button, .button {
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

button:hover, .button:hover { border-color: #c3cbd8; }
button:disabled { opacity: .5; cursor: default; }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.danger-link {
  border: none;
  background: none;
  color: var(--danger);
  min-height: 36px;
  padding: 4px 8px;
  font-size: 13px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.quiet-link {
  display: inline-block;
  margin-top: 14px;
  color: var(--ink-weak);
  font-size: 14px;
}

/* ---- ランチャー ---- */

.participant-list { display: grid; gap: 16px; }

.participant {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
}

.participant-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.participant-head h3 { font-size: 18px; }
.participant-meta { color: var(--ink-weak); font-size: 13px; margin: 2px 0 0; }

.task-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.task-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #fbfcfe;
  min-height: 96px;
}

.task-card:hover { border-color: var(--accent); }
.task-card .emoji { font-size: 26px; display: block; line-height: 1.2; }
.task-card b { display: block; margin-top: 4px; }
.task-card span.target { display: block; color: var(--ink-weak); font-size: 12px; }

/* ---- 課題画面 ---- */

.task-root {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.task-root .card { max-width: 640px; width: 100%; margin: 0; }
.instruction .points { padding-left: 20px; margin: 0 0 20px; color: var(--ink-weak); }
.instruction .points li { margin-bottom: 6px; }
.instruction .points b { color: var(--ink); }

/* 児童が見る舞台。刺激以外は置かない。 */
.stage {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stimulus-svg {
  width: min(46vw, 46vh);
  height: auto;
  max-height: 76vh;
}

/* とまれ！用。刺激を重ねて置き、表示の切り替えを opacity だけにする。
   display の切り替えや innerHTML の組み直しは再レイアウトを起こし、提示時刻がずれる。 */
.stage-layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  /* 先にレイヤへ昇格させ、隠れている間にラスタライズまで済ませておく。
     表示の切り替えを opacity だけにすると、描き直しなしで次のフレームに出る。 */
  transform: translateZ(0);
  will-change: opacity;
}

.stage-layer.show { opacity: 1; }

.stop-svg { width: min(34vw, 34vh); height: auto; }

/* 選択ボタン式（ぎゃくことば）。刺激は上、押すボタンは下にずっと出しておく。 */
.choice-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  padding: 3vh 3vw;
}

.choice-slot {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 34vh;
}

.choice-slot .stimulus-svg { width: min(30vw, 34vh); max-height: 34vh; }

.choice-row {
  display: flex;
  gap: 5vw;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

/* 子どもが端末を持ったまま押せる大きさ。押した瞬間だけ沈む（正誤は出さない）。 */
.choice-button {
  width: min(26vw, 26vh);
  height: min(26vw, 26vh);
  padding: 2%;
  border: 4px solid #dfe3ec;
  border-radius: 24px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 90ms ease, background-color 90ms ease;
}

.choice-button .stimulus-svg { width: 100%; height: auto; max-height: 100%; }
.choice-button:active { transform: scale(0.94); background: #f3f6ff; }

/* まねしないで。画面いっぱいの1枚パッドを叩かせる。 */
.pad-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tap-pad {
  width: min(52vw, 62vh);
  height: min(52vw, 62vh);
  border: 6px solid #e6d3a8;
  border-radius: 50%;
  background: #fffaf0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pad-svg { width: 46%; height: auto; }

/* 叩けたことだけを返す光。正誤の手がかりにはしない */
.tap-pad.hit {
  background: #fff2d0;
  border-color: #f2b134;
  transform: scale(0.97);
}

/* かたちわけ（DCCS）。上に手本2枚、下に出題カード。 */
.dccs-stage {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  padding: 3vh 3vw;
}

.dccs-targets {
  display: flex;
  gap: 6vw;
  flex: 0 0 auto;
}

.dccs-target {
  width: min(24vw, 26vh);
  height: min(24vw, 26vh);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 90ms ease;
}

.dccs-target:active { transform: scale(0.94); }
.card-svg { width: 100%; height: 100%; }

.dccs-slot {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 30vh;
}

.dccs-slot .card-svg { width: min(24vw, 30vh); height: auto; }

/* ひかりの じゅんばん（Corsi）。9枚を不規則に置く。 */
.corsi-stage {
  position: absolute;
  inset: 0;
  margin: 4vh 6vw;
}

.corsi-block {
  position: absolute;
  width: min(14vw, 18vh);
  height: min(14vw, 18vh);
  transform: translate(-50%, -50%);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.corsi-face {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background: #cfd6e6;
  box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.08);
  transition: background-color 60ms linear, transform 60ms linear;
}

.corsi-block.lit .corsi-face { background: #ffc93c; transform: scale(1.08); }
.corsi-block.hit .corsi-face { background: #7fb2f0; transform: scale(0.94); }

/* 提示中は触らせない */
.corsi-stage.locked .corsi-block { pointer-events: none; }

.feedback {
  font-size: min(22vw, 22vh);
  font-weight: 700;
  line-height: 1;
}

.feedback.ok { color: var(--ok); }
.feedback.ng { color: var(--danger); }

/* 右上の見えない長押し領域 */
.hotspot {
  position: fixed;
  top: 0;
  right: 0;
  width: 88px;
  height: 88px;
  z-index: 20;
}

/* 画面下の採点バー（HTKS など評価者採点の課題だけ出る）
   児童に正誤が伝わらないよう、色分けせず漢字ラベルにしてある */
.scorepad {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 18;
  display: flex;
  gap: 8px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  background: rgba(24, 28, 38, .9);
}

.scorepad-key {
  flex: 1;
  min-height: 56px;
  border: 0;
  border-radius: 10px;
  background: #3a4152;
  color: #eef1f6;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: .04em;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.scorepad-key:active { background: #4c5468; }

.scorepad-key.subtle {
  flex: 0 0 22%;
  background: transparent;
  color: #9aa3b5;
  box-shadow: inset 0 0 0 1px #4c5468;
}

.examiner-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 15;
  width: min(320px, 80vw);
  background: rgba(24, 28, 38, .94);
  color: #eef1f6;
  border-radius: 12px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.examiner-panel.hidden { display: none; }
.examiner-panel .notice { margin: 0 0 8px; color: #ffd479; }
.panel-list { margin: 0; }
.panel-list > div { display: flex; justify-content: space-between; gap: 12px; }
.panel-list dt { color: #a8b1c2; margin: 0; }
.panel-list dd { margin: 0; text-align: right; }

.finish {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #fff;
}

.finish-mark { font-size: min(18vw, 18vh); line-height: 1; }
.finish-text { font-size: min(9vw, 9vh); font-weight: 700; margin: 0; }

/* ---- 結果・レポート ---- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fbfcfe;
}

.metric-label { display: block; font-size: 12px; color: var(--ink-weak); }
.metric-value { display: block; font-size: 20px; letter-spacing: .01em; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-top: 12px;
}

.data-table th, .data-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.data-table th { color: var(--ink-weak); font-weight: 500; }
.table-scroll { overflow-x: auto; }

.date-group { margin-bottom: 26px; }

.date-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
  margin-bottom: 14px;
}

.date-head h2 { margin: 0; font-size: 20px; }
.date-head span { color: var(--ink-weak); font-size: 13px; }

.session-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 18px;
  margin-bottom: 14px;
}

.session-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.session-head h3 { font-size: 17px; }
.session-sub { color: var(--ink-weak); font-size: 13px; margin: 2px 0 0; }

.session-card details { margin-top: 12px; }
.session-card summary { cursor: pointer; color: var(--accent); font-size: 14px; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2f9;
  color: var(--ink-weak);
}

.badge.aborted { background: #fdecea; color: var(--danger); }

/* CSSだけの推移バー */
.trend { margin-top: 8px; }
.trend-row {
  display: grid;
  grid-template-columns: 92px 1fr 56px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 6px;
}

.trend-bar {
  height: 12px;
  border-radius: 999px;
  background: #eaeef5;
  overflow: hidden;
}

.trend-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.trend-value { text-align: right; color: var(--ink-weak); }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--ink-weak);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.toolbar .field { margin-bottom: 0; min-width: 220px; }

.notice-line {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--ok);
  min-height: 20px;
}

@media (max-width: 640px) {
  .app-shell { padding: 16px 14px 48px; }
  .card { padding: 18px; }
  .trend-row { grid-template-columns: 76px 1fr 48px; }
}
