* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --bg-main: #111315;
  --bg-surface: #1b1f23;
  --bg-card: #252a30;
  --text-main: #ffffff;
  --text-muted: #9ca3af;
  --accent-primary: #ffbc0d;
  --accent-secondary: #db0007;
  --ready-bg: #0f291e;
  --ready-header: #15803d;
  --ready-card: #16a34a;
  --ready-text: #ffffff;
  --waiting-header: #374151;
  --waiting-card: #262b31;
  --waiting-text: #f3f4f6;
  --border-color: rgba(255, 255, 255, 0.1);
}

/* 🍨 サーティワン（バスキン・ロビンス）風テーマ */
body.theme-br31 {
  --bg-main: #fff5f9;
  --bg-surface: #ffffff;
  --bg-card: #fce7f3;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --accent-primary: #ec008c;
  --accent-secondary: #1f3a93;
  --ready-bg: #fdf2f8;
  --ready-header: #ec008c;
  --ready-card: #ec008c;
  --ready-text: #ffffff;
  --waiting-header: #1f3a93;
  --waiting-card: #eff6ff;
  --waiting-text: #1f3a93;
  --border-color: rgba(31, 58, 147, 0.15);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.25s ease, color 0.25s ease;
}

.hidden {
  display: none !important;
}

/* 上部ナビバー */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border-color);
  flex-wrap: wrap;
  z-index: 20;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-primary);
  color: #111;
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

body.theme-br31 .brand-badge {
  color: #fff;
}

.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.pill-sub {
  background: rgba(128, 128, 128, 0.25);
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.72rem;
}

.conn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 6px #f59e0b;
}

.conn-dot.online {
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
}

.topbar-center {
  flex: 1;
  max-width: 260px;
  min-width: 150px;
}

.auto-progress-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 3px;
  text-align: center;
  font-weight: 700;
}

.auto-progress-track {
  height: 6px;
  background: rgba(128, 128, 128, 0.25);
  border-radius: 999px;
  overflow: hidden;
}

.auto-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  transition: width 0.15s linear;
}

