@charset "UTF-8";
/* ==========================================================================
   しいたけねこジャンプ — style.css
   1. 変数・ベース   2. 背景の飾り   3. タイトル画面
   4. HUD（LEVEL / SCORE / GOAL）   5. ゲーム画面   6. 結果画面   7. スマホ対応
   ========================================================================== */

/* ------------------------------------------------ 1. 変数・ベース */
:root {
  --cream:      #fdf8ec;
  --cream-deep: #f6ecd6;
  --brown:      #7c5136;
  --brown-deep: #4e3524;
  --green-deep: #365730;
  --moss:       #8aa86a;
  --orange:     #e08b3c;
  --orange-deep:#c96f24;
  --yellow:     #f3c453;
  --line:       #e3d3b4;

  --shadow-sm: 0 2px 8px rgba(124, 81, 54, .10);
  --shadow-md: 0 8px 22px rgba(124, 81, 54, .14);
  --shadow-lg: 0 18px 44px rgba(124, 81, 54, .18);

  --radius: 22px;
  --radius-lg: 30px;
  --pill: 999px;

  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans",
          "Yu Gothic Medium", "Meiryo", system-ui, sans-serif;
  --ease: cubic-bezier(.22, .68, .3, 1);
  --bounce: cubic-bezier(.34, 1.45, .5, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font);
  color: var(--brown-deep);
  background:
    radial-gradient(1200px 600px at 50% -10%, #fffdf6 0%, rgba(255,253,246,0) 70%),
    linear-gradient(180deg, #fbf3e2 0%, #f4ead4 55%, #eee2c6 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; height: auto; display: block; }

/* ------------------------------------------------ 2. 背景の飾り */
.forest-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.forest-deco .leaf {
  position: absolute; width: 26px; height: 26px;
  background: var(--orange); border-radius: 0 60% 0 60%;
  opacity: .16; animation: leafFloat 14s var(--ease) infinite;
}
.leaf1 { left: 6%;  top: 12%; }
.leaf2 { left: 88%; top: 20%; background: var(--moss); animation-delay: -3s; }
.leaf3 { left: 14%; top: 72%; background: var(--yellow); animation-delay: -6s; }
.leaf4 { left: 78%; top: 66%; animation-delay: -9s; }
.leaf5 { left: 46%; top: 6%;  background: var(--moss); animation-delay: -11s; }
.leaf6 { left: 60%; top: 88%; background: var(--yellow); animation-delay: -5s; }
@keyframes leafFloat {
  0%, 100% { transform: translate3d(0,0,0) rotate(0deg); }
  50%      { transform: translate3d(14px,-22px,0) rotate(28deg); }
}

/* ------------------------------------------------ 画面の切り替え */
.screen { display: none; position: relative; z-index: 1; }
.screen.is-active { display: block; animation: fadeUp .5s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------ ボタン */
.btn {
  font-family: inherit; font-weight: 700; cursor: pointer; border: none;
  border-radius: var(--pill); touch-action: manipulation;
  transition: transform .18s var(--bounce), box-shadow .18s var(--ease), background-color .18s var(--ease);
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn-main {
  font-size: clamp(18px, 4.4vw, 24px); color: #fff; padding: 18px 48px;
  background: linear-gradient(180deg, #e8974a 0%, var(--orange-deep) 100%);
  box-shadow: 0 6px 0 #a95a19, var(--shadow-md); letter-spacing: .06em;
}
.btn-main:hover { background: linear-gradient(180deg, #eda153 0%, #d17a2a 100%); transform: translateY(-2px); }
.btn-main:active { box-shadow: 0 2px 0 #a95a19, var(--shadow-sm); }
.btn-sub {
  font-size: 15px; color: var(--brown); padding: 13px 28px; background: #fff;
  border: 2px solid var(--line); box-shadow: var(--shadow-sm);
}
.btn-sub:hover { background: var(--cream); border-color: var(--orange); color: var(--orange-deep); }
.btn-sound {
  font-size: 13px; color: var(--brown); padding: 9px 18px; background: #fff;
  border: 2px solid var(--line); box-shadow: var(--shadow-sm);
}
.btn-sound .sound-off { display: none; }
.btn-sound[aria-pressed="false"] .sound-on { display: none; }
.btn-sound[aria-pressed="false"] .sound-off { display: inline; }
.btn-icon {
  width: 38px; height: 38px; font-size: 17px; line-height: 1; color: #fff;
  background: linear-gradient(180deg, #8a6444, #6b4a30);
  box-shadow: 0 3px 0 #4a3222;
}
.btn-jump {
  font-size: 16px; color: #fff; padding: 14px 40px;
  background: linear-gradient(180deg, #5e8a4f 0%, var(--green-deep) 100%);
  box-shadow: 0 4px 0 #2b451f;
}
.btn-jump:hover { filter: brightness(1.07); }

/* ------------------------------------------------ 3. タイトル画面 */
#screen-title { display: none; place-items: center; min-height: 100svh; padding: 32px 16px 48px; }
#screen-title.is-active { display: grid; }
.title-card {
  width: min(680px, 100%); text-align: center;
  background: rgba(255,253,246,.92); border: 3px solid #fff;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: clamp(24px,6vw,44px) clamp(18px,5vw,44px) clamp(28px,6vw,40px);
}
.title-neko { width: clamp(140px,34vw,210px); margin: -14px auto 6px; animation: nekoHop 1.8s var(--ease) infinite; }
@keyframes nekoHop {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  40%      { transform: translateY(-14px) rotate(3deg); }
}
.title {
  margin: 0 0 6px; line-height: 1.2; font-size: clamp(30px,8vw,50px);
  color: var(--brown-deep); text-shadow: 0 2px 0 #fff, 0 4px 10px rgba(124,81,54,.15);
}
.title span { color: var(--green-deep); }
.subtitle { margin: 0 0 14px; font-size: clamp(13px,3.4vw,16px); color: var(--brown); }
.lead {
  margin: 0 auto 24px; max-width: 26em; font-size: clamp(13px,3.3vw,15px);
  line-height: 1.9; color: #6a513c; background: var(--cream);
  border-radius: var(--radius); padding: 14px 18px;
}
.howto {
  margin: 22px auto 0; padding: 0; list-style: none; max-width: 30em;
  font-size: 12.5px; line-height: 1.9; color: #7a6249; text-align: left;
}
.howto li { position: relative; padding-left: 20px; }
.howto li::before {
  content: ""; position: absolute; left: 2px; top: .62em;
  width: 10px; height: 6px; background: var(--brown); border-radius: 10px 10px 2px 2px;
}
.back-link {
  display: inline-block; margin-top: 18px; font-size: 12.5px; color: var(--brown);
  text-decoration: none; border-bottom: 2px dotted var(--line); padding-bottom: 2px;
}
.back-link:hover { color: var(--orange-deep); border-bottom-color: var(--orange); }

/* ------------------------------------------------ 4. HUD */
#screen-game { padding: 14px 12px 32px; max-width: 1020px; margin: 0 auto; }

.hud {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 10px;
}
.hud-item {
  display: flex; align-items: center; gap: 8px;
  background: linear-gradient(180deg, #fffdf6, #f4e7cd);
  border: 3px solid #fff; border-radius: var(--pill);
  box-shadow: var(--shadow-sm); padding: 6px 16px;
}
.hud-label { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: #8a705a; }
.hud-value { font-size: clamp(18px,4.6vw,24px); line-height: 1; color: var(--brown-deep); font-variant-numeric: tabular-nums; }
.hud-value--sm { font-size: 14px; }
.hud-theme { font-size: 11px; color: var(--green-deep); background: #eaf2e2; border-radius: var(--pill); padding: 3px 9px; }
.hud-score .hud-value { color: var(--orange-deep); }

.gauge {
  position: relative; display: block; width: clamp(90px, 22vw, 190px); height: 12px;
  background: #e7dbc2; border-radius: var(--pill); overflow: visible;
}
.gauge__fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, #a8c77e, #6da35b);
  border-radius: var(--pill); transition: width .16s linear;
}
.gauge__flag {
  position: absolute; right: -6px; top: -12px; font-size: 14px; color: #d8452c;
}

/* ------------------------------------------------ 5. ゲーム画面 */
.stage {
  position: relative;
  border: 4px solid #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-md); overflow: hidden;
  background: #cfe3ef;
  cursor: pointer;
  touch-action: manipulation;
}
#canvas { display: block; width: 100%; height: auto; }

.tap-hint {   /* しいたけねこに重ならないよう、画面の上のほうに出します */
  position: absolute; left: 50%; top: 10%; transform: translateX(-50%);
  margin: 0; padding: 8px 20px; border-radius: var(--pill);
  background: rgba(255, 253, 246, .92); color: var(--brown);
  font-size: clamp(12px, 3vw, 14px); font-weight: 700;
  box-shadow: var(--shadow-sm); pointer-events: none;
  animation: hintPulse 1.6s var(--ease) infinite;
}
.tap-hint[hidden] { display: none; }
@keyframes hintPulse { 0%,100% { opacity: .95; transform: translateX(-50%) translateY(0); } 50% { opacity: .65; transform: translateX(-50%) translateY(4px); } }

.game-foot { margin-top: 14px; display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; }

/* ------------------------------------------------ 6. 結果画面 */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: 20px; background: rgba(62,42,28,.58); animation: fadeIn .3s var(--ease) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay[hidden] { display: none; }
.overlay-card {
  position: relative; z-index: 2; width: min(520px,100%); text-align: center;
  background: var(--cream); border: 4px solid #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 28px clamp(18px,5vw,34px) 26px;
  animation: cardIn .5s var(--bounce) both; max-height: 88svh; overflow-y: auto;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(20px) scale(.94); } to { opacity: 1; transform: none; } }
.ov-neko { width: clamp(110px,28vw,160px); margin: -6px auto 8px; }
.overlay-card.is-all .ov-neko { width: clamp(150px,40vw,220px); animation: nekoHop 1.8s var(--ease) infinite; }
.ov-title { margin: 0 0 6px; font-size: clamp(22px,6vw,32px); color: var(--orange-deep); text-shadow: 0 2px 0 #fff; }
.overlay-card.is-over .ov-title { color: var(--brown); }
.ov-text { margin: 0 0 14px; font-size: clamp(13px,3.6vw,16px); color: var(--brown); line-height: 1.8; }
.ov-score {
  display: inline-flex; align-items: center; gap: 10px; margin: 0 0 16px;
  padding: 8px 20px; border-radius: var(--radius);
  background: #fff; border: 2px solid var(--line);
}
.ov-score span { font-size: 11px; letter-spacing: .12em; color: #8a705a; font-weight: 700; }
.ov-score strong { font-size: 24px; color: var(--orange-deep); font-variant-numeric: tabular-nums; }
.ov-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti i { position: absolute; top: -20px; width: 12px; height: 12px; border-radius: 0 60% 0 60%; animation: fall linear forwards; }
@keyframes fall {
  0% { opacity: 0; transform: translateY(-10px) rotate(0deg); }
  10% { opacity: 1; }
  100% { opacity: .9; transform: translateY(105svh) rotate(540deg); }
}

/* ------------------------------------------------ 7. スマホ対応 */
@media (max-width: 720px) {
  #screen-game {
    padding: 10px 8px 28px;
    min-height: 100svh;
    display: flex; flex-direction: column; justify-content: center;  /* 上下の中央に置きます */
  }
  .title { font-size: clamp(26px, 7.4vw, 44px); }   /* 「プ」だけ改行されないように */
  .hud { gap: 6px; }
  .hud-item { padding: 5px 12px; gap: 6px; }
  .hud-theme { display: none; }
  .hud-label { font-size: 10px; }
}
@media (min-width: 721px) {
  /* パソコンではジャンプボタンを出さず、クリックとスペースキーで遊びます */
  .btn-jump { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
