:root {
  --ink: #ffffff;
  --ink-dim: rgba(255,255,255,.72);
  --panel: rgba(13,27,42,.86);
  --accent: #ffd23f;
  --out: #ff4d4d;
  --safe: #4dc3ff;
  --huh: #ffb84d;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0d1b2a; color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }

/* HUD */
#hud {
  position: fixed; top: max(8px, env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none; font-weight: 800; text-shadow: 0 2px 4px rgba(0,0,0,.6);
}
#hud > div { background: rgba(0,0,0,.35); border-radius: 10px; padding: 4px 12px; font-size: 18px; }
#hud .sub { font-size: 13px; color: var(--ink-dim); margin-left: 4px; }
#hud .lbl { font-size: 12px; color: var(--accent); margin-right: 6px; letter-spacing: .1em; }

#prompt {
  position: fixed; left: 0; right: 0; bottom: 14%; text-align: center;
  font-size: clamp(16px, 3.6vmin, 24px); font-weight: 800; pointer-events: none;
  text-shadow: 0 2px 6px rgba(0,0,0,.8);
}
#flash {
  position: fixed; left: 0; right: 0; top: 38%; text-align: center; pointer-events: none;
  font-size: clamp(28px, 9vmin, 64px); font-weight: 900; color: var(--accent);
  text-shadow: 0 3px 0 #7a5200, 0 6px 14px rgba(0,0,0,.6); opacity: 0;
}
#flash.show { animation: flash .7s ease-out forwards; }
@keyframes flash { 0%{opacity:1;transform:scale(1.4)} 60%{opacity:1;transform:scale(1)} 100%{opacity:0;transform:scale(1)} }

#call {
  position: fixed; left: 0; right: 0; top: 12%; text-align: center; pointer-events: none;
  font-size: clamp(44px, 14vmin, 120px); font-weight: 900; font-style: italic; opacity: 0;
  letter-spacing: .02em;
}
#call.show { animation: stamp .45s cubic-bezier(.2,1.6,.4,1) forwards; }
#call.out  { color: var(--out);  text-shadow: 0 4px 0 #6b0000, 0 8px 20px rgba(0,0,0,.6); }
#call.safe { color: var(--safe); text-shadow: 0 4px 0 #00456b, 0 8px 20px rgba(0,0,0,.6); }
@keyframes stamp { 0%{opacity:0;transform:scale(2.4) rotate(-8deg)} 100%{opacity:1;transform:scale(1) rotate(-4deg)} }

#bubble {
  position: fixed; left: 50%; top: 20%; transform: translate(-50%, -100%);
  background: #fff; color: #222; font-weight: 900; font-size: clamp(30px, 9vmin, 64px);
  padding: .15em .6em; border-radius: 1em; opacity: 0; pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
#bubble::after {
  content: ""; position: absolute; left: 30%; bottom: -16px;
  border: 10px solid transparent; border-top: 16px solid #fff; border-bottom: 0;
}
#bubble.show { animation: pop .35s cubic-bezier(.2,1.8,.4,1) forwards; }
@keyframes pop { 0%{opacity:0;transform:translate(-50%,-100%) scale(.3)} 100%{opacity:1;transform:translate(-50%,-100%) scale(1)} }

#toast {
  position: fixed; left: 50%; top: 30%; transform: translateX(-50%);
  background: var(--panel); border-radius: 12px; padding: 10px 18px;
  font-weight: 800; font-size: 18px; opacity: 0; transition: opacity .25s; pointer-events: none;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

#tapBtn {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: 120px; height: 120px; border-radius: 50%; border: 4px solid #fff;
  background: rgba(139,74,34,.85); color: #fff; font-size: 22px; font-weight: 900;
  box-shadow: 0 6px 16px rgba(0,0,0,.45);
}
#tapBtn:active { transform: scale(.94); }

