/* ビンゴカードメーカー＆抽選機 */

.bingo-app {
  max-width: 1080px;
  margin: 24px auto 40px;
  padding: 0 4px;
}

/* ===== タブ ===== */
.bingo-tabs {
  display: flex;
  border: 1px solid #ccc;
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 20px;
}

.bingo-tab {
  flex: 1;
  padding: 13px 6px;
  font-size: 14.5px;
  font-weight: 600;
  background: #fff;
  color: #555;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.bingo-tab + .bingo-tab {
  border-left: 1px solid #ccc;
}

.bingo-tab.active {
  background: var(--accent, #2a9d8f);
  color: #fff;
}

/* ===== カード系パネル共通（フォーム＋プレビュー2カラム） ===== */
.bg-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  text-align: left;
}

.bg-form {
  width: 360px;
  flex-shrink: 0;
  text-align: left;
}

.bg-form .fs-title {
  font-size: 15px;
  font-weight: 700;
  color: #333;
  margin: 18px 0 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--accent, #2a9d8f);
}

.bg-form .fs-title:first-child {
  margin-top: 0;
}

.bg-form input[type='text'],
.bg-form input[type='number'],
.bg-form textarea {
  width: 100%;
  padding: 9px 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #333;
  box-sizing: border-box;
}

.bg-form textarea {
  min-height: 170px;
  line-height: 1.7;
  resize: vertical;
}

.bg-form .radio-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  margin-top: 6px;
}

.bg-form .radio-line label {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  font-size: 13.5px;
  color: #333;
  cursor: pointer;
}

.bg-form .field-hint {
  font-size: 11.5px;
  color: #888;
  margin: 6px 0 0;
  line-height: 1.6;
}

.bg-form .num-line {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
}

.bg-form .num-line input {
  width: 90px;
}

.bg-form .num-line .unit {
  font-size: 13.5px;
  color: #333;
}

.bg-seed-btn,
.bg-sample-btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--accent, #2a9d8f);
  border-radius: 6px;
  background: #fff;
  color: var(--accent, #2a9d8f);
  cursor: pointer;
  white-space: nowrap;
}

