/* POYON — おなかで、あそぶ。
   昼下がりの部屋。暖色のグラデーションの上に、コードで描いた猫が寝ている。 */

:root {
  --bg-a: #fdf3e3;
  --bg-b: #f7ddc4;
  --bg-c: #f0cdae;
  --ink: #5a4632;
  --ink-soft: rgba(90, 70, 50, .62);
  --accent: #e8956b;
  --chip-bg: rgba(255, 255, 255, .55);
  --panel: rgba(255, 252, 246, .72);
  --panel-line: rgba(90, 70, 50, .14);
  --font-round: "Zen Maru Gothic", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

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

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-round);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 78% 12%, rgba(255, 246, 224, .95), rgba(255, 246, 224, 0) 55%),
    linear-gradient(168deg, var(--bg-a) 0%, var(--bg-b) 58%, var(--bg-c) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.mono { font-family: var(--font-mono); }

/* ═══════════ キャンバス ═══════════ */
.cat-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
  touch-action: none;
}

/* ═══════════ ヘッダー ═══════════ */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 26px 0;
  z-index: 10;
  pointer-events: none;
}

.site-header a, .site-header button { pointer-events: auto; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.brand__mark { width: 28px; height: 28px; }

.brand__name {
  font-weight: 700;
  letter-spacing: .34em;
  font-size: 16px;
}

.share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-round);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: .1em;
  color: #fff;
  background: #1a1a1a;
  border: 0;
  border-radius: 999px;
  padding: 11px 20px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .22);
  transition: transform .2s ease, box-shadow .2s ease;
}

.share svg { width: 14px; height: 14px; }

.share:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0, 0, 0, .28); }

.share {
  position: relative;
}

.share__badge {
  position: absolute;
  top: -8px;
  right: -6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 3px 7px;
  box-shadow: 0 4px 10px rgba(232, 149, 107, .5);
  animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* ═══════════ HUD：左＝スコア・称号 / 右＝設定・チャレンジ ═══════════ */
.hud {
  position: fixed;
  top: calc(76px + env(safe-area-inset-top, 0px));
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 218px;
  pointer-events: none;
  transition: opacity .7s ease .2s, transform .7s ease .2s;
}

.hud--left { left: 26px; align-items: flex-start; }
.hud--right { right: 26px; align-items: flex-end; }

.hud button { pointer-events: auto; }

/* スタート画面の間はHUDを隠し、最初のタップでふわっと出す */
body:not(.is-played) .hud {
  opacity: 0;
  transform: translateY(-10px);
  visibility: hidden;
}

.status {
  width: 100%;
  padding: 16px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 20px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 34px rgba(122, 84, 50, .14);
}

.status__row {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.status__count {
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  letter-spacing: .02em;
}

.status__unit {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}

.status__rank {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}

.status__rank-label {
  font-size: 9.5px;
  letter-spacing: .24em;
  color: #fff;
  background: var(--accent);
  border-radius: 6px;
  padding: 3px 7px 2px 9px;
}

.status__rank-name {
  font-size: 16.5px;
  font-weight: 700;
  letter-spacing: .04em;
}

.status__bar {
  margin-top: 9px;
  height: 7px;
  border-radius: 999px;
  background: rgba(90, 70, 50, .12);
  overflow: hidden;
}

.status__bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #f3b184, var(--accent));
  transition: width .45s cubic-bezier(.2, .8, .25, 1);
}

.status__next {
  margin-top: 7px;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--ink-soft);
}

/* ═══════════ クイック設定（HUD内） ═══════════ */
.quick {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.quick__btn { white-space: nowrap; }

.quick__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-round);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .05em;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 14px;
  padding: 11px 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(122, 84, 50, .1);
  transition: transform .15s ease, background .2s ease;
}

.quick__btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, .85); }

.quick__btn.is-on { border-color: var(--accent); box-shadow: 0 6px 20px rgba(232, 149, 107, .3); }

/* 15秒チャレンジボタン */
.ta-btn {
  width: 100%;
  font-family: var(--font-round);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .06em;
  color: #fff;
  background: linear-gradient(135deg, #f3a976, var(--accent));
  border: 0;
  border-radius: 15px;
  padding: 13px 14px;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(232, 149, 107, .45);
  transition: transform .15s ease, box-shadow .2s ease;
}

.ta-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(232, 149, 107, .55); }
.ta-btn:active { transform: scale(.97); }