/* panels */
.panel {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(400px, calc(100vw - 32px)); background: var(--panel); border-radius: 16px;
  padding: 10px 16px 12px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.card-title { font-size: 24px; font-weight: 900; }
.card-title.out { color: var(--out); } .card-title.safe { color: var(--safe); } .card-title.huh { color: var(--huh); }
.card-detail { font-size: 13px; color: var(--ink-dim); margin: 4px 0; line-height: 1.5; }
.pitch-note { font-size: 12px; opacity: .85; }
.card-points { font-size: 20px; font-weight: 900; color: var(--accent); margin-bottom: 8px; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 12px; padding: 13px 10px;
  font-size: 17px; font-weight: 800; color: #1a1a1a; background: var(--accent); cursor: pointer;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); filter: brightness(.95); }
.btn-sub { background: rgba(255,255,255,.16); color: #fff; margin-top: 8px; font-size: 14px; }
.btn-main { margin-top: 12px; }

/* screens */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(13,27,42,.55), rgba(13,27,42,.92));
  overflow-y: auto; padding: 16px;
}
.title-box { width: min(440px, 100%); text-align: center; margin: auto; }
.logo-sub { font-size: 14px; color: var(--accent); font-weight: 800; letter-spacing: .2em; }
.logo {
  margin: 4px 0 10px; font-size: clamp(40px, 11vmin, 64px); line-height: 1.05; font-weight: 900;
  font-style: italic; text-shadow: 0 4px 0 #8b4a22, 0 8px 24px rgba(0,0,0,.5);
}
.howto { text-align: left; font-size: 14px; line-height: 1.7; padding-left: 1.4em; margin: 8px 0; color: var(--ink-dim); }
.howto b { color: #fff; }
.opts { display: block; font-size: 12px; color: var(--ink-dim); margin: 12px 0 0; }
.lead { font-size: 15px; margin: 10px 0 6px; color: var(--ink-dim); }
.lead b { color: #fff; }
.opts select { font-size: 12px; padding: 3px 6px; border-radius: 8px; margin-left: 6px; font-family: inherit; }
.note { font-size: 12px; color: var(--ink-dim); margin-top: 12px; line-height: 1.6; }
.note b { color: #fff; }
.best { margin-top: 10px; font-size: 13px; color: var(--accent); font-weight: 700; }
.rank { font-size: clamp(30px, 8vmin, 46px); font-weight: 900; margin: 6px 0; }
.over-score { font-size: 40px; font-weight: 900; color: var(--accent); }
.stats { margin: 10px auto; border-collapse: collapse; font-size: 15px; }
.stats td { padding: 3px 12px; }
.stats td:first-child { color: var(--ink-dim); text-align: left; }
.stats td:last-child { font-weight: 800; text-align: right; }

#sensorWarn {
  position: fixed; left: 50%; top: 56px; transform: translateX(-50%); background: var(--panel);
  padding: 8px 14px; border-radius: 10px; font-size: 13px; width: max-content; max-width: calc(100vw - 32px);
}
#debug {
  position: fixed; left: 8px; bottom: 8px; background: rgba(0,0,0,.7); color: #0f0;
  font: 11px/1.4 ui-monospace, Menlo, monospace; padding: 6px 8px; border-radius: 6px; white-space: pre;
  pointer-events: auto; max-width: calc(100vw - 16px);
}
#debug input { width: 120px; vertical-align: middle; pointer-events: auto; }
#debug { pointer-events: none; }   /* デバッグ表示は「タッチ！」ボタンへのタップを邪魔しない（スライダーだけ操作できる） */

#card .btn { padding: 10px; }

/* スマホへの誘導 */
.disclaimer { font-size: 11px; color: var(--ink-dim); margin-top: 14px; line-height: 1.6; text-align: center;
  background: rgba(255,255,255,.06); border-radius: 8px; padding: 8px 10px; }
.rotate-hint { display: none; margin-top: 10px; font-size: 13px; color: var(--accent); font-weight: 700; }
.rotate-hint b { color: #fff; }
@media (orientation: landscape) { body.mobile .rotate-hint { display: block; } }
body.mobile .pc-only { display: none; }
.pc-logo { font-size: clamp(34px, 8vmin, 52px); }
.pc-lead { text-wrap: balance; font-size: 14px; line-height: 1.7; color: var(--ink-dim); margin: 6px 0 14px; }
.qr-box { background: #fff; padding: 10px; border-radius: 12px; line-height: 0; width: max-content; margin: 0 auto; }
.qr-box svg { display: block; width: 180px; height: 180px; }
.pc-url { font: 12px/1.4 ui-monospace, Menlo, monospace; background: rgba(255,255,255,.08); border-radius: 8px;
  padding: 8px 12px; margin: 12px auto 0; word-break: break-all; width: max-content; max-width: 100%; }
.share-status { font-size: 12px; color: var(--accent); min-height: 1em; margin-top: 4px; }

/* 反応の秒数（タッチした瞬間に大きく） */
#bigTime {
  position: fixed; left: 0; right: 0; top: 40%; text-align: center; pointer-events: none;
  font: 900 clamp(48px, 16vmin, 110px)/1 ui-monospace, "SF Mono", Menlo, monospace; color: #fff; opacity: 0;
  text-shadow: 0 4px 0 #8b4a22, 0 8px 20px rgba(0,0,0,.6); letter-spacing: -.02em;
}
#bigTime.show { animation: bigtime 1.6s ease-out forwards; }
@keyframes bigtime { 0%{opacity:0;transform:scale(1.8)} 12%{opacity:1;transform:scale(1)} 75%{opacity:1} 100%{opacity:0;transform:translateY(-30px)} }

/* 隠し球のときの「シェイク！」（フェードインで出す） */
#hint { position: fixed; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 20; pointer-events: none;
  font-size: 64px; font-weight: 900; color: #ffd23f; letter-spacing: .04em; white-space: nowrap;
  text-shadow: 0 3px 0 #7a3c12, 0 6px 18px rgba(0,0,0,.55); opacity: 0; transition: opacity .9s ease; }
#hint.show { opacity: 1; animation: hintPulse 1.2s ease-in-out .9s infinite; }
@keyframes hintPulse { 0%, 100% { transform: translate(-50%, -50%) scale(1); } 50% { transform: translate(-50%, -50%) scale(1.07); } }
