@charset "UTF-8";
/* =========================================================================
   来場者カウンター  style.css
   ビルド不要・CDN 不使用（N-07）。iPadOS Safari / Windows Edge・Chrome 共通（N-08）。
   ========================================================================= */

:root {
  --purple:      #4a2574;
  --purple-dark: #35194f;
  --ink:         #1c1620;
  --paper:       #f7f4fb;
  --line:        #d9d0e6;
  --danger:      #c0261f;
  --warn:        #b26b00;

  /* ボタンの対色（N-06: 屋内照明下で判読できるコントラスト） */
  --tone-a-bg: #4a2574; --tone-a-fg: #ffffff;  /* 卒業生・元/現教員 */
  --tone-b-bg: #1f6f5c; --tone-b-fg: #ffffff;  /* 在校生ペア */
  --tone-c-bg: #a4491b; --tone-c-fg: #ffffff;  /* 小学生ペア */
  --tone-d-bg: #4c4a55; --tone-d-fg: #ffffff;  /* その他 */

  --gap: 10px;
  --radius: 14px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* N-05: 選択・長押しメニュー・ズームの抑止 */
* {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo",
               system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }

/* ------------------------------------------------------------- 画面切替 -- */
.screen { display: none; position: fixed; inset: 0; }
.screen.is-active { display: flex; }

/* --------------------------------------------------------- 起動画面 7.1 -- */
#screen-start {
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--purple) 0%, var(--purple-dark) 100%);
  color: #fff;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.start-box { width: min(440px, 100%); text-align: center; }
.start-logo { border-radius: 20px; display: block; margin: 0 auto 12px; }
.start-title { font-size: 1.6rem; margin: 0 0 4px; letter-spacing: .04em; }
.start-sub { margin: 0 0 28px; opacity: .8; font-size: .95rem; }
.btn-start {
  width: 100%;
  min-height: 88px;
  border: none;
  border-radius: var(--radius);
  background: #fff;
  color: var(--purple);
  font-size: 1.7rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-start:active { transform: scale(.985); }
.btn-start[disabled] { opacity: .5; cursor: default; }
.btn-start[disabled]:active { transform: none; }
.start-note { font-size: .82rem; opacity: .75; margin: 10px 0 22px; }
.start-status {
  margin: 0; display: grid; gap: 6px 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  font-size: .8rem; text-align: left;
}
.start-status > div { display: flex; justify-content: space-between; gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,.18); padding-bottom: 4px; }
.start-status dt { opacity: .7; margin: 0; }
.start-status dd { margin: 0; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ------------------------------------------------------ カウント画面 7.2 -- */
#screen-count {
  flex-direction: column;
  padding: calc(6px + var(--safe-top)) calc(8px + var(--safe-right))
           calc(6px + var(--safe-bottom)) calc(8px + var(--safe-left));
}
/* 横長画面でもボタンが極端に横長にならないよう最大幅を設けて中央寄せ（7.2）。
   対象は「流れの中に並ぶ子」だけに限定する。`#screen-count > *` にすると
   ID を含むぶん詳細度が高く、position:fixed の #admin-hotspot（72px 四方）まで
   760px に広げてしまい、1行目のボタンの上端を覆ってタップを飲み込む。 */
#screen-count > .test-banner,
#screen-count > .count-header,
#screen-count > .grid,
#screen-count > .count-footer { width: min(760px, 100%); margin-inline: auto; }

/* F-13-1: テストモードの赤帯 */
.test-banner {
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  letter-spacing: .2em;
  text-align: center;
  padding: 5px 8px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: .95rem;
  flex: 0 0 auto;
}
.test-banner[hidden] { display: none; }