/* タイムアタック中は上下のUIを隠して集中させる */
body.is-ta .hud,
body.is-ta .dock { visibility: hidden; }

/* ═══════════ タイムアタックHUD ═══════════ */
.ta-hud {
  position: fixed;
  top: calc(88px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translate(-50%, -8px);
  z-index: 12;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 26px;
  background: var(--panel);
  border: 1.5px solid rgba(232, 149, 107, .5);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 36px rgba(122, 84, 50, .22);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}

.ta-hud.is-on { opacity: 1; transform: translate(-50%, 0); }

.ta-hud__time, .ta-hud__score {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  color: var(--ink);
}

.ta-hud__time { min-width: 3.2em; }

.ta-hud__time small, .ta-hud__score small {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.ta-hud__score span { color: var(--accent); }

.ta-hud.is-last5 .ta-hud__time { color: #d64f3c; animation: lastPulse .5s ease-in-out infinite; }

@keyframes lastPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* カウントダウン */
.ta-count {
  position: fixed;
  inset: 0;
  z-index: 13;
  display: grid;
  place-items: center;
  font-family: var(--font-round);
  font-weight: 700;
  font-size: clamp(110px, 24vw, 200px);
  color: var(--accent);
  text-shadow: 0 4px 0 rgba(255, 255, 255, .8), 0 16px 50px rgba(232, 149, 107, .45);
  pointer-events: none;
  opacity: 0;
}

.ta-count.is-on { opacity: 1; }

.ta-count.pop { animation: countPop .55s cubic-bezier(.2, .9, .3, 1.3); }

@keyframes countPop {
  0% { transform: scale(1.7); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.quick__btn--icon {
  width: 42px;
  height: 42px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  flex: none;
}

.quick__btn--icon .quick__icon { font-size: 15px; }

.quick__icon { font-size: 17px; }

.quick__label b { font-weight: 700; color: var(--accent); }

/* ═══════════ スタート画面 ═══════════ */
.intro {
  position: fixed;
  inset: 0;
  z-index: 14;
  pointer-events: none; /* タップは猫へ素通し */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: calc(90px + env(safe-area-inset-top, 0px)) clamp(24px, 6vw, 90px) calc(34px + env(safe-area-inset-bottom, 0px));
  background:
    linear-gradient(180deg,
      rgba(253, 243, 227, .96) 0%,
      rgba(253, 243, 227, .78) 26%,
      rgba(250, 232, 208, .38) 48%,
      rgba(247, 221, 196, .46) 72%,
      rgba(240, 205, 174, .96) 100%);
  transition: opacity .9s ease;
}

body.is-played .intro { opacity: 0; }

.intro__inner { transition: transform .9s ease; }

body.is-played .intro__inner { transform: translateY(-16px); }

.intro__eyebrow {
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.intro__title {
  font-weight: 700;
  font-size: clamp(42px, 7.4vw, 92px);
  line-height: 1.14;
  letter-spacing: .06em;
  text-shadow: 0 2px 18px rgba(253, 243, 227, .9);
}

.intro__line { display: block; overflow: hidden; }
.intro__line--indent { padding-left: .9em; }

.intro__line-inner {
  display: inline-block;
  transform: translateY(110%);
  animation: rise 1s cubic-bezier(.2, .7, .2, 1) forwards;
}

.intro__line:nth-child(2) .intro__line-inner { animation-delay: .14s; }

@keyframes rise { to { transform: translateY(0); } }

.intro__hint {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 480px;
}

.hint-chip {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--ink);
  background: rgba(255, 255, 255, .82);
  border: 1px solid var(--panel-line);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 4px 14px rgba(122, 84, 50, .1);
}

.hint-chip__plus {
  margin-left: 5px;
  color: #d0703f;
  font-weight: 700;
}

.intro__start { text-align: center; }

.intro__start-chip {
  display: inline-block;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .08em;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 14px 30px;
  box-shadow: 0 10px 30px rgba(232, 149, 107, .5);
  animation: beckon 1.8s ease-in-out infinite;
}

@keyframes beckon {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-7px) scale(1.04); }
}

/* ═══════════ コンボ（上端中央・ヘッダーの空きスペース） ═══════════ */
.combo {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translate(-50%, -8px) scale(.9);
  z-index: 9;
  display: flex;
  align-items: baseline;
  gap: 9px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
}

.combo.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }

.combo__num {
  font-family: var(--font-round);
  font-weight: 700;
  font-size: 56px;
  color: var(--accent);
  text-shadow: 0 3px 0 rgba(255, 255, 255, .75), 0 8px 24px rgba(232, 149, 107, .35);
  line-height: 1;
}

.combo.pop .combo__num { animation: comboPop .32s cubic-bezier(.2, .9, .3, 1.4); }

@keyframes comboPop {
  0% { transform: scale(1.45); }
  100% { transform: scale(1); }
}

.combo__label {
  font-size: 13px;
  letter-spacing: .3em;
  color: var(--ink-soft);
  font-weight: 500;
}

/* ═══════════ ねこ切り替えドック ═══════════ */
.dock {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: stretch;
  gap: 18px;
  padding: 13px 22px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 22px;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 34px rgba(122, 84, 50, .14);
}

.dock__group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.dock__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--ink-soft);
  margin-right: 8px;
  white-space: nowrap;
}

