:root {
  --ink: #2b2420;
  --paper: #efe6d2;
  --paper2: #e6dabf;
  --beni: #b5473a;
  --ai: #2f4b6e;
  --wood: #5e3d2a;
  --font: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #16120f;
  color: var(--ink);
  font-family: var(--font);
  overflow: hidden;
}

/* ---- 壁 */
#stage {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(100vw, calc(100vh * 1920 / 820));
  aspect-ratio: 1920 / 820;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage canvas[hidden] { display: none; }
#stage::before, #stage::after { content: ""; position: absolute; inset: 0; pointer-events: none; display: none; }
#stage.triptych::before {
  display: block;
  background:
    linear-gradient(90deg, transparent calc(33.33% - 1.2%), #16120f calc(33.33% - 1.2%), #16120f calc(33.33% + 1.2%), transparent calc(33.33% + 1.2%)),
    linear-gradient(90deg, transparent calc(66.66% - 1.2%), #16120f calc(66.66% - 1.2%), #16120f calc(66.66% + 1.2%), transparent calc(66.66% + 1.2%));
}
#stage.lattice::after {
  display: block;
  background:
    repeating-linear-gradient(90deg, rgba(60, 40, 25, 0.85) 0 6px, transparent 6px 16.6%),
    repeating-linear-gradient(0deg, rgba(60, 40, 25, 0.85) 0 6px, transparent 6px 33.3%);
  box-shadow: inset 0 0 0 14px #4a3220;
  mix-blend-mode: multiply;
}

/* ---- ボタン群 */
.corner {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  z-index: 20;
  opacity: 0.35;
  transition: opacity 0.2s;
}
.corner:hover { opacity: 1; }
body.bare .corner { display: none; }
.corner button, .fb-btn {
  font: inherit;
  font-size: 15px;
  padding: 8px 14px;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  border-radius: 2px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.fb-btn.primary { background: var(--beni); color: #f6ecd8; border-color: #6e2a20; }
.fb-btn:active { transform: translateY(1px); }

/* ---- 札場の引き出し */
#drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(420px, 100vw);
  background: var(--paper);
  border-left: 6px solid var(--wood);
  transform: translateX(105%);
  transition: transform 0.35s ease;
  z-index: 30;
  overflow-y: auto;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.4);
}
#drawer.open { transform: none; }
#drawer .close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--ink); }

