/* ============================================================
   booth.css — お試し謎ページの見た目

   ■ 見た目の決まり
     ・押すもの：生成りの面・墨の縁 3px・厚み 0 5px 0（ぼかさない）・押すと5px沈む（70ms steps(2)）
     ・面の色＝状態：生成り＝押せる／臙脂＝選ばれている・確認できた／灰＝選べる／墨＝閉じる
     ・額縁：墨の縁に金の細線
     ・画面の下に寄せる物は --safe-bottom（画面の下の帯の高さ）だけ持ち上げる
   ■ 部屋の中で一番明るいのは押すもの（生成り）。額縁の紙はそれより少し暗くしてある
   ============================================================ */

:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --sumi: #1c1c20;
  --gold: #c9a84c;
  --paper: #e4dcc8;

  --ctl2-stage: #17171d;
  --ctl2-ink: #16161a;
  --ctl2-paper: #f2ead6;
  --ctl2-paper-step: #16161a;
  --ctl2-enji: #a8323f;
  --ctl2-enji-step: #1b1a1a;
  --ctl2-grey: #8a857a;
  --ctl2-grey-step: #0c0c10;
  --ctl2-on-paper: #16161a;
  --ctl2-on-ink: #f2ead6;
  --ctl2-label: rgba(242, 234, 214, .66);
  --ctl2-muted: rgba(242, 234, 214, .62);
  --ctl2-focus: #f2ead6;
  --ctl2-lift: 5px;
  --ctl2-radius: 3px;
  --ctl2-border: 3px;

  --font: 'Noto Sans JP', sans-serif;

  --bob-px: 4px;
  --bob-ms: 420ms;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  overflow: hidden;
  background: var(--sumi);
  color: var(--ctl2-on-ink);
  font-family: var(--font);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.svg-filters {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ico {
  width: 24px;
  height: 24px;
  flex: none;
  display: block;
  fill: currentColor;
}

/* ── 押すもの ── */
.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 56px;
  min-width: 56px;
  padding: 0 16px;
  border: var(--ctl2-border) solid var(--ctl2-ink);
  border-radius: var(--ctl2-radius);
  background: var(--ctl2-paper);
  color: var(--ctl2-on-paper);
  box-shadow: 0 var(--ctl2-lift) 0 var(--ctl2-paper-step);
  font-family: var(--font);
  font-size: 16.5px;
  font-weight: 900;
  letter-spacing: .02em;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 70ms steps(2),
    box-shadow 70ms steps(2),
    background 70ms steps(2);
}

.ctl:active {
  transform: translateY(var(--ctl2-lift));
  box-shadow:
    0 0 0 var(--ctl2-paper-step),
    inset 0 2px 5px rgba(0, 0, 0, .38);
}

