/* 守成クラブ足利会場 共通タイマー 共通スタイル（スマホ縦持ち最優先） */
:root {
  --navy: #1f3a5f;
  --navy-dark: #152a45;
  --gold: #c9a24a;
  --green: #1e8e4e;
  --yellow: #f2b705;
  --red: #c62828;
  --blue: #1f63b4;
  --ink: #1b1f24;
  --muted: #5d6673;
  --line: #d9dee5;
  --bg: #f4f6f9;
  --card: #ffffff;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { color: var(--ink); background: var(--bg); line-height: 1.5; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }

/* ---------- ヘッダー ---------- */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--navy); color: #fff;
  border-bottom: 3px solid var(--gold);
}
.brand-logo { width: 40px; height: 40px; flex: none; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.brand-sub { font-size: .8rem; color: #e7d6a8; }
.viewers { margin-left: auto; font-size: .9rem; white-space: nowrap; }

/* ---------- 接続状態 ---------- */
.conn {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 16px; background: #b71c1c; color: #fff; font-weight: 700; font-size: 1.05rem;
}
.conn-dot { width: 12px; height: 12px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- 色（フェーズ） ---------- */
[data-color="idle"], [data-color="done"] { --phase: var(--navy); --phase-ink: #fff; }
[data-color="green"]  { --phase: var(--green);  --phase-ink: #fff; }
[data-color="yellow"] { --phase: var(--yellow); --phase-ink: #1b1f24; }
[data-color="red"]    { --phase: var(--red);    --phase-ink: #fff; }
[data-color="blue"]   { --phase: var(--blue);   --phase-ink: #fff; }

/* ---------- 参加者画面 ---------- */
body.participant {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--phase); color: var(--phase-ink);
  transition: background-color .4s ease, color .4s ease;
}
.stage {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px 16px 8px;
}
.phase { font-size: clamp(1.4rem, 6.5vw, 2.4rem); font-weight: 700; }
.round { font-size: clamp(1.1rem, 5vw, 1.8rem); font-weight: 600; opacity: .95; margin-top: 2px; }
.time {
  font-size: clamp(5rem, 31vw, 16rem); font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 12px 0 18px;
}
body.is-paused .time { animation: blink 1.6s infinite; }
body.is-offline .stage { opacity: .55; }
.bar { width: min(90%, 560px); height: 10px; border-radius: 99px; background: rgba(255,255,255,.3); overflow: hidden; }
[data-color="yellow"] .bar { background: rgba(0,0,0,.15); }
.bar-fill { height: 100%; width: 0; background: currentColor; border-radius: 99px; }
.note { margin-top: 14px; font-size: clamp(1rem, 4.5vw, 1.4rem); font-weight: 700; min-height: 1.5em; }

.controls {
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; align-items: stretch;
  background: rgba(0,0,0,.18);
}
[data-color="yellow"] .controls { background: rgba(255,255,255,.35); }
.sound-on { display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 10px; font-size: .95rem; }
.toggle input { width: 22px; height: 22px; flex: none; }
.hint { margin: 0; font-size: .8rem; opacity: .85; }

.flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; z-index: 40; }
.flash.on { animation: flash 1.2s ease-out; }
@keyframes flash { 0%, 40% { opacity: .9; } 20%, 100% { opacity: 0; } 60% { opacity: .7; } }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 18px; border-radius: 12px; border: 2px solid transparent;
  font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-big { min-height: 60px; font-size: 1.2rem; }
.btn-small { min-height: 40px; padding: 6px 12px; font-size: .9rem; }
.btn-primary { background: var(--gold); color: var(--navy-dark); }
.btn-ghost { background: rgba(255,255,255,.92); color: var(--navy); border-color: var(--line); }
.btn-secondary { background: var(--navy); color: #fff; }
.btn-start { background: var(--green); color: #fff; }
.btn-stop { background: var(--red); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-outline { background: #fff; color: var(--red); border-color: var(--red); }

/* ---------- 管理画面 ---------- */
body.admin { background: var(--bg); }
.admin-main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; display: grid; gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.card h2 { margin: 0 0 12px; font-size: 1.1rem; color: var(--navy); }
.card h3 { margin: 20px 0 4px; font-size: 1rem; color: var(--navy); }
.monitor { background: var(--phase); color: var(--phase-ink); text-align: center; transition: background-color .4s; }
.monitor .time { font-size: clamp(4rem, 20vw, 8rem); margin: 6px 0 12px; }
.monitor .phase { font-size: 1.4rem; }
.monitor .round { font-size: 1.1rem; }
.monitor .bar { margin: 0 auto; }

.ops { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.ops-danger { margin-top: 28px; padding-top: 16px; border-top: 1px dashed var(--line); display: flex; justify-content: flex-end; }
.admin-sound { margin-top: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msg { min-height: 1.5em; margin: 8px 0 0; font-weight: 600; color: var(--green); }
.msg.error { color: var(--red); }
.muted { color: var(--muted); font-size: .88rem; margin: 6px 0; }

.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.inline { display: flex; align-items: center; gap: 6px; font-weight: 400; }
input[type="number"], select {
  min-height: 44px; padding: 6px 10px; border: 1px solid #b9c1cc; border-radius: 10px; background: #fff; font-size: 1rem;
}
input[type="number"] { width: 5.2em; text-align: right; }
.cues { display: grid; gap: 8px; margin: 8px 0 10px; }
.cue { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

.qr-card { text-align: center; }
.qr-wrap { display: flex; justify-content: center; }
.qr-wrap img { width: min(320px, 80vw); height: auto; background: #fff; }
.qr-url { word-break: break-all; font-weight: 600; color: var(--navy); }
.qr-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(10,20,35,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 22px 20px; max-width: 420px; width: 100%; }
.modal-box h2 { margin: 0 0 8px; color: var(--navy); font-size: 1.15rem; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.qr-full {
  position: fixed; inset: 0; z-index: 90; background: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 16px; text-align: center;
}
.qr-full-title { font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 800; color: var(--navy); }
#qr-full-img { width: min(70vh, 80vw); height: auto; }
.qr-full-lead { font-size: clamp(1.2rem, 2.5vw, 2rem); font-weight: 700; }
.qr-full-url { color: var(--muted); word-break: break-all; }

.print-only { display: none; }

@media (max-width: 480px) {
  .ops { grid-template-columns: 1fr; }
}

/* ---------- 印刷（QRのみ） ---------- */
@media print {
  @page { size: A4 portrait; margin: 18mm; }
  body { background: #fff; }
  .no-print, .conn, .modal, .qr-full { display: none !important; }
  .admin-main { max-width: none; padding: 0; }
  .card { box-shadow: none; }
  .print-only { display: block; }
  .print-head { text-align: center; }
  .print-head h1 { color: var(--navy); font-size: 26pt; margin: 8mm 0; }
  .qr-wrap img { width: 120mm; }
  .print-lead { font-size: 18pt; font-weight: 700; margin-top: 6mm; }
  .qr-url { font-size: 12pt; }
}
