/* お目当て集計 見た目。特典会タイマーと同じ濃色テーマ固定（暗い会場の受付で読みやすい）。 */
:root {
  --bg: #0e0f13;
  --card: #1a1c24;
  --card-border: #262935;
  --fg: #f4f5f7;
  --muted: #8b8f9a;
  --btn: #2a2d3a;
  --btn-active: #3b3f52;
  --warn: #ff4d4d;
  --ok: #7ee2a8;
  --caution: #ffb86b;
  --accent: #7c9cff;
  --actionbar-h: 128px; /* 画面下の固定バーの高さ。main の下余白に使う */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  padding-block: env(safe-area-inset-top) 0;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  border-radius: 12px;
  background: var(--btn);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
button:active { background: var(--btn-active); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: default; }

/* ---------- ヘッダー ---------- */
.header { padding-top: 4px; }
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
}
.title { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.02em; }
.caps { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.cap {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.cap:empty { display: none; }
.gear {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: var(--card);
  color: var(--fg);
}

.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  margin-top: 6px;
}
.tab {
  height: 40px;
  font-size: 16px;
  font-weight: 700;
  background: var(--card);
  border: 2px solid var(--card-border);
  color: var(--muted);
}
.tab[aria-selected="true"] {
  color: var(--fg);
  border-color: var(--tab-color, var(--accent));
  background: color-mix(in srgb, var(--tab-color, var(--accent)) 18%, var(--card));
}

/* イベント名（タブ直下・両グループ共通） */
.event-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.event-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.event-input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}
.event-input::placeholder { color: #5c606b; }
.event-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- 設定エラー・通知 ---------- */
.config-error {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--warn);
  border-radius: 10px;
  color: var(--warn);
  font-size: 13px;
  white-space: pre-wrap;
}
.notices:empty { display: none; }
.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--caution);
  border: 1px solid #5a4a2f;
  border-radius: 10px;
}
.notice.error { color: var(--warn); border-color: #5a2f2f; }
.notice span { flex: 1; }
.notice .dismiss {
  flex: none;
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 999px;
}

/* 日付が変わって起動した時の帯 */
.stale-banner {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--caution);
  border-radius: 10px;
  background: rgba(255, 184, 107, 0.08);
}
.stale-banner[hidden] { display: none; }
.stale-text { margin: 0 0 6px; font-size: 13px; line-height: 1.5; white-space: pre-line; }
.stale-actions { display: flex; gap: 8px; justify-content: flex-end; }
.stale-actions .small { margin-top: 0; }
.warn-btn { color: #fff; background: var(--warn); font-weight: 700; }

/* ---------- 選択肢の行 ---------- */
.main { flex: 1; padding-top: 6px; padding-bottom: calc(var(--actionbar-h) + env(safe-area-inset-bottom)); }
.group[hidden] { display: none; }
.option {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--group-color, var(--accent));
  border-radius: 14px;
  padding: 4px 8px 4px 10px;
  margin-bottom: 6px;
}
.option .name {
  flex: 1 1 0;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.option .step {
  flex: none;
  width: 56px;
  height: 56px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.option .count {
  flex: none;
  width: 72px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
}
.option .count.zero { color: var(--muted); font-weight: 500; }

/* ---------- 画面下の固定バー（合計・クリア・確定） ---------- */
.actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--bg);
  border-top: 1px solid var(--card-border);
  padding: 6px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.actionbar-inner { width: 100%; max-width: 560px; margin-inline: auto; }
.arm-note {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--caution);
}
.arm-note[hidden] { display: none; }
.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  min-height: 28px;
}
.total-label { font-size: 13px; color: var(--muted); }
.total-value {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.action-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.clear-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 56px;
  padding: 0 6px;
  font-size: 14px;
  line-height: 1.2;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
}
.clear-btn.armed {
  color: #fff;
  background: var(--warn);
  border-color: var(--warn);
  font-weight: 700;
}
.confirm-btn {
  flex: 1 1 0;
  min-width: 0;
  height: 56px;
  font-size: 18px;
  font-weight: 700;
  background: var(--accent);
  color: #0e0f13;
}
.confirm-btn:active { background: #93aeff; }

/* ---------- ダイアログ共通（設定・プレビュー） ---------- */
.settings, .preview {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  z-index: 50;
}
.settings[open], .preview[open] { display: flex; align-items: flex-end; justify-content: center; }
.settings::backdrop, .preview::backdrop { background: rgba(0, 0, 0, 0.6); }
.settings-panel, .preview-panel {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px 16px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.settings-head h2 { margin: 0; font-size: 16px; }
.settings-head .close { min-height: 36px; padding: 0 14px; font-size: 14px; }
.settings-sec { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--card-border); }
.settings-sec h3 { margin: 0 0 6px; font-size: 14px; }
.hint { margin: 4px 0 8px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.small { min-height: 36px; padding: 0 14px; font-size: 13px; margin-top: 6px; }
.status-line { margin: 2px 0; font-size: 13px; line-height: 1.5; }
.status-line.ok { color: var(--ok); }
.status-line.ng { color: var(--caution); }
.status-line.error { color: var(--warn); }
.status-line[hidden] { display: none; }

/* 送信履歴 */
.history { margin: 0; padding: 0 0 0 18px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.history li { margin: 2px 0; }
.history .h-ok { color: var(--ok); }
.history .h-failed { color: var(--warn); }
.history .h-unknown { color: var(--caution); }
.history .h-empty { list-style: none; margin-left: -18px; }

/* ---------- プレビュー ---------- */
.preview-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 10px 0 8px;
  font-size: 13px;
}
.preview-meta dt { color: var(--muted); }
.preview-meta dd { margin: 0; overflow-wrap: anywhere; }
.preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.preview-list li {
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.preview-list .pl-name { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-list .pl-count { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.preview-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 10px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--card-border);
  font-size: 14px;
}
.preview-total b { font-size: 24px; font-variant-numeric: tabular-nums; }
.preview-msg { margin: 8px 0; min-height: 1.5em; font-size: 13px; line-height: 1.5; color: var(--caution); }
.preview-msg.ok { color: var(--ok); }
.preview-msg.error { color: var(--warn); }
.send-btn {
  width: 100%;
  min-height: 56px;
  font-size: 17px;
  font-weight: 700;
  background: var(--accent);
  color: #0e0f13;
}
.send-btn[hidden] { display: none; }

/* ---------- 合言葉の入力 ---------- */
/* 起動時の合言葉ゲート: 合言葉を入れるまで本体（dialog 以外）を出さない */
body.gated > :not(dialog) { visibility: hidden; }
.gate-cancel[hidden] { display: none; }
.gate {
  position: fixed;
  inset: 0;
  width: auto;
  height: auto;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  z-index: 60;
}
.gate[open] { display: flex; align-items: center; justify-content: center; }
.gate::backdrop { background: rgba(14, 15, 19, 0.85); }
.gate-panel {
  width: calc(100% - 32px);
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.gate-panel h2 { margin: 0; font-size: 18px; }
.gate-lead { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; }
.gate-label { font-size: 13px; color: var(--muted); }
.gate-row { display: flex; gap: 8px; }
.gate-row input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 12px;
  font: inherit;
  font-size: 18px;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--card-border);
  border-radius: 12px;
}
.gate-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.gate-eye { min-height: 48px; padding: 0 12px; font-size: 13px; }
.gate-submit { min-height: 52px; font-size: 17px; font-weight: 700; background: var(--accent); color: #0e0f13; }
.gate-submit:disabled { opacity: 0.6; }
.gate-msg { margin: 0; min-height: 1.4em; font-size: 13px; color: var(--caution); line-height: 1.5; }
.gate-cancel { min-height: 40px; font-size: 13px; background: transparent; color: var(--muted); border: 1px solid var(--card-border); }

.noscript { padding: 16px; color: var(--warn); }

/* iOS 代替振動用の switch。display:none にするとハプティクスが鳴らないので画面外に置く */
.haptic-switch {
  position: fixed;
  left: -100px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* 背の低い画面では余白だけ詰める（ボタンの 56px は保つ） */
@media (max-height: 620px) {
  .option { padding: 2px 8px 2px 10px; margin-bottom: 4px; }
  .option .name { font-size: 16px; }
  .event-input { min-height: 36px; }
}

/* 大きい画面（タブレット・PC）では中央に寄せる */
@media (min-width: 600px) {
  body { padding-inline: 24px; }
  .header, .main, .config-error, .notices, .stale-banner { width: 100%; max-width: 560px; margin-inline: auto; }
}