.ctl:focus-visible {
  outline: 3px solid var(--ctl2-focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .ctl {
    transition: none;
  }

  .ctl:active {
    transform: none;
  }
}

.ctl-on {
  background: var(--ctl2-enji);
  color: var(--ctl2-on-ink);
  box-shadow: 0 var(--ctl2-lift) 0 var(--ctl2-enji-step);
}

.ctl-on:active {
  box-shadow: 0 0 0 var(--ctl2-enji-step), inset 0 2px 5px rgba(0, 0, 0, .38);
}

.ctl-off {
  background: var(--ctl2-grey);
  color: var(--ctl2-on-paper);
  box-shadow: 0 var(--ctl2-lift) 0 var(--ctl2-grey-step);
}

.ctl-off:active {
  box-shadow: 0 0 0 var(--ctl2-grey-step), inset 0 2px 5px rgba(0, 0, 0, .38);
}

.ctl-exit {
  background: var(--ctl2-ink);
  border-color: var(--ctl2-paper);
  color: var(--ctl2-on-ink);
  box-shadow: 0 6px 0 #000;
}

.ctl-exit:active {
  box-shadow: 0 0 0 #000, inset 0 2px 5px rgba(0, 0, 0, .5);
}

.ctl-row {
  display: flex;
  width: 100%;
  height: 74px;
  min-height: 74px;
  justify-content: flex-start;
  padding: 0 16px 0 10px;
  text-align: left;
}

.ctl-row .ico {
  width: 36px;
  height: 36px;
}

.ctl-row-state {
  margin-left: auto;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .16em;
  opacity: .72;
}

.ctl-toggle {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* 1回転の案内の額縁の中の、スマホを持ってその場で1回転する人（2026-10-07 作者の注文）。
   人は動かさず、足もとの輪だけが回る（輪の一か所だけ臙脂にして、回っていることを見せる）。
   人の形は Phosphor Icons の person-simple（fill・MIT。細身）。揺れを減らす設定では輪を止める */
.spin-figure {
  display: flex;
  justify-content: center;
  margin: -6px 0 26px;
  perspective: 300px;
}

.spin-stage {
  position: relative;
  width: 96px;
  height: 92px;
}

.spin-ring {
  position: absolute;
  left: 50%;
  bottom: -30px;
  width: 84px;
  height: 84px;
  margin-left: -42px;
  border: 3px solid rgba(22, 22, 26, .28);
  border-top-color: var(--ctl2-enji);
  border-radius: 50%;
  transform: rotateX(74deg);
  animation: spin-ring 1.8s linear infinite;
}

@keyframes spin-ring {
  from { transform: rotateX(74deg) rotateZ(0deg); }
  to { transform: rotateX(74deg) rotateZ(360deg); }
}

.spin-person {
  position: absolute;
  left: 50%;
  top: 0;
  width: 84px;
  height: 96px;
  margin-left: -42px;
  fill: var(--ctl2-ink);
}

.spin-phone {
  fill: var(--ctl2-enji);
}

@media (prefers-reduced-motion: reduce) {
  .spin-ring {
    animation: none;
  }
}

/* 額縁の紙の中に置く。部屋の物は押す操作を通す作りなので、ここだけ受け取り直す */
.first-btn {
  width: calc(100% - 36px);
  letter-spacing: .12em;
  pointer-events: auto;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 2000;
  font-size: 14px;
  color: var(--ctl2-on-ink);
}

/* ── 部屋 ── */
.room {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: block;
  overflow: hidden;
  overflow: clip;
  background: var(--sumi);
}

.room-wall {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(-1 * var(--bob-px) - 4px);
  bottom: calc(-1 * var(--bob-px) - 4px);
  z-index: 2;
  pointer-events: none;
  background-image: url("../images/wall.webp");
  background-repeat: repeat-x;
  background-position-y: center;
  filter: saturate(0.72) brightness(0.85);
}

.room-wall::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 44%,
      rgba(28, 28, 32, 0) 26%,
      rgba(28, 28, 32, 0.45) 100%);
}