.count-header { flex: 0 0 auto; padding: 4px 2px 6px; }
.guide { margin: 0; text-align: center; font-size: 1.05rem; font-weight: 600; color: #4b4155; }

/* 2列グリッド。ペアが同じ行に並ぶ（7.2） */
.grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: var(--gap);
}
.cat-btn {
  border: none;
  border-radius: var(--radius);
  min-height: 150px;              /* N-06: 短辺 150px 以上 */
  padding: 4px;
  font-size: clamp(1.35rem, 4.4vmin, 2.3rem);
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,.22);
  transition: transform .06s ease-out, filter .06s ease-out;
}
.cat-btn:active, .cat-btn.is-pressed { transform: translateY(2px); filter: brightness(1.18); box-shadow: none; }
.cat-btn.span-2 { grid-column: 1 / -1; }
.cat-btn.tone-a { background: var(--tone-a-bg); color: var(--tone-a-fg); }
.cat-btn.tone-b { background: var(--tone-b-bg); color: var(--tone-b-fg); }
.cat-btn.tone-c { background: var(--tone-c-bg); color: var(--tone-c-fg); }
.cat-btn.tone-d { background: var(--tone-d-bg); color: var(--tone-d-fg); }
/* ペアの右側（保護者）は同系色の明度違いにして「対」であることを示す */
.cat-btn.pair-2 { filter: brightness(1.32); }
.cat-btn.pair-2:active, .cat-btn.pair-2.is-pressed { filter: brightness(1.5); }

/* タブレットの横向き・PCでは横幅を4区分に分ける。
   各属性の本人と関係者を縦にそろえ、「その他」は2行分を結合した形にする。 */
@media (min-width: 1200px), (orientation: landscape) and (min-width: 700px) {
  #screen-count > .test-banner,
  #screen-count > .count-header,
  #screen-count > .grid,
  #screen-count > .count-footer { width: 100%; }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    grid-auto-rows: unset;
  }
  .cat-btn[data-key="alumni"]          { grid-column: 1; grid-row: 1; }
  .cat-btn[data-key="teacher"]         { grid-column: 1; grid-row: 2; }
  .cat-btn[data-key="student"]         { grid-column: 2; grid-row: 1; }
  .cat-btn[data-key="student_guardian"] { grid-column: 2; grid-row: 2; }
  .cat-btn[data-key="elem"]            { grid-column: 3; grid-row: 1; }
  .cat-btn[data-key="elem_guardian"]   { grid-column: 3; grid-row: 2; }
  .cat-btn[data-key="other"].span-2 {
    grid-column: 4;
    grid-row: 1 / -1;
  }
}

