/* 特典会タイマー 見た目。暗い会場で読みやすい濃色テーマ固定。 */
:root {
  --bg: #0e0f13;
  --card: #1a1c24;
  --card-border: #262935;
  --fg: #f4f5f7;
  --muted: #8b8f9a;
  --btn: #2a2d3a;
  --btn-active: #3b3f52;
  --warn: #ff4d4d;
  --accent: #7c9cff;
  --flash-ms: 1500ms;
  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) env(safe-area-inset-bottom);
}

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; }

/* ---------- ヘッダー ---------- */
.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; }
.cap {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}
.cap.ok { color: #7ee2a8; border-color: #2f5a41; }
.cap.ng { color: #ffb86b; border-color: #5a4a2f; }
.cap.offline { color: var(--warn); border-color: #5a2f2f; }
.cap-btn { background: transparent; border-radius: 999px; min-height: 28px; }
.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);
}
.group .empty { color: var(--muted); font-size: 13px; padding: 12px 4px; }
.group .empty[hidden] { display: none; }

/* ---------- 設定画面 ---------- */
.settings {
  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] { display: flex; align-items: flex-end; justify-content: center; }
.settings::backdrop { background: rgba(0, 0, 0, 0.6); }
.settings-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; }
.toggles { display: flex; flex-direction: column; gap: 4px; }
.toggles .group-name { font-size: 12px; color: var(--muted); margin-top: 6px; }
.row { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; }
.row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.small { min-height: 36px; padding: 0 14px; font-size: 13px; margin-top: 6px; }
.status-line { margin: 2px 0; font-size: 13px; }
.status-line.ok { color: #7ee2a8; }
.status-line.ng { color: #ffb86b; }
.status-line.offline { color: var(--warn); }

.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));
}

/* ---------- 設定エラー ---------- */
.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;
}

/* ---------- メンバー ---------- */
.main { flex: 1; padding-top: 6px; }
.group[hidden] { display: none; }
.member {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--group-color, var(--accent));
  border-radius: 14px;
  padding: 5px 10px 7px;
  margin-bottom: 6px;
}
.member-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 26px;
}
.name { font-size: 18px; font-weight: 700; }
.reset {
  min-height: 28px;
  min-width: 72px;
  padding: 0 12px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
}
.reset.armed {
  color: #fff;
  background: var(--warn);
  border-color: var(--warn);
  font-weight: 700;
}
.controls {
  display: flex;             /* −／時間／＋／＋10。役割で隠したボタンの分は残りが広がる */
  gap: 8px;
  align-items: stretch;
  margin-top: 4px;
}
.controls button {
  flex: 3 1 0;
  height: 52px;
  min-width: 0;
  font-size: 26px;
  font-weight: 700;
}
.controls .bulk { flex: 4 1 0; font-size: 18px; }
.controls button[hidden] { display: none; }
.time {
  flex: 5 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 52px;
  border-radius: 12px;
  font-size: clamp(26px, 9.5vw, 38px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
}
.time.stopped { color: var(--muted); font-weight: 500; }
.time.warn { color: var(--warn); font-weight: 800; }
/* パターンB: 待機分があり、まだ開始していない（剥がしがタップで開始） */
.time.ready { color: #ffcf5a; background: rgba(255, 207, 90, 0.12); border: 1px dashed rgba(255, 207, 90, 0.6); }
.time.tappable { cursor: pointer; }
.time.tappable:active { background: var(--btn-active); }
.next {
  font-size: 12px;
  color: #ffcf5a;
  border: 1px solid rgba(255, 207, 90, 0.5);
  border-radius: 999px;
  padding: 2px 8px;
  margin-right: 8px;
  white-space: nowrap;
}
.next[hidden] { display: none; }
.next.armed { color: #fff; background: var(--warn); border-color: var(--warn); }
.head-right { display: flex; align-items: center; }
.row input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.row small { color: var(--muted); font-size: 12px; }
/* 10秒を切った瞬間、該当メンバーのカードを光らせる（誰が10秒かを示す） */
.member.alert {
  border-color: var(--warn);
  box-shadow: 0 0 0 2px var(--warn), 0 0 18px rgba(255, 77, 77, 0.6);
}

/* ---------- フッター ---------- */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 2px 8px;
}
.footer-right { display: flex; gap: 10px; align-items: center; }
.relogin {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  font-size: 12px;
  min-height: 28px;
  padding: 0 10px;
}
.relogin.armed { color: #fff; background: var(--warn); border-color: var(--warn); font-weight: 700; }
.relogin[hidden] { display: none; }

/* ---------- 合言葉の入力画面 ---------- */
.gated .header, .gated .main, .gated .footer { visibility: hidden; }  /* 合言葉を入れるまで画面を出さない */
.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.92); }
.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: #ffb86b; line-height: 1.5; }
.gate-cancel { min-height: 40px; font-size: 13px; background: transparent; color: var(--muted); border: 1px solid var(--card-border); }
.gate-cancel[hidden] { display: none; }

/* ---------- 画面点滅（残り10秒） ---------- */
.flash {
  position: fixed;
  inset: 0;
  background: var(--warn);
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}
.flash.on {
  animation: flash-blink calc(var(--flash-ms) / 3) linear 3;
}
@keyframes flash-blink {
  0% { opacity: 0; }
  50% { opacity: 0.35; }
  100% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .flash.on { animation: flash-steady var(--flash-ms) linear 1; }
  @keyframes flash-steady { 0%, 100% { opacity: 0; } 10%, 90% { opacity: 0.3; } }
}

.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;
}

/* 背の低い画面ではさらに詰める */
@media (max-height: 620px) {
  .controls button { height: 46px; }
  .member { padding: 3px 10px 5px; margin-bottom: 4px; }
  .name { font-size: 16px; }
}

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