.bg-seed-btn:hover,
.bg-sample-btn:hover {
  background: var(--accent, #2a9d8f);
  color: #fff;
}

.bg-sample-btn {
  margin-top: 8px;
}

.bg-info {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent, #2a9d8f);
  margin: 16px 0 0;
}

.bg-info.warn {
  color: #c0392b;
}

/* --- プレビュー側 --- */
.bg-preview {
  flex: 1;
  min-width: 0;
  position: sticky;
  top: 16px;
  align-self: flex-start;
  text-align: center;
}

.bg-print-btn {
  width: 100%;
  background: var(--accent, #2a9d8f);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.bg-print-btn:hover {
  opacity: 0.85;
}

.bg-print-btn:disabled {
  background: #cbd5e1;
  cursor: default;
}

.bg-print-note {
  font-size: 12px;
  color: #888;
  margin: 8px 0 12px;
  line-height: 1.5;
}

.bg-need-box {
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 28px 16px;
  font-size: 14px;
  color: #555;
  line-height: 1.8;
  background: #f8fafc;
}

.bg-preview-caption {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
}

/* ===== A4シート ===== */
.bg-sheet-box {
  overflow: hidden;
  border-radius: 4px;
}

.bg-sheet-box + .bg-sheet-box {
  margin-top: 16px;
}

.bg-sheet {
  width: 210mm;
  height: 297mm;
  background: #fff;
  box-sizing: border-box;
  position: relative;
  transform-origin: top left;
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
  font-family: 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'YuGothic', 'Meiryo', sans-serif;
  text-align: left;
}

/* common.cssのレガシーグローバル対策 */
.bg-sheet * {
  font-size: inherit;
  color: inherit;
  font-family: inherit;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* --- 面付けブロック --- */
.bg-block {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bg-sheet.layout-1 .bg-block {
  width: 210mm;
  height: 297mm;
  padding: 16mm;
}

.bg-sheet.layout-2 .bg-block {
  width: 210mm;
  height: 148.5mm;
  padding: 8mm 20mm;
}

.bg-sheet.layout-2 .bg-block + .bg-block {
  border-top: 0.3mm dashed #999;
}

.bg-sheet.layout-2 .bg-block + .bg-block::before {
  content: '✂';
  position: absolute;
  left: 4mm;
  top: -2.4mm;
  font-size: 3.6mm;
  color: #999;
  background: #fff;
  padding: 0 1mm;
  line-height: 1;
}

.bg-sheet.layout-4 {
  display: flex;
  flex-wrap: wrap;
}

.bg-sheet.layout-4 .bg-block {
  width: 105mm;
  height: 148.5mm;
  padding: 7mm 8mm;
}

.bg-sheet.layout-4 .bg-block:nth-child(odd) {
  border-right: 0.3mm dashed #999;
}

.bg-sheet.layout-4 .bg-block:nth-child(-n + 2) {
  border-bottom: 0.3mm dashed #999;
}

/* --- カード --- */
.bg-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.bg-card-title {
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: 0.06em;
  margin-bottom: 3mm;
  max-width: var(--gw);
  text-align: center;
  line-height: 1.3;
}

.bg-head {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: var(--gw);
  border: 0.5mm solid #1a1a1a;
  border-bottom: none;
  background: #1a1a1a;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.bg-head span {
  text-align: center;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.1em;
  padding: 1mm 0;
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(var(--size, 5), 1fr);
  grid-auto-rows: calc(var(--gw) / var(--size, 5));
  width: var(--gw);
  border-left: 0.5mm solid #1a1a1a;
  border-top: 0.5mm solid #1a1a1a;
}

.bg-cell {
  border-right: 0.5mm solid #1a1a1a;
  border-bottom: 0.5mm solid #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  color: #1a1a1a;
  font-size: calc(var(--gw) / var(--size, 5) * var(--fs, 0.38));
  line-height: 1.25;
  padding: 4%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.bg-card.is-word .bg-cell {
  --fs: 0.17;
}

.bg-cell.free {
  --fs: 0.2;
  background: #efefef;
  font-weight: 700;
  letter-spacing: 0.08em;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.bg-card.is-word .bg-cell.free {
  --fs: 0.14;
}

.bg-card-meta {
  width: var(--gw);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 1.6mm;
  color: #888;
}

/* --- レイアウト別サイズ --- */
.bg-sheet.layout-1 .bg-card {
  --gw: 162mm;
}

.bg-sheet.layout-1 .bg-card-title {
  font-size: 19pt;
}

.bg-sheet.layout-1 .bg-head span {
  font-size: 17pt;
}

.bg-sheet.layout-1 .bg-card-meta {
  font-size: 9pt;
}

.bg-sheet.layout-2 .bg-card {
  --gw: 108mm;
}

.bg-sheet.layout-2 .bg-card-title {
  font-size: 13.5pt;
  margin-bottom: 2mm;
}

.bg-sheet.layout-2 .bg-head span {
  font-size: 11.5pt;
}

.bg-sheet.layout-2 .bg-card-meta {
  font-size: 7.5pt;
}

.bg-sheet.layout-4 .bg-card {
  --gw: 84mm;
}

.bg-sheet.layout-4 .bg-card-title {
  font-size: 11pt;
  margin-bottom: 1.6mm;
}

.bg-sheet.layout-4 .bg-head span {
  font-size: 9.5pt;
}

.bg-sheet.layout-4 .bg-card-meta {
  font-size: 7pt;
}

/* ===== 抽選機 ===== */
.bd-stage {
  background: #16213a;
  border-radius: 14px;
  padding: 20px 22px 26px;
  color: #fff;
  text-align: center;
}

.bd-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
  flex-wrap: wrap;
}

.bd-range {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #cbd5e1;
}

.bd-range input {
  width: 62px;
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid #475569;
  border-radius: 6px;
  background: #0f172a;
  color: #fff;
  text-align: center;
}

.bd-range input:disabled {
  opacity: 0.5;
}

.bd-topbtns {
  display: flex;
  gap: 8px;
}

.bd-iconbtn {
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #475569;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  cursor: pointer;
}

.bd-iconbtn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.bd-main {
  margin: 8px 0 4px;
}

.bd-current {
  font-size: clamp(88px, 19vw, 168px);
  font-weight: 800;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: #fff;
  min-height: 1.1em;
}

.bd-current.rolling {
  color: #94a3b8;
}

.bd-current.landed {
  animation: bd-pop 0.45s ease;
}

@keyframes bd-pop {
  0% {
    transform: scale(0.6);
  }
  55% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.bd-sub {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 22px;
  margin: 2px 0 14px;
  font-size: 14px;
  color: #94a3b8;
}

.bd-prev-num {
  font-size: 30px;
  font-weight: 700;
  color: #fbbf24;
  font-variant-numeric: tabular-nums;
}

.bd-draw-btn {
  background: #f59e0b;
  color: #1a1a1a;
  border: none;
  border-radius: 12px;
  padding: 16px 54px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 4px 0 #b45309;
  transition: transform 0.08s ease, box-shadow 0.08s ease, opacity 0.2s ease;
}

.bd-draw-btn:hover {
  transform: translateY(1px);
  box-shadow: 0 3px 0 #b45309;
}

.bd-draw-btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
}

.bd-key-hint {
  font-size: 11.5px;
  color: #64748b;
  margin-top: 10px;
}

.bd-hist {
  margin-top: 22px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 14px 14px 12px;
}

.bd-hist-title {
  font-size: 12.5px;
  font-weight: 600;
  color: #94a3b8;
  margin: 0 0 10px;
  text-align: left;
}

.bd-hist-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.bd-hist-row + .bd-hist-row {
  margin-top: 5px;
}

.bd-hist-label {
  width: 24px;
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 800;
  color: #fbbf24;
  text-align: center;
}

.bd-hist-cells {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(var(--cols, 15), 1fr);
  gap: 4px;
}

.bd-cell-h {
  aspect-ratio: 1;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(9px, 1.6vw, 14px);
  font-variant-numeric: tabular-nums;
}

.bd-cell-h.hit {
  background: #f59e0b;
  color: #1a1a1a;
  font-weight: 700;
}

.bd-cell-h.last {
  outline: 2.5px solid #fff;
  outline-offset: 1px;
}

.bd-bottombar {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bd-save-note {
  font-size: 11.5px;
  color: #64748b;
  text-align: left;
}

.bd-reset-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #7f1d1d;
  border-radius: 8px;
  background: rgba(220, 38, 38, 0.12);
  color: #fca5a5;
  cursor: pointer;
}

.bd-reset-btn:hover {
  background: rgba(220, 38, 38, 0.28);
}

/* 全画面表示（プロジェクタ投影用） */
.bd-stage:fullscreen {
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3vh 5vw;
  overflow: auto;
}

.bd-stage:fullscreen .bd-current {
  font-size: min(34vh, 26vw);
}

.bd-stage:fullscreen .bd-prev-num {
  font-size: 5vh;
}

.bd-stage:fullscreen .bd-sub {
  font-size: 2.4vh;
}

.bd-stage:fullscreen .bd-draw-btn {
  font-size: 3.4vh;
  padding: 2vh 8vw;
}

.bd-stage:fullscreen .bd-hist {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* ===== レスポンシブ ===== */
@media (max-width: 940px) {
  .bg-layout {
    flex-direction: column;
  }

  .bg-form {
    width: 100%;
  }

  .bg-preview {
    position: static;
    width: 100%;
  }

  .bd-stage {
    padding: 14px 12px 20px;
  }

  .bd-hist-label {
    width: 16px;
    font-size: 12px;
  }
}

/* ===== 印刷用：表示中タブのシートだけをA4原寸で ===== */
@media print {
  @page {
    size: A4;
    margin: 0;
  }

  html,
  body {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    height: auto !important;
  }

  body > *:not(.container) {
    display: none !important;
  }

  .container {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    width: auto !important;
  }

  .container > *:not(.bingo-app) {
    display: none !important;
  }

  .bingo-app {
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .bingo-app > *:not(.bg-panel) {
    display: none !important;
  }

  .bg-panel[hidden] {
    display: none !important;
  }

  .bg-panel#bingoPanelDraw {
    display: none !important;
  }

  .bg-layout {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .bg-layout > *:not(.bg-preview) {
    display: none !important;
  }

  .bg-preview {
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
  }

  .bg-preview > *:not(.bg-sheet-wrap) {
    display: none !important;
  }

  .bg-sheet-box {
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    border-radius: 0 !important;
    break-after: page;
    page-break-after: always;
  }

  .bg-sheet-box:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .bg-sheet {
    transform: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    width: 210mm !important;
    height: 296mm !important;
    overflow: hidden !important;
  }

  .bg-sheet.layout-1 .bg-block,
  .bg-sheet.layout-2 .bg-block:last-child {
    height: auto;
    min-height: 0;
  }

  .bg-sheet.layout-1 .bg-block {
    height: 296mm;
  }

  .bg-sheet.layout-2 .bg-block:last-child {
    height: 147.5mm;
  }

  .bg-sheet.layout-4 .bg-block:nth-child(n + 3) {
    height: 147.5mm;
  }
}