.count-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 0;
  gap: 10px;
}
.btn-undo {
  border: 1px solid var(--line);
  background: #fff;
  color: #5c5266;
  border-radius: 8px;
  padding: 7px 18px;
  font-size: .95rem;
  cursor: pointer;
}
.btn-undo:active { background: #eee7f4; }
.count-view { font-size: .95rem; color: #6d6478; font-variant-numeric: tabular-nums; }

/* 管理画面の呼び出し領域（不可視・3秒長押し） */
.admin-hotspot {
  position: fixed;
  top: 0; right: 0;
  width: 72px; height: 72px;
  z-index: 40;
  background: transparent;
}
.admin-hint {
  position: fixed;
  top: 4px; right: 78px;
  z-index: 41;
  font-size: .7rem;
  color: #9a8fa8;
  pointer-events: none;
}
.admin-hint[hidden] { display: none; }

/* 縦に余裕のない画面（横向きの小型端末、Windows の小ウィンドウ）では
   150px を維持できないため、破綻させずに縮める（N-09） */
@media (max-height: 620px) {
  .cat-btn { min-height: 76px; font-size: clamp(1.05rem, 5vmin, 1.7rem); }
  :root { --gap: 7px; }
}

/* --------------------------------------------- オーバーレイ 7.3 / F-03 -- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 37, 116, .82);
  color: #fff;
  pointer-events: none;      /* ← 必須。表示中も次のタップを受け付ける */
  opacity: 0;
  visibility: hidden;
}
.overlay.is-show {
  visibility: visible;
  animation: overlay-fade 800ms ease-out forwards;   /* F-03: 0.8秒 */
}
@keyframes overlay-fade {
  0%   { opacity: 1; }
  62%  { opacity: 1; }
  100% { opacity: 0; }
}
.overlay-text {
  font-size: clamp(1.8rem, 8vmin, 4rem);
  font-weight: 700;
  text-align: center;
  padding: 0 20px;
  text-shadow: 0 2px 8px rgba(0,0,0,.25);
}
@media (prefers-reduced-motion: reduce) {
  .overlay.is-show { animation-timing-function: steps(1, end); }
}

/* ----------------------------------------------------------- トースト -- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(64px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 45;
  background: rgba(28, 22, 32, .92);
  color: #fff;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: .95rem;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
.toast[hidden] { display: none; }

/* ------------------------------------------------------- 管理画面 7.4 -- */
.screen-admin { background: var(--paper); z-index: 50; }
.admin-inner {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;                 /* 管理画面のみスクロールを許可する */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(12px + var(--safe-top)) calc(12px + var(--safe-right))
           calc(28px + var(--safe-bottom)) calc(12px + var(--safe-left));
}
.admin-inner > * { width: min(760px, 100%); margin-inline: auto; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.admin-head h2 { margin: 0; font-size: 1.2rem; }
.admin-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.admin-card .label { font-size: .78rem; color: #7a7085; font-weight: 700; margin-bottom: 8px; letter-spacing: .04em; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.mode-value { font-size: 1.25rem; font-weight: 700; }
.mode-value.is-test { color: var(--danger); }
.mode-value.is-prod { color: #1f6f5c; }
.hint { font-size: .78rem; color: #7a7085; margin: 8px 0 0; }
.hint code, .admin-card code { background: #f0eaf7; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 11px 16px;
  min-height: 44px;
  font-size: .95rem;
  cursor: pointer;
}
.btn:active { background: #efe9f6; }
.btn-primary { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn-warn    { background: #fff5e6; color: var(--warn); border-color: #e6c68a; font-weight: 700; }
.btn-danger  { background: var(--danger); color: #fff; border-color: var(--danger); font-weight: 700; }
.btn-danger[disabled] { opacity: .45; cursor: default; }
.btn-ghost   { background: transparent; color: #6d6478; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.admin-table th, .admin-table td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: right; white-space: nowrap; }
.admin-table th:first-child, .admin-table td:first-child { text-align: left; }
.admin-table thead th { color: #7a7085; font-size: .78rem; }
.admin-table tfoot td, .admin-table tr.total td { font-weight: 700; border-top: 2px solid var(--line); }
.admin-table td { font-variant-numeric: tabular-nums; }

.kv { margin: 0; display: grid; gap: 4px; font-size: .88rem; }
.kv > div { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px dotted var(--line); padding-bottom: 3px; }
.kv dt { color: #7a7085; margin: 0; }
.kv dd { margin: 0; text-align: right; overflow-wrap: anywhere; -webkit-user-select: text; user-select: text; }

.csv-text {
  width: 100%;
  height: 180px;
  margin-top: 10px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: .75rem;
  -webkit-user-select: text;
  user-select: text;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  white-space: pre;
}
.csv-text[hidden] { display: none; }

.danger-card { border-color: #e8bdbb; }
.confirm-box { margin-top: 10px; padding: 10px; border: 1px solid #e8bdbb; border-radius: 9px; background: #fdf4f3; font-size: .9rem; }
.confirm-box[hidden] { display: none; }
.confirm-box p { margin: 0 0 10px; }
.sep { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.reset-input {
  font-size: 1.1rem;
  letter-spacing: .28em;
  padding: 10px;
  width: 100%;
  max-width: 220px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  -webkit-user-select: text;
  user-select: text;
  text-transform: uppercase;
}
.admin-version { text-align: center; font-size: .72rem; color: #9a8fa8; }