.room-objects {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.room-object {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
}

/* 向きを変えたときの揺れ（見た目だけ）。上へ2歩ぶん */
@keyframes room-bob {
  0%   { transform: translateY(0); }
  25%  { transform: translateY(calc(-1 * var(--bob-px))); }
  50%  { transform: translateY(0); }
  75%  { transform: translateY(calc(-0.6 * var(--bob-px))); }
  100% { transform: translateY(0); }
}

body.is-step .room-wall,
body.is-step .room-objects {
  animation: room-bob var(--bob-ms) ease-in-out;
}

/* 回っている間だけ、壁と額縁を横に流す */
body.is-turning .room-wall {
  filter: saturate(0.72) brightness(0.85) url(#turn-blur);
}

body.is-turning .room-objects {
  filter: url(#turn-blur);
}

@media (prefers-reduced-motion: reduce) {
  body.is-step .room-wall,
  body.is-step .room-objects {
    animation: none;
  }
}

/* ── 額縁 ── */
.frame {
  position: relative;
  padding: 6px;
  background: var(--sumi);
  border: 6px solid var(--sumi);
  box-shadow:
    inset 0 0 0 1px rgba(201, 168, 76, 0.3),
    0 0 0 1px var(--gold),
    0 8px 22px rgba(0, 0, 0, 0.62);
}

.frame-paper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--paper);
}

.frame-plain {
  width: 210px;
  height: 210px;
}

/* 正面の額縁（案内の文）。
   文は lines.js の改行どおりに組む。1行18字まで（14.5px × 18 = 261px）が、幅360の端末でも
   折り返さずに収まる幅にしてある（額縁324px − 額の縁24px − 左右の余白36px = 264px）。
   **字の大きさ・額縁の幅・余白を変えたら、1行に入る字数も変わる**（lines.js の決まりと一緒に直す） */
.frame-notice {
  width: min(324px, calc(100vw - 32px));
  min-height: 230px;
  display: flex;
}

.frame-notice .frame-paper {
  flex-direction: column;
  height: auto;
  min-height: 100%;
  flex: 1;
}

/* 左そろえで組み、行のかたまりごと額縁の真ん中に置く（行の長さをそろえてあるので、端がそろって見える） */
.notice-text {
  max-width: 100%;
  padding: 22px 18px;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.75;
  color: var(--ctl2-ink);
  text-align: left;
  white-space: pre-line;
  word-break: auto-phrase;
  line-break: strict;
}

/* 最初の額縁の案内は小さく出す */
.notice-text.is-small {
  padding: 0 18px 16px;
  font-size: 13px;
}

/* 1回転の途中で、向いた無地の額縁に入る番号（向いた順に 1・2・3。2026-10-07 作者の注文・~~✓~~ から替えた） */
.frame-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 104px;
  height: 104px;
  color: var(--ctl2-enji);
  font-family: var(--font);
  font-size: 92px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s linear;
}

.frame.is-checked .frame-check {
  opacity: 1;
}

/* 正面の額縁は、1回転したときに角へ小さく付く */
.frame-badge {
  position: absolute;
  top: -18px;
  right: -18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 3px solid var(--ctl2-ink);
  border-radius: 50%;
  background: var(--ctl2-enji);
  color: var(--ctl2-on-ink);
  opacity: 0;
  transition: opacity 0.2s linear;
}

.frame-badge .ico {
  width: 24px;
  height: 24px;
}

.frame.is-checked .frame-badge {
  opacity: 1;
}