.dock button {
  font-family: var(--font-round);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 17px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .2s ease, background .2s ease, transform .15s ease;
}

.dock button:hover { color: var(--ink); transform: translateY(-1px); }

.dock button.is-on {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 4px 14px rgba(232, 149, 107, .45);
}

/* ═══════════ フッター ═══════════ */
.site-footer {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  z-index: 4;
  text-align: center;
  padding: 0 20px 8px;
  font-size: 10px;
  letter-spacing: .16em;
  color: rgba(90, 70, 50, .42);
  pointer-events: none;
}

/* ═══════════ シェア誘導トースト（画面幅バナー） ═══════════ */
.toast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  margin: 0 auto;
  width: calc(100% - 20px);
  max-width: 560px;
  transform: translateY(20px) scale(.98);
  z-index: 20;
  display: flex;
  align-items: stretch;
  background: linear-gradient(135deg, rgba(255, 252, 246, .96), rgba(255, 243, 228, .96));
  border: 1.5px solid rgba(232, 149, 107, .45);
  border-radius: 20px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(122, 84, 50, .28), 0 2px 0 rgba(255, 255, 255, .8) inset;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease, transform .45s cubic-bezier(.2, .9, .25, 1.15);
}

.toast.is-on {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.toast__body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 4px 14px 16px;
  background: none;
  border: 0;
  cursor: pointer;
  font-family: var(--font-round);
  text-align: left;
  color: var(--ink);
}

.toast__emoji { font-size: 30px; flex: none; }

