/* サンタ Fly High style.css — 構造とクラス名は docs/design.md を参照 */

:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-line: #eadcc0;
  --c-red: #e8413b;
  --c-red-deep: #b8302c;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-sky: #4f9be0;
  --c-sky-deep: #2f6fb8;
  --c-sky-pale: #bfe3ff;
  --c-night: #1b2960;
  --c-night-deep: #0b1438;
  --c-aurora: #5ef2c8;
  --c-aurora-2: #8f7bff;
  --c-snow: #f4f9ff;
  --c-gift: #ff6fa3;

  --font-base: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "SF Pro Rounded",
    ui-rounded, system-ui, sans-serif;

  --radius-m: 18px;
  --radius-l: 28px;
  --btn-depth: 6px;
  --play-w: min(100vw, 480px);

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --dur-fast: 0.15s;
  --dur-mid: 0.35s;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-base);
  color: var(--c-ink);
  background: var(--c-night-deep);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; }
.num { font-family: var(--font-num); font-weight: 900; font-variant-numeric: tabular-nums; }

.app {
  position: relative;
  width: var(--play-w);
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(180deg, var(--c-sky), var(--c-sky-pale));
}
@media (min-width: 520px) {
  .app { border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink); }
}

/* ---------- 画面切替 ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateY(12px);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
  overflow-y: auto;
}
.screen.is-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s;
}
.screen__bg { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.screen:not(.screen--play) > :not(.screen__bg) { position: relative; z-index: 1; }

/* ---------- ボタン（押すと沈む） ---------- */
.btn {
  --btn-bg: var(--c-red);
  --btn-edge: var(--c-red-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 28px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 20px; font-weight: 800; letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 var(--btn-depth) 0 var(--btn-edge), 0 var(--btn-depth) 0 3px var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter var(--dur-fast);
}
.btn::after {
  content: ""; position: absolute; top: 5px; left: 18%; right: 18%; height: 6px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.35); pointer-events: none;
}
.btn:hover { filter: brightness(1.05); }
.btn:active, .btn.is-pressed {
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn:disabled { filter: grayscale(0.8) opacity(0.6); cursor: not-allowed; }
.btn--block { display: flex; width: 100%; }
.btn--sky { --btn-bg: var(--c-sky); --btn-edge: var(--c-sky-deep); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--ghost { --btn-bg: var(--c-paper); --btn-edge: var(--c-line); --btn-fg: var(--c-ink); }
.btn--small { min-height: 40px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }
.btn__sub { display: block; font-size: 12px; font-weight: 700; opacity: 0.9; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
  font-size: 20px; font-weight: 900; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
.icon-btn--pause::before {
  content: ""; width: 12px; height: 14px;
  border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink);
}
.btn:focus-visible, .icon-btn:focus-visible, .seg__btn:focus-visible {
  outline: 4px solid var(--c-gold); outline-offset: 4px;
}

/* ---------- タイトル ---------- */
.screen--title { align-items: center; justify-content: center; gap: 14px; text-align: center; }
.title__gear { position: absolute !important; top: calc(12px + var(--safe-top)); right: calc(12px + var(--safe-right)); }
.logo { margin: 0; font-weight: 900; line-height: 1.05; }
.logo__sub {
  display: inline-block; padding: 2px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper);
  font-size: clamp(14px, 3.8vmin, 18px);
  transform: rotate(-3deg);
}
.logo__main { display: flex; flex-direction: column; align-items: center; margin-top: 8px; font-size: clamp(42px, 12vmin, 68px); }
.logo__row { display: flex; gap: 2px; }
.logo__char {
  display: inline-block;
  color: var(--c-paper);
  -webkit-text-stroke: 3px var(--c-ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--c-ink);
  animation: rise 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i, 0) * 0.08s);
}
.logo__char--red { color: var(--c-red); }
.logo__char--gold { color: var(--c-gold); }
.logo__char--sky { color: #7fd0ff; }
/* 下から順にふわっと浮く（右ほど高く＝上昇感） */
.logo__row--fly .logo__char { transform: translateY(calc(var(--i, 0) * -3px)); }
@keyframes rise {
  0%, 60%, 100% { translate: 0 0; }
  70% { translate: 0 3px; }
  82% { translate: 0 -10px; }
}
.title__scene { width: min(60vw, 240px); height: auto; aspect-ratio: 1 / 1; }
/* 傾けて遊ぶ旨。スマホの絵が左右にかたむく */
.tilt-hint {
  display: flex; align-items: center; gap: 10px;
  margin: 0; padding: 8px 14px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: var(--c-paper);
  box-shadow: 0 4px 0 var(--c-ink);
  font-size: 14px; font-weight: 800; text-align: left;
}
.tilt-hint__phone {
  flex: none; position: relative;
  width: 22px; height: 36px;
  border: 3px solid var(--c-ink); border-radius: 6px;
  background: linear-gradient(180deg, #7fd0ff, var(--c-sky-pale));
  animation: tilt 2s ease-in-out infinite;
}
.tilt-hint__phone::after {
  content: ""; position: absolute; left: 50%; bottom: 2px; width: 6px; height: 3px; margin-left: -3px;
  border-radius: 2px; background: var(--c-ink);
}
@keyframes tilt { 0%, 100% { transform: rotate(-18deg); } 50% { transform: rotate(18deg); } }
.tilt-hint__pc { display: block; color: var(--c-ink-sub); font-size: 12px; font-weight: 700; }
.title__actions { display: flex; flex-direction: column; gap: 12px; width: min(80vw, 320px); }
.title__best {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0; padding: 4px 14px;
  border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-gold);
  font-size: 14px; font-weight: 900;
}
/* センサー許可の結果・長押し切替のお知らせ */
.notice {
  margin: 0; padding: 8px 12px;
  border: 3px dashed var(--c-ink); border-radius: var(--radius-m);
  background: #fff6d8;
  font-size: 13px; font-weight: 700;
}
.notice--warn { background: #ffe1e1; }

/* ---------- モーダル（ルール・設定・ポーズ） ---------- */
.modal {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(11, 20, 56, 0.66);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
}
.modal.is-open { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity var(--dur-mid) ease, visibility 0s; }
.card {
  width: min(100%, 360px);
  padding: 20px 18px 22px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-l);
  background: var(--c-paper);
  box-shadow: 0 8px 0 var(--c-ink);
  text-align: center;
}
.modal.is-open .card { animation: pop-in var(--dur-mid) var(--ease-pop) both; }
@keyframes pop-in { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
.card__title { margin: 0 0 12px; font-size: 22px; font-weight: 900; }
.card__actions { display: flex; flex-direction: column; gap: 12px; }
.card--pause .card__title { font-size: 26px; }

.rules { display: grid; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; text-align: left; }
.rules__item {
  display: grid; grid-template-columns: 56px 1fr; align-items: center; gap: 12px;
  padding: 8px 10px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: #fff;
}
.rules__pic { width: 56px; height: 56px; border: 2px solid var(--c-ink); border-radius: 12px; background: var(--c-sky-pale); }
.rules__text { margin: 0; font-size: 14px; font-weight: 700; }
.rules__text b { color: var(--c-red); }

/* 操作方式・感度の切替（セグメント） */
.setting { margin: 0 0 14px; text-align: left; }
.setting__label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 900; }
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 4px; gap: 4px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: #efe6d2;
}
.seg__btn {
  min-height: 40px; padding: 4px 10px;
  border: 0; border-radius: 999px;
  background: transparent;
  font-size: 14px; font-weight: 800;
  cursor: pointer;
  transition: background var(--dur-fast), transform 0.08s ease;
}
.seg__btn:active { transform: translateY(2px); }
.seg__btn[aria-pressed="true"] {
  background: var(--c-red); color: #fff;
  box-shadow: inset 0 0 0 3px var(--c-ink), 0 3px 0 var(--c-ink);
}
.seg__btn:disabled { color: #a99f90; cursor: not-allowed; }
.setting__note { margin: 4px 0 0; color: var(--c-ink-sub); font-size: 12px; }

/* ---------- プレイ ---------- */
.screen--play { padding: 0; overflow: hidden; background: var(--c-night-deep); touch-action: none; }
.play__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: flex-start; gap: 8px;
  padding: calc(10px + var(--safe-top)) calc(10px + var(--safe-right)) 0 calc(10px + var(--safe-left));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud__alt {
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 2px 14px 4px;
  border: 3px solid var(--c-ink); border-radius: 16px;
  background: var(--c-paper);
  box-shadow: 0 3px 0 var(--c-ink);
  line-height: 1.1;
}
.hud__alt-value { font-size: 28px; }
.hud__alt-value small { margin-left: 2px; font-size: 15px; }
.hud__best { font-size: 11px; font-weight: 800; color: var(--c-ink-sub); }
.hud__best .num { color: var(--c-gold-deep); }
.hud__alt.is-record { background: var(--c-gold); }
.hud__alt.is-record .hud__best { color: var(--c-ink); }
.hud__spacer { flex: 1; }
.hud__zone {
  align-self: center;
  padding: 2px 12px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: rgba(255, 253, 247, 0.9);
  font-size: 13px; font-weight: 900;
}
.hud__tick { animation: tick 0.25s var(--ease-pop); }
@keyframes tick { from { transform: scale(1.18); } to { transform: none; } }
/* 長押し操作のときの左右ガイド */
.hold-guide { position: absolute; inset: auto 0 0 0; z-index: 1; display: flex; justify-content: space-between; padding: 0 12px calc(14px + var(--safe-bottom)); pointer-events: none; }
.hold-guide__side {
  display: grid; place-items: center;
  width: 54px; height: 54px;
  border: 3px solid rgba(59, 47, 47, 0.6); border-radius: 50%;
  background: rgba(255, 253, 247, 0.45);
  font-size: 22px; font-weight: 900; color: var(--c-ink);
  transition: background var(--dur-fast), transform 0.08s;
}
.hold-guide__side.is-on { background: var(--c-gold); transform: scale(0.92); }

/* ---------- ゾーン到達バナー ---------- */
.zone-banner {
  position: absolute; left: 50%; top: 22%; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 22px 8px 10px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-red); color: #fff;
  box-shadow: 0 6px 0 var(--c-ink);
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
}
.zone-banner__icon { width: 48px; height: 48px; flex: none; }
.zone-banner__text { display: flex; flex-direction: column; line-height: 1.15; }
.zone-banner__small { font-size: 12px; font-weight: 800; color: #ffe0a6; }
.zone-banner__name { font-size: 22px; font-weight: 900; text-shadow: 0 2px 0 var(--c-red-deep); }
/* リボンの切り込み */
.zone-banner::before, .zone-banner::after {
  content: ""; position: absolute; top: 10px; z-index: -1;
  width: 30px; height: 34px;
  border: 3px solid var(--c-ink);
  background: var(--c-red-deep);
}
.zone-banner::before { left: -20px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 35% 50%); border-right: 0; }
.zone-banner::after { right: -20px; clip-path: polygon(0 0, 100% 0, 65% 50%, 100% 100%, 0 100%); border-left: 0; }
.zone-banner.is-show { animation: banner 2.4s var(--ease-pop) both; }
@keyframes banner {
  0% { opacity: 0; transform: translateX(-50%) translateY(30px) scale(0.6) rotate(-6deg); }
  14% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.08) rotate(2deg); }
  22% { transform: translateX(-50%) scale(1) rotate(0); }
  82% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(0.9); }
}
/* 小さめの「ベスト更新！」 */
.zone-banner--mini { top: 34%; padding: 4px 16px; background: var(--c-gold); color: var(--c-ink); }
.zone-banner--mini::before, .zone-banner--mini::after { display: none; }
.zone-banner--mini .zone-banner__name { font-size: 17px; text-shadow: none; }