.top-btn {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.sound-btn.sound-on {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}

.mode-switch-group {
  display: inline-flex;
  background: var(--bg-card);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid var(--border-color);
}

.mode-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.mode-tab.active {
  background: var(--accent-primary);
  color: #111;
}

body.theme-br31 .mode-tab.active {
  color: #fff;
}

/* ランディング画面 */
.landing-view {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.landing-card {
  max-width: 760px;
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.landing-badge {
  display: inline-block;
  background: var(--accent-primary);
  color: #111;
  font-weight: 800;
  font-size: 0.8rem;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}

body.theme-br31 .landing-badge {
  color: #fff;
}

.landing-card h1 {
  font-size: 1.7rem;
  margin-bottom: 10px;
}

.landing-desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 26px;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.role-card {
  background: var(--bg-card);
  color: var(--text-main);
  border: 2px solid var(--border-color);
  border-radius: 18px;
  padding: 24px 20px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.role-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-primary);
}

.role-emoji {
  font-size: 2.4rem;
}

.role-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.role-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.role-cta {
  display: inline-block;
  margin-top: 8px;
  font-weight: 800;
  color: var(--accent-primary);
}

/* 🖥️ モニター画面 */
.monitor-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.audio-unlock-banner {
  background: #f59e0b;
  color: #111;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
}

.unlock-cta {
  background: #111;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 5px 14px;
  font-weight: 800;
  cursor: pointer;
}

.monitor-board {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 64px);
}

.board-col {
  background: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.col-ready {
  background: var(--ready-bg);
  border-color: var(--ready-header);
}

.col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  color: #fff;
}

.waiting-header {
  background: var(--waiting-header);
}

.ready-header {
  background: var(--ready-header);
}

.col-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.col-icon {
  font-size: 2rem;
}

.col-title {
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.col-subtitle {
  font-size: 0.78rem;
  opacity: 0.88;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.col-count {
  background: rgba(0, 0, 0, 0.28);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 900;
}

.number-grid {
  padding: 20px;
  display: grid;
  gap: 14px;
  align-content: start;
  flex: 1;
}

.waiting-grid {
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
}

.ready-grid {
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
}

.num-tile {
  border-radius: 14px;
  font-weight: 900;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  user-select: none;
}

.waiting-tile {
  background: var(--waiting-card);
  color: var(--waiting-text);
  padding: 16px 10px;
  font-size: 2.3rem;
  border: 2px solid var(--border-color);
}

.ready-tile {
  background: var(--ready-card);
  color: var(--ready-text);
  padding: 22px 12px;
  font-size: 3.3rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  animation: popIn 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.ready-tile.latest {
  outline: 5px solid var(--accent-primary);
  transform: scale(1.03);
}

.empty-board-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 1.15rem;
  font-weight: 700;
}

/* 大型呼び出しポップアップ */
.call-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.18s ease;
}

.call-popup-card {
  background: var(--bg-surface);
  border: 6px solid var(--accent-primary);
  border-radius: 32px;
  padding: 40px 56px;
  text-align: center;
  max-width: 680px;
  width: 100%;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  animation: popupBounce 0.38s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.popup-tag {
  display: inline-block;
  background: var(--accent-primary);
  color: #111;
  font-size: 1.4rem;
  font-weight: 900;
  padding: 8px 26px;
  border-radius: 999px;
  margin-bottom: 16px;
}

body.theme-br31 .popup-tag {
  color: #fff;
}

.popup-num {
  font-size: 8.5rem;
  font-weight: 900;
  line-height: 1.05;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
  margin: 10px 0 16px;
  text-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

body.theme-br31 .popup-num {
  color: var(--accent-secondary);
}

.popup-msg {
  font-size: 1.65rem;
  font-weight: 800;
}

/* 📱 iPhone スタッフ操作画面 */
.staff-view {
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  padding: 14px 14px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.staff-control-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.staff-ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ctrl-title {
  font-weight: 800;
  font-size: 1rem;
}

.ctrl-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.toggle-pill {
  min-width: 74px;
  padding: 9px 16px;
  border-radius: 999px;
  border: none;
  font-weight: 900;
  font-size: 0.9rem;
  background: #4b5563;
  color: #fff;
  cursor: pointer;
}

.toggle-pill.active {
  background: #16a34a;
}

.staff-quick-actions {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 10px;
}

.action-btn {
  border: none;
  border-radius: 14px;
  padding: 15px 12px;
  font-size: 1rem;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.action-btn:active {
  transform: scale(0.97);
}

.btn-primary-call {
  background: var(--accent-primary);
  color: #111;
}

body.theme-br31 .btn-primary-call {
  color: #fff;
}

.btn-issue-manual {
  background: var(--bg-card);
  color: var(--text-main);
  border: 2px solid var(--border-color);
}

.staff-theme-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
}

.theme-row-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 700;
}

.theme-chip {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
}

.theme-chip.active {
  border-color: var(--accent-primary);
  background: var(--accent-primary);
  color: #111;
}

body.theme-br31 .theme-chip.active {
  color: #fff;
}

.staff-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.staff-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.staff-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.staff-panel-header h3 {
  font-size: 1rem;
  font-weight: 800;
}

.badge-count {
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.ready-badge {
  background: #16a34a;
  color: #fff;
}

.staff-waiting-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.staff-wait-btn {
  background: var(--waiting-card);
  color: var(--waiting-text);
  border: 2px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.staff-wait-btn:active {
  transform: scale(0.95);
  border-color: var(--accent-primary);
}

.staff-wait-num {
  font-size: 1.65rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.staff-wait-sub {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent-primary);
}

.staff-ready-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.staff-ready-row {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.staff-ready-num {
  font-size: 1.85rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #22c55e;
}

body.theme-br31 .staff-ready-num {
  color: var(--accent-primary);
}

.staff-ready-btns {
  display: flex;
  gap: 8px;
}

.btn-recall {
  background: #f59e0b;
  color: #111;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-complete {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 0.85rem;
  cursor: pointer;
}

.staff-footer {
  text-align: center;
  margin-top: 8px;
}

.btn-danger-outline {
  background: transparent;
  color: #ef4444;
  border: 1px solid #ef4444;
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
}

/* モーダル */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}

.modal-card {
  background: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-close {
  background: var(--bg-card);
  color: var(--text-main);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-weight: 800;
  cursor: pointer;
}

.modal-text {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.qr-box {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  margin-bottom: 16px;
}

#qrImage {
  width: 180px;
  height: 180px;
  display: block;
  margin: 0 auto 10px;
}

.url-copy-box {
  display: flex;
  gap: 6px;
}

.url-copy-box input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 0.8rem;
  color: #0f172a;
}

.url-copy-box button {
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.room-input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.room-input-row {
  display: flex;
  gap: 8px;
}

.room-input-row input {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.btn-save-room {
  background: var(--accent-primary);
  color: #111;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 800;
  cursor: pointer;
}

body.theme-br31 .btn-save-room {
  color: #fff;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes popupBounce {
  0% {
    opacity: 0;
    transform: scale(0.75);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .monitor-board {
    grid-template-columns: 1fr;
  }
  .popup-num {
    font-size: 5.5rem;
  }
  .staff-quick-actions {
    grid-template-columns: 1fr;
  }
}