.toast__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toast__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast__sub {
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: .02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast__cta {
  flex: none;
  align-self: center;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .05em;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 9px 15px;
  box-shadow: 0 5px 14px rgba(232, 149, 107, .45);
  white-space: nowrap;
}

.toast__close {
  flex: none;
  background: none;
  border: 0;
  color: var(--ink-soft);
  font-size: 18px;
  padding: 0 13px;
  cursor: pointer;
}

/* ═══════════ 記録カードモーダル ═══════════ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}

.sheet.is-on { opacity: 1; pointer-events: auto; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(90, 66, 44, .34);
  backdrop-filter: blur(6px);
}

.sheet__panel {
  position: relative;
  width: min(430px, 100%);
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  background: #fffcf6;
  border: 1px solid var(--panel-line);
  border-radius: 24px;
  padding: 22px 22px calc(18px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 30px 80px rgba(90, 60, 34, .35);
  transform: translateY(16px) scale(.97);
  transition: transform .35s cubic-bezier(.2, .8, .25, 1);
}

.sheet.is-on .sheet__panel { transform: none; }

.sheet__close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: 0;
  font-size: 22px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 8px;
}

.sheet__eyebrow {
  font-size: 10px;
  letter-spacing: .32em;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.sheet__card-wrap {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(122, 84, 50, .18);
}

.sheet__card {
  display: block;
  width: 100%;
  height: auto;
}

.sheet__bonus {
  margin: 13px 0 0;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--ink);
  background: rgba(232, 149, 107, .14);
  border: 1px dashed rgba(232, 149, 107, .5);
  border-radius: 12px;
  padding: 9px 12px;
}

.sheet__bonus b { color: #d0703f; }

.sheet__bonus.is-done {
  background: rgba(90, 70, 50, .06);
  border-color: rgba(90, 70, 50, .18);
  color: var(--ink-soft);
}

.sheet__actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.sheet__actions--col { flex-direction: column; }

.sheet__row {
  display: flex;
  gap: 10px;
}

.sheet__row .btn { font-size: 12.5px; padding: 11px 8px; }

.btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-round);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .04em;
  border-radius: 14px;
  padding: 13px 10px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .2s ease;
}

.btn:active { transform: scale(.97); }

.btn svg { width: 16px; height: 16px; }

.btn--x {
  color: #fff;
  background: #1a1a1a;
  border: 1px solid #1a1a1a;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

.btn--ghost {
  color: var(--ink);
  background: var(--chip-bg);
  border: 1px solid var(--panel-line);
}

.sheet__note {
  margin-top: 12px;
  text-align: center;
  font-size: 10.5px;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

/* ═══════════ モバイル ═══════════ */
@media (max-width: 720px) {
  .site-header { padding: calc(14px + env(safe-area-inset-top, 0px)) 14px 0; }
  .share { font-size: 12px; padding: 10px 16px; }
  .share__badge { top: -7px; right: -5px; font-size: 9px; padding: 2px 6px; }

  .hud {
    top: calc(62px + env(safe-area-inset-top, 0px));
    width: 168px;
    gap: 7px;
  }

  .hud--left { left: 10px; }
  .hud--right { right: 10px; }

  .status { padding: 12px 14px 11px; border-radius: 17px; }
  .status__count { font-size: 27px; }
  .status__unit { font-size: 11px; }
  .status__rank { margin-top: 8px; gap: 6px; }
  .status__rank-label { font-size: 8.5px; padding: 2px 6px 2px 8px; }
  .status__rank-name { font-size: 14px; }
  .status__bar { margin-top: 8px; height: 6px; }
  .status__next { font-size: 10px; }

  .quick { gap: 6px; }
  .quick__btn { font-size: 11px; padding: 8px 11px; gap: 7px; border-radius: 12px; }
  .quick__btn--icon { width: 36px; height: 36px; }
  .quick__btn--icon .quick__icon { font-size: 13px; }
  .quick__icon { font-size: 14px; }

  .ta-btn { font-size: 12.5px; padding: 11px 12px; }

  .ta-hud {
    top: calc(64px + env(safe-area-inset-top, 0px));
    gap: 14px;
    padding: 10px 20px;
  }

  .ta-hud__time, .ta-hud__score { font-size: 27px; }

  .intro {
    padding: calc(72px + env(safe-area-inset-top, 0px)) 20px calc(96px + env(safe-area-inset-bottom, 0px));
  }

  .intro__title { font-size: clamp(38px, 11.5vw, 60px); }
  .intro__hint { margin-top: 18px; gap: 8px; }
  .hint-chip { font-size: 12px; padding: 7px 13px; }
  .intro__start-chip { font-size: 13.5px; padding: 12px 24px; }

  .combo { top: calc(14px + env(safe-area-inset-top, 0px)); }
  .combo__num { font-size: 38px; }
  .combo__label { font-size: 10px; }

  .dock {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    transform: none;
    justify-content: center;
    padding: 9px 10px;
    border-radius: 18px;
  }

  .dock button { font-size: 13px; padding: 8px 12px; }
  .dock__label { font-size: 11px; margin-right: 4px; }
  .site-footer { display: none; }

  .toast {
    width: calc(100% - 16px);
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    border-radius: 18px;
  }

  .toast__emoji { font-size: 26px; }
  .toast__title { font-size: 14px; }
  .toast__sub { font-size: 11px; }
  .toast__cta { font-size: 11.5px; padding: 8px 12px; }
  .toast__close { padding: 0 10px; }

  .sheet__panel { padding: 18px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .sheet__row .btn { font-size: 11.5px; }
}