/* ---------- 結果 ---------- */
.screen--result { align-items: center; justify-content: center; gap: 14px; text-align: center; background: rgba(11, 20, 56, 0.55); }
.result__card { width: min(100%, 360px); padding: 18px 16px 20px; }
.result__label { margin: 0; font-size: 14px; font-weight: 900; color: var(--c-ink-sub); }
.result__alt { margin: 0; font-size: 64px; line-height: 1; color: var(--c-red); -webkit-text-stroke: 2px var(--c-ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--c-ink); animation: pop-in 0.5s var(--ease-pop) both 0.1s; }
.result__alt small { font-size: 28px; }
.result__zone {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin: 12px 0 6px;
}
.result__zone-icon { width: 52px; height: 52px; }
.result__zone-name { font-size: 18px; font-weight: 900; text-align: left; line-height: 1.2; }
.result__title-name { display: block; font-size: 13px; color: var(--c-gold-deep); }
.result__best { margin: 0 0 8px; font-size: 14px; font-weight: 800; }
.result__new {
  display: inline-block; margin-left: 6px; padding: 0 8px;
  border: 2px solid var(--c-ink); border-radius: 8px;
  background: var(--c-gold); font-size: 12px; font-weight: 900;
  animation: wiggle 0.9s ease-in-out infinite;
}
@keyframes wiggle { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) scale(1.1); } }
.result__next {
  margin: 0 0 14px; padding: 8px 10px;
  border: 3px solid var(--c-ink); border-radius: var(--radius-m);
  background: #e8f4ff;
  font-size: 14px; font-weight: 800;
}
.result__next .num { color: var(--c-red); font-size: 18px; }
/* 次ゾーンまでの進み具合 */
.result__meter { display: block; height: 12px; margin-top: 6px; border: 2px solid var(--c-ink); border-radius: 999px; background: #fff; overflow: hidden; }
.result__meter-fill { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: linear-gradient(90deg, var(--c-aurora), var(--c-aurora-2)); }
.result__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.result__actions .btn--block { grid-column: 1 / -1; }
.toast {
  position: absolute; left: 50%; bottom: calc(24px + var(--safe-bottom)); z-index: 30;
  padding: 6px 16px; border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--c-paper); font-size: 14px; font-weight: 800;
  transform: translateX(-50%); animation: pop-in var(--dur-mid) var(--ease-pop) both;
}

/* ---------- 横向き警告 ---------- */
.rotate {
  position: fixed; inset: 0; z-index: 50;
  display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--c-night); color: var(--c-paper);
  font-size: 20px; font-weight: 900; text-align: center;
}
.rotate__phone {
  width: 44px; height: 72px;
  border: 4px solid var(--c-paper); border-radius: 10px;
  animation: turn 1.8s ease-in-out infinite;
}
@keyframes turn { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: rotate(0); } }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate { display: flex; }
}
.rotate.is-show { display: flex; }

/* ---------- 動きを減らす ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .logo__char, .tilt-hint__phone, .rotate__phone, .result__new { animation: none !important; }
  .zone-banner.is-show { animation: banner-fade 2.4s linear both !important; animation-duration: 2.4s !important; }
}
@keyframes banner-fade { 0%, 100% { opacity: 0; } 8%, 85% { opacity: 1; } }
