/* ============ 共通 ============ */
:root {
  --late: #d32f2f;
  --late-bg: #ffebee;
  --early: #1565c0;
  --early-bg: #e3f2fd;
  --ontime: #616161;
  --ontime-bg: #eeeeee;
  --start: #2e7d32;
  --end: #e65100;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif;
  -webkit-text-size-adjust: 100%;
}
.fatal { padding: 24px; font-size: 20px; color: var(--late); }

/* ============ 管理画面 ============ */
body.admin { background: #f5f5f5; color: #212121; }

.admin-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 12px 16px; background: #263238; color: #fff;
}
.admin-header h1 { margin: 0; font-size: 20px; }
.header-right { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.clock { font-size: 20px; font-weight: bold; font-variant-numeric: tabular-nums; }
.sync-status {
  font-size: 13px; padding: 4px 8px; border-radius: 6px; background: #37474f; color: #cfd8dc;
}
.sync-status:empty { display: none; }
.sync-status.sync-synced { background: #1b5e20; color: #fff; }
.sync-status.sync-saving, .sync-status.sync-connecting { background: #455a64; color: #fff; }
.sync-status.sync-nopin, .sync-status.sync-empty { background: #f9a825; color: #212121; }
.sync-status.sync-unauthorized, .sync-status.sync-offline, .sync-status.sync-error { background: #c62828; color: #fff; }
.display-link {
  color: #fff; background: #455a64; padding: 8px 12px; border-radius: 8px;
  text-decoration: none; font-size: 16px;
}

.admin-main { max-width: 1100px; margin: 0 auto; padding: 12px; }

/* ブロック切り替えタブ */
.block-tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 10px; }
.block-tabs[hidden] { display: none; }
.block-tab {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 76px; padding: 10px 14px; border: 3px solid #b0bec5; border-radius: 14px;
  background: #fff; color: #37474f; font: inherit; text-align: left; cursor: pointer;
}
.block-tab-title { font-size: 26px; font-weight: bold; }
.block-tab-status { font-size: 15px; color: #555; line-height: 1.3; word-break: break-all;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.block-tab-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.block-tab-live { display: none; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
  background: #212121; color: #ffeb3b; font-size: 13px; font-weight: bold; }
.block-tab.is-live .block-tab-live { display: inline-block; }
.block-tab.tab-running .block-tab-status { color: var(--start); font-weight: bold; }
.block-tab.tab-changeover .block-tab-status { color: #8d6e00; font-weight: bold; }
.block-tab.tab-finished { background: #eceff1; }
.block-tab.tab-finished .block-tab-status { color: #777; }
.block-tab.is-selected { border-color: #1565c0; background: #e3f2fd; color: #0d47a1; box-shadow: 0 2px 6px rgba(21,101,192,.35); }
.block-tab.is-selected.tab-finished { background: #e3eaf1; }
.block-heading { margin: 0 0 8px; font-size: 18px; color: #0d47a1; }
.block-heading-note { font-size: 14px; color: #555; font-weight: normal; margin-left: 4px; }

.summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px;
}
.summary-item {
  background: #fff; border-radius: 12px; padding: 10px 12px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.summary-item .label { font-size: 14px; color: #555; margin-bottom: 4px; }
.summary-value { font-size: 32px; font-weight: bold; font-variant-numeric: tabular-nums; }
.delay-badge {
  display: inline-block; font-size: 28px; font-weight: bold; padding: 4px 14px;
  border-radius: 10px; color: #fff; background: var(--ontime);
}
.delay-badge.late { background: var(--late); }
.delay-badge.early { background: var(--early); }
.delay-badge.ontime { background: var(--ontime); }

.stage { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.slot {
  background: #fff; border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.12); border-left: 8px solid #b0bec5; min-width: 0;
}
.slot-label[hidden], .slot-sub[hidden] { display: none; }
.slot-label { font-size: 16px; font-weight: bold; color: #555; }
.slot-name { font-size: 28px; font-weight: bold; margin: 6px 0; word-break: break-all; }
.slot-now .slot-name { font-size: 40px; }
.slot-sub { font-size: 15px; color: #555; }
.slot-now.is-active { border-left-color: var(--start); background: #f1f8e9; }
.slot-now.is-active .slot-label { color: var(--start); }

/* 次のセッティング（開始待ち＝開演前・入れ替え中のみ） */
.setup {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: #fff8e1; border: 3px solid #f9a825;
}
.setup[hidden], .setup [hidden] { display: none; }
.setup-title { font-size: 18px; font-weight: bold; color: #6d4c00; }
.setup-name { font-size: 22px; color: #212121; word-break: break-all; }
.setup-note { font-size: 14px; color: #6d4c00; margin-top: 2px; }
.setup-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .4em;
  margin-top: 6px; font-size: 30px; font-weight: 900; line-height: 1.25; color: #212121;
}
.setup-key { flex: 0 0 auto; color: #6d4c00; font-size: 22px; }
.setup-val { word-break: break-all; }

.controls { margin-bottom: 20px; }
.btn {
  font: inherit; border: none; border-radius: 14px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-start, .btn-end {
  display: block; width: 100%; min-height: 84px; margin-bottom: 10px;
  font-size: 28px; font-weight: bold; color: #fff; padding: 12px;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.btn-start { background: var(--start); }
.btn-end { background: var(--end); }
.btn-start:not(:disabled):active, .btn-end:not(:disabled):active { transform: translateY(2px); box-shadow: none; }
.sub-controls { display: flex; gap: 10px; }
.btn-undo, .btn-reset {
  flex: 1; min-height: 56px; font-size: 18px; font-weight: bold;
  background: #fff; color: #333; border: 2px solid #90a4ae;
}
.btn-reset { color: var(--late); border-color: var(--late); flex: 0 0 35%; }
.reset-confirm {
  margin-top: 10px; padding: 14px; border-radius: 12px;
  background: var(--late-bg); border: 2px solid var(--late);
}
.reset-confirm p { margin: 0 0 10px; font-size: 17px; font-weight: bold; color: var(--late); }
.reset-confirm-buttons { display: flex; gap: 10px; }
.btn-reset-do, .btn-reset-cancel { flex: 1; min-height: 56px; font-size: 18px; font-weight: bold; }
.btn-reset-do { background: var(--late); color: #fff; }
.btn-reset-cancel { background: #fff; color: #333; border: 2px solid #90a4ae; }
.btn-reset-all { display: block; width: 100%; margin-top: 10px; min-height: 48px; font-size: 16px; background: #fff;
  color: var(--late); border: 2px dashed var(--late); }

.schedule h2 { font-size: 20px; margin: 0 0 8px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.schedule-table { width: 100%; border-collapse: collapse; font-size: 17px; }
.schedule-table th, .schedule-table td { padding: 10px 8px; border-bottom: 1px solid #e0e0e0; text-align: left; white-space: nowrap; }
.schedule-table th { background: #eceff1; font-size: 14px; }
.schedule-table .col-name { white-space: normal; min-width: 8em; font-weight: bold; }
.schedule-table .col-time { font-variant-numeric: tabular-nums; }
.schedule-table .col-status { font-size: 14px; color: #555; }
.row-break td { background: #fafafa; color: #777; font-style: normal; }
.row-break .col-name { font-weight: normal; }
.row-done td { color: #888; }
.row-done .col-name { font-weight: normal; }
.row-running td { background: #e8f5e9; }
.row-running .col-status { color: var(--start); font-weight: bold; }
.row-next td { background: #fff8e1; }
.row-next .col-status { color: #8d6e00; font-weight: bold; }
.chip {
  display: inline-block; min-width: 3em; text-align: center; padding: 2px 8px;
  border-radius: 999px; font-weight: bold; font-variant-numeric: tabular-nums;
}
.chip.late { background: var(--late-bg); color: var(--late); }
.chip.early { background: var(--early-bg); color: var(--early); }
.chip.ontime { background: var(--ontime-bg); color: var(--ontime); }
.note { font-size: 14px; color: #555; }

@media (max-width: 720px) {
  .admin-header h1 { font-size: 17px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .summary-item:first-child { grid-column: 1 / -1; }
  .summary-value { font-size: 28px; }
  .stage { grid-template-columns: 1fr 1fr; }
  .slot-now { grid-column: 1 / -1; }
  .slot-now .slot-name { font-size: 34px; }
  .slot-name { font-size: 22px; }
  .setup-row { font-size: 26px; }
  .setup-key { font-size: 20px; }
  .btn-start, .btn-end { font-size: 24px; min-height: 80px; }
}

/* ============ 表示画面（係員向け・特大表示） ============ */
body.display { background: #000; color: #fff; min-height: 100vh; }
.disp {
  display: flex; flex-direction: column; gap: 3vh;
  min-height: 100vh; padding: 3vh 4vw; max-width: 1200px; margin: 0 auto;
}
.disp-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.disp-block { font-size: clamp(22px, 6vw, 48px); font-weight: 900; color: #000; background: #ffeb3b;
  padding: 0 .5em; border-radius: 10px; }
.disp-block:empty { display: none; }
.disp-clock { font-size: clamp(18px, 4.5vw, 32px); color: #bdbdbd; text-align: right; font-variant-numeric: tabular-nums; }
.disp-sync-warn {
  background: #b71c1c; color: #fff; text-align: center; font-weight: bold;
  font-size: clamp(14px, 3.5vw, 24px); padding: 6px 10px; border-radius: 10px;
}
.disp-sync-warn[hidden] { display: none; }

.disp-delay {
  text-align: center; font-weight: 900; border-radius: 20px; padding: 2vh 2vw;
  font-size: clamp(44px, 15vw, 140px); line-height: 1.1; letter-spacing: .02em;
}
.disp-delay.late { background: #ff1744; color: #fff; }
.disp-delay.early { background: #00e5ff; color: #000; }
.disp-delay.ontime { background: #424242; color: #fff; }

.disp-now { border: 4px solid #ffeb3b; border-radius: 20px; padding: 2vh 4vw; }
.disp-label { font-size: clamp(20px, 6vw, 44px); color: #ffeb3b; font-weight: bold; }
.disp-now-name {
  font-size: clamp(36px, 12vw, 110px); font-weight: 900; line-height: 1.15;
  margin: 1vh 0; word-break: break-all;
}
.disp-end { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 4vw; }
.disp-end-label { font-size: clamp(20px, 6vw, 44px); color: #e0e0e0; font-weight: bold; }
.disp-end-time { font-size: clamp(44px, 15vw, 130px); font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }

.disp-wait { display: flex; flex-direction: column; gap: 1.5vh; }
.disp-wait-row {
  display: flex; align-items: center; gap: 4vw;
  background: #212121; border-radius: 16px; padding: 1.5vh 4vw;
}
.disp-wait-label {
  flex: 0 0 auto; font-size: clamp(18px, 5vw, 36px); font-weight: bold; color: #000;
  background: #fff; border-radius: 10px; padding: .2em .5em;
}
.disp-wait-name { font-size: clamp(26px, 8vw, 72px); font-weight: bold; word-break: break-all; line-height: 1.2; }