/* 振っても反応しないときのリンク。出ていない間も場所は取っておく（額縁が上下に動かないように） */
.skip-link {
  display: block;
  margin-top: 18px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  background: none;
  color: var(--ctl2-muted);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.skip-link[hidden] {
  display: block !important;
  visibility: hidden;
  pointer-events: none;
}

.skip-link:focus-visible {
  outline: 3px solid var(--ctl2-focus);
  outline-offset: 2px;
}

/* ── 1回転したあとの謎 ──
   額縁の紙を正方形の絵に替え、下に解答欄を置く。**絵は額縁いっぱいに入れる**（謎の絵に余白を足さない）。
   画面が低い端末では、右上のメニューに掛からないよう額縁ごと小さくする */
body.is-quiz {
  --quiz-w: min(324px, calc(100vw - 32px), calc(100dvh - 260px));
}

body.is-quiz .frame-notice {
  width: var(--quiz-w);
  min-height: 0;
}

.quiz-picture {
  display: none;
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.quiz-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.quiz-image:not([src]) {
  display: none;
}

body.is-quiz .notice-text,
body.is-quiz .frame-badge {
  display: none;
}

body.is-quiz .quiz-picture {
  display: block;
}

body.is-quiz .skip-link[hidden] {
  display: none !important;
}

.quiz-form {
  position: relative;
  width: var(--quiz-w);
  margin-top: 16px;
  padding-bottom: 36px;
  pointer-events: auto;
}

.quiz-row {
  display: flex;
  gap: 10px;
}

/* 打つ欄は凹み（押すものは凸）。16px 未満だと iPhone が画面を拡大する */
.quiz-input {
  flex: 1;
  min-width: 0;
  min-height: 56px;
  padding: 0 12px;
  border: var(--ctl2-border) solid var(--ctl2-ink);
  border-radius: var(--ctl2-radius);
  background: var(--ctl2-stage);
  box-shadow: inset 0 3px 0 #000;
  color: var(--ctl2-on-ink);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  user-select: text;
  -webkit-user-select: text;
}

.quiz-input::placeholder {
  color: var(--ctl2-muted);
}

.quiz-input:focus-visible {
  outline: 3px solid var(--ctl2-focus);
  outline-offset: 2px;
}

.quiz-submit {
  flex: none;
  padding: 0 18px;
}

/* 正解したら解答欄の場所に出す（画面の中の物を動かさない） */
.quiz-share {
  display: flex;
  width: 100%;
  text-decoration: none;
}

/* 不正解に赤を使わない。沈めた字で返し、正解は生成りを強く出す。
   文の行数が増えても額縁が動かないよう、中央そろえの計算から外す（高さは .quiz-form の下の余白で1行ぶんだけ取る） */
.quiz-message {
  position: absolute;
  top: 68px;
  left: 0;
  right: 0;
  color: var(--ctl2-muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  white-space: pre-line;
  text-shadow: 0 1px 2px #000;
}

/* 正解のメッセージも中央揃えで表示する */
.quiz-message.is-correct {
  color: var(--ctl2-on-ink);
  text-align: center;
}

/* ── 確認できたとき ── */
.ok-pop {
  position: fixed;
  left: 50%;
  top: 42%;
  z-index: 300;
  padding: 10px 28px 12px;
  border: 3px solid var(--ctl2-ink);
  border-radius: var(--ctl2-radius);
  background: var(--ctl2-enji);
  color: var(--ctl2-on-ink);
  box-shadow: 0 5px 0 var(--ctl2-enji-step);
  font-size: 46px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .04em;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
}

.ok-pop:empty {
  display: none;
}

.ok-pop.is-on {
  animation: ok-pop 1.1s ease-out forwards;
}

@keyframes ok-pop {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  22%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  78%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .ok-pop.is-on {
    animation: ok-fade 1.1s linear forwards;
  }

  @keyframes ok-fade {
    0%, 78% { opacity: 1; }
    100% { opacity: 0; }
  }
}

/* ── 右上のメニューを開く ── */
.menu-btn {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 210;
  width: 56px;
  min-width: 56px;
  height: 56px;
  padding: 0;
  background: var(--ctl2-ink);
  border-color: var(--ctl2-paper);
  color: var(--ctl2-on-ink);
  box-shadow: 0 var(--ctl2-lift) 0 #000;
}

.menu-btn:active {
  box-shadow: 0 0 0 #000, inset 0 2px 5px rgba(0, 0, 0, .5);
}

/* ── 矢印キー ── */
.keys {
  position: fixed;
  bottom: calc(5rem + var(--safe-bottom));
  left: 50%;
  z-index: 210;
  display: flex;
  gap: clamp(1.5rem, 6vw, 3rem);
  transform: translateX(-50%);
}

.key-btn {
  width: 68px;
  min-width: 68px;
  height: 68px;
  padding: 0;
}

.key-btn .ico {
  width: 30px;
  height: 30px;
}

/* ── メニュー ── */
.menu {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  background: var(--ctl2-stage);
}

.menu-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding:
    max(52px, env(safe-area-inset-top, 0px) + 20px)
    18px
    calc(22px + var(--safe-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-title {
  padding: 0 2px 13px;
  border-bottom: 2px solid rgba(242, 234, 214, .16);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: .06em;
  color: var(--ctl2-on-ink);
}

.menu-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 22px;
}

.menu-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--ctl2-label);
}

.menu-close {
  position: sticky;
  bottom: 0;
  z-index: 1;
  margin-top: auto;
  height: 72px;
  min-height: 72px;
  justify-content: center;
  font-size: 16px;
  letter-spacing: .06em;
}

.menu-close::after {
  content: '';
  position: absolute;
  left: -18px;
  right: -18px;
  top: calc(100% + 6px);
  height: 60px;
  background: var(--ctl2-stage);
  z-index: -1;
}
