:root {
  --bg: #241a10;
  --ink: #fcfcfc;
  --red: #d82800;
  --gold: #f8b800;
}

* { box-sizing: border-box; }

/* iPhone のダブルタップ拡大を止める（viewport の user-scalable=no は iOS では無視される） */
html, body, * { touch-action: manipulation; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "M PLUS 1p", "Hiragino Kaku Gothic ProN", sans-serif;
  font-weight: 500;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

/* 画面いっぱいに 3D を描く */
.screen-wrap {
  position: fixed;
  inset: 0;
  background: #000;
  line-height: 0;
}
#screen, #hud, .touch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.touch { cursor: crosshair; }
.loading {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  line-height: 1;
  color: #8c8cb8;
  font-size: 14px;
  pointer-events: none;
}
body.ready .loading { display: none; }

/* スマホの移動スティック（触った場所に出る） */
.stick {
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.2);
  pointer-events: none;
}
.stick[hidden] { display: none; }
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.mini {
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
}
.corner {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  z-index: 5;
}

/* A / B ボタン（タッチ端末のプレイ中だけ） */
.btns {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: none;
  align-items: flex-end;
  gap: 14px;
  z-index: 4;
}
body.play .btns { display: flex; }
body.ride #btn-a { display: none; } /* 乗り物の中では走らない */
@media (hover: hover) and (pointer: fine) {
  body.play .btns { display: none; }
}
.round {
  position: relative;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.7);
  background: rgba(216, 40, 0, 0.75);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 24px;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.round span { font-size: 9px; margin-top: 3px; line-height: 1.15; }
.round.small { width: 62px; height: 62px; font-size: 20px; margin-bottom: 40px; background: rgba(36, 96, 160, 0.78); }
/* 状況に応じて出る行動のボタン（店員に聞く・エレベーターを呼ぶ・すみません など） */
.round.act {
  position: absolute;
  right: 0;
  bottom: 116px; /* B ボタン（上の端が 102px）と重ならない高さ */
  width: auto;
  min-width: 78px;
  height: 52px;
  padding: 0 14px;
  border-radius: 26px;
  background: rgba(230, 160, 0, 0.9);
  font-size: 16px;
  color: #241a10;
  flex-direction: row;
  gap: 6px;
}
.round.act span { font-size: 15px; margin: 0; white-space: nowrap; }
/* ボタンの文字が長くても 1 行で、枠の中に収める */
.round.act { width: max-content; max-width: calc(100vw - 40px); white-space: nowrap; }
.round.act[hidden] { display: none; }
.round.act.on { background: rgba(200, 120, 0, 0.95); }
/* 会話のスキップ（2 回目から） */
.skip {
  position: fixed;
  top: calc(52px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  z-index: 5;
  font-size: 15px;
}
.skip[hidden] { display: none; }
.round.on { transform: scale(0.92); background: rgba(168, 16, 0, 0.9); }

/* タイトルのときだけ下に出す説明とリンク */
.menu {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  text-align: center;
  background: linear-gradient(rgba(30, 20, 10, 0), rgba(30, 20, 10, 0.85) 40%);
  z-index: 3;
  line-height: 1.6;
  pointer-events: none;
}
.menu[hidden] { display: none; }
.menu p { margin: 0 0 2px; font-size: 12px; color: #f0e0c8; }
.menu .note { font-size: 11px; color: #c8b8a0; }
.menu .ver {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: #b8a890;
}
.menu a { color: #fff; pointer-events: auto; }
kbd {
  font: inherit;
  border: 1px solid #8c8cc8;
  padding: 0 4px;
  border-radius: 3px;
  margin: 0 1px;
}
@media (pointer: coarse) {
  .keyboard-only { display: none; }
}
@media (hover: hover) and (pointer: fine) {
  .touch-only { display: none; }
}

/* ---------- リザルトのシェアボタン（画面の下に重ねる） ---------- */
.result-panel {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(520px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
}
.result-panel[hidden] { display: none; }
.share-row { display: flex; gap: 8px; }
.btn {
  flex: 1;
  font: inherit;
  font-weight: 800;
  font-size: 15px;
  padding: 11px 6px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
}
.btn:active { transform: translateY(2px); }
.btn-x { background: #000; }
.btn-line { background: #06c755; }
.btn-share { background: #0058f8; }
.btn-next { background: #d07000; }
.btn-sub { background: #4c4c4c; flex: 0.5; }
.btn[hidden] { display: none; }
.follow {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  font-size: 12px;
  color: #b8b8e0;
  text-shadow: 0 1px 2px #000;
}
.follow a { color: #d8d8f8; display: flex; padding: 2px; }
.follow a:hover, .follow a:focus-visible { color: var(--ink); }
.follow svg { width: 18px; height: 18px; fill: currentColor; }

/* セーフエリア（ノッチ・角丸）を JS で読むための見えない箱。Canvas に描く HUD の余白に足す */
#safe-probe {
  position: fixed;
  left: 0;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px);
}
