:root {
  --bg: #0c0c24;
  --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.board #btn-b { display: none; } /* 乗り込み中は B を使わない */
@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, 36, 124, 0.75); }
.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(10, 10, 40, 0), rgba(10, 10, 40, 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: #c8c8f0; }
.menu .note { font-size: 11px; color: #9a9ac8; }
.menu .ver {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  font-size: 11px;
  color: #8c8cb8;
}
.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: var(--red); }
.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; }

/* ?og：OGP 画像のスクリーンショット用 */
body.og .screen-wrap { right: auto; bottom: auto; width: 1200px; height: 630px; }
body.og .menu, body.og .corner, body.og .btns, body.og .loading { display: none; }