.fudaba { padding: 22px 22px 40px; min-height: 100%; }
.fb-step { display: flex; flex-direction: column; gap: 12px; }
.fb-title {
  font-size: 26px;
  letter-spacing: 0.3em;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 6px;
}
.fb-lead { font-size: 17px; margin: 0; line-height: 1.6; }
.fb-note { font-size: 13px; color: #6b5d50; margin: 0; line-height: 1.6; }
.fb-scan { display: flex; gap: 8px; }
.fb-id {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 22px;
  letter-spacing: 0.08em;
  padding: 8px 10px;
  border: 1.5px solid var(--ink);
  background: #faf5ea;
}
.fb-link { font: inherit; font-size: 14px; background: none; border: 0; color: var(--ai); text-decoration: underline; cursor: pointer; align-self: flex-start; padding: 0; }
.fb-check { font-size: 14px; }
.fb-row { display: flex; gap: 8px; flex-wrap: wrap; }
fieldset { border: 1px solid #b6a68a; padding: 8px 12px 10px; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
legend { font-size: 13px; color: #6b5d50; padding: 0 4px; }
.fudaba [hidden] { display: none !important; }
.fb-cam { position: relative; width: 100%; background: #2b2420; margin-top: 2px; line-height: 0; }
.fb-view { display: block; margin: 0 auto; width: auto; height: auto; max-width: 100%; max-height: 68vh; }
.fb-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 120px; line-height: 1; color: #f6ecd8; text-shadow: 0 0 12px #000; pointer-events: none; }
.fb-busy { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px; background: rgba(43,36,32,0.78); color: #f6ecd8; font-size: 15px; line-height: 1.6; }
.fb-busy .fb-brush { margin-bottom: 6px; }
.fb-why { display: block; color: var(--beni); font-weight: 700; }
.fb-alt { gap: 18px; }
.fb-confirm { display: grid; grid-template-columns: 3fr 1fr; gap: 8px; align-items: end; }
.fb-stage { width: 100%; height: auto; border: 1px solid var(--ink); background: #efe6d2; }
.fb-pics { display: grid; gap: 6px; }
.fb-pic { width: 100%; height: auto; border: 1px solid var(--ink); background: #efe6d2; }
.fb-cands { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fb-cand {
  font: inherit;
  font-size: 13px;
  border: 1.5px solid var(--ink);
  background: var(--paper2);
  padding: 4px 4px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.fb-cand:hover { background: #f6ecd8; outline: 3px solid var(--beni); }
.fb-cand canvas { width: 100%; height: auto; }
.fb-hair { display: flex; gap: 6px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.fb-chip { font: inherit; font-size: 13px; padding: 3px 8px; border: 1px solid var(--ink); background: none; cursor: pointer; border-radius: 12px; }
.fb-chip.on { background: var(--ink); color: var(--paper); }
.fb-brush { height: 10px; background: #d8ccb2; overflow: hidden; position: relative; }
.fb-brush i { position: absolute; inset: 0; width: 40%; background: var(--ink); animation: brush 1.6s ease-in-out infinite; }
@keyframes brush { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.fb-time { font-size: 28px; margin: 0; }
.fb-done canvas { width: 150px; border: 1px solid var(--ink); }
.fb-times { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; font-size: 14px; margin: 0; }
.fb-times dd { margin: 0; text-align: right; }
.fb-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 14px; }
.fb-tab { font: inherit; font-size: 15px; padding: 5px 12px; border: 1.5px solid var(--ink); background: none; cursor: pointer; }
.fb-tab.on { background: var(--ink); color: var(--paper); }
.fb-tab:disabled { opacity: 0.35; cursor: default; }
.fb-side3d { font-size: 13px; color: #6b5d50; margin-left: 4px; }
.fb-art { position: relative; min-height: 220px; display: flex; align-items: center; justify-content: center; background: #2b2420; padding: 10px; }
.fb-art.busy::after { content: '刷っています…'; position: absolute; right: 10px; bottom: 8px; color: #f6ecd8; font-size: 13px; }
.fb-art-wait { color: #f6ecd8; margin: 0; }
.fb-sheet { display: block; max-width: 100%; height: auto; box-shadow: 0 4px 16px rgba(0,0,0,0.45); }
.fb-sheet.figure, .fb-sheet.okubi { max-height: 70vh; width: auto; }
.fb-sheet.scene { max-height: 60vh; width: auto; }
.fb-btn:disabled { opacity: 0.45; cursor: default; }

/* ---- 操作盤 */
#hud {
  position: fixed;
  left: 12px;
  top: 12px;
  width: 340px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(239, 230, 210, 0.96);
  border: 1.5px solid var(--ink);
  padding: 12px 14px;
  font-size: 13px;
  z-index: 25;
  display: none;
}
#hud.open { display: block; }
#hud h3 { margin: 0 0 6px; font-size: 15px; letter-spacing: 0.1em; }
#hud h4 { margin: 10px 0 4px; font-size: 13px; border-bottom: 1px solid #b6a68a; }
#hud label { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 3px 0; }
#hud input[type="number"] { width: 70px; font: inherit; }
#hud select { font: inherit; }
#hud input[type="range"] { width: 140px; }
#hud .btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
#hud .btns button { font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--ink); background: #faf5ea; cursor: pointer; }
#hud .btns button.primary { background: var(--beni); color: #f6ecd8; }
#stats { line-height: 1.7; font-size: 12.5px; }
#res8 { font-size: 12.5px; color: var(--ai); min-height: 1em; }

/* ---- 今日の一枚 */
#today {
  position: fixed;
  inset: 0;
  background: rgba(22, 18, 15, 0.92);
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}
#today.open { display: flex; }
#today .pic img { max-width: min(96vw, 1600px); max-height: 74vh; display: block; box-shadow: 0 0 40px #000; }
#today .info { color: #e9dcc0; font-size: 14px; max-width: 1100px; text-align: center; line-height: 1.6; }
#today .info b { color: #ffb4a0; }

@media (max-width: 600px) {
  #hud { width: calc(100vw - 24px); }
  .fudaba { padding: 18px 16px 40px; }
}
/* Web 版の説明と同意・アンケート（2026-11-17） */
.fb-consent-list { margin: 0; padding-left: 1.2em; font-size: 16px; line-height: 1.7; }
.fb-consent-list li { margin: 2px 0; }
.fb-consent .fb-check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; line-height: 1.5; }
.fb-consent .fb-check input { margin-top: 4px; }
.fb-btn:disabled { opacity: 0.45; cursor: default; }
.fb-survey-box { border-top: 2px solid var(--ink); margin-top: 8px; padding-top: 10px; }
.fb-survey { display: flex; flex-direction: column; gap: 14px; }
.fb-survey-title { font-size: 20px; }
.fb-q-label { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.fb-likert { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12px; color: #6b5d50; }
.fb-likert .fb-tab { min-width: 40px; }
.fb-comment { width: 100%; box-sizing: border-box; font: inherit; font-size: 15px; padding: 6px; border: 1.5px solid var(--ink); background: #fbf6ea; }
.fb-opt { gap: 16px; font-size: 14px; }
.fb-opt select { font: inherit; font-size: 14px; }
.fb-ab-pics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fb-ab-card { font: inherit; padding: 4px; border: 2px solid transparent; background: #2b2420; color: #f6ecd8; cursor: pointer; display: flex; flex-direction: column; gap: 4px; align-items: center; }
.fb-ab-card.on { border-color: var(--beni); outline: 3px solid var(--beni); }
