@charset "UTF-8";
/* ==========================================================================
   しいたけねこ脱出ゲーム — style.css
   1. 変数・ベース   2. 背景の飾り   3. タイトル画面   4. 上のバー
   5. 探索画面（背景・調べる物・しいたけねこ）   6. アイテム欄
   7. 拡大表示・暗号入力   8. 結果画面   9. スマホ対応
   ========================================================================== */

/* ------------------------------------------------ 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: 12px 26px; 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-peek,
.btn-hint {
  font-size: 13px; color: #6a4a22; padding: 9px 16px;
  background: linear-gradient(180deg, #ffe08a, #f3c453);
  box-shadow: 0 3px 0 #c99a2a;
}
.btn-peek {
  color: #3f5430; background: linear-gradient(180deg, #d8ebbf, #aacb8b);
  box-shadow: 0 3px 0 #7e9a63;
}
.btn-ghost {
  font-size: 13px; color: #fff; padding: 9px 16px;
  background: linear-gradient(180deg, #8a6444, #6b4a30);
  box-shadow: 0 3px 0 #4a3222;
}
.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; }

/* ------------------------------------------------ 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(700px, 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,200px); margin: -14px auto 6px; animation: nekoBob 3.2s var(--ease) infinite; }
@keyframes nekoBob { 0%,100% { transform: translateY(0) rotate(-1.5deg); } 50% { transform: translateY(-8px) rotate(1.5deg); } }
.title {
  margin: 0 0 6px; line-height: 1.22; font-size: clamp(26px,7.2vw,44px);
  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); line-height: 1.7; }
.lead {
  margin: 0 auto 24px; max-width: 28em; font-size: clamp(13px,3.3vw,15px);
  line-height: 1.9; color: #6a513c; background: var(--cream);
  border-radius: var(--radius); padding: 14px 18px;
}
.howto-steps {
  display: grid; gap: 8px; margin: 24px auto 0; padding: 0; list-style: none;
  max-width: 34em; text-align: left;
}
.howto-steps li {
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px; line-height: 1.7; color: #6a513c;
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius);
  padding: 9px 14px;
}
.step-no {
  flex: none; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-deep); color: #fff; font-size: 12px; font-weight: 700;
}
.howto {
  margin: 10px auto 0; padding: 0; list-style: none; max-width: 34em;
  font-size: 12.5px; line-height: 1.8; color: #7a6249; text-align: center;
}
.br-sp { display: none; }
@media (max-width: 560px) { .br-sp { display: inline; } }
.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. 上のバー */
#screen-game { padding: 12px 12px 28px; max-width: 1020px; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: linear-gradient(180deg, #fffdf6, #f4e7cd);
  border: 3px solid #fff; border-radius: var(--pill);
  box-shadow: var(--shadow-sm); padding: 7px 10px 7px 18px; margin-bottom: 10px;
}
.topbar__level { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__level b {
  font-size: clamp(13px,3.4vw,16px); color: #fff; background: var(--green-deep);
  border-radius: var(--pill); padding: 4px 12px; white-space: nowrap;
}
.topbar__level span {
  font-size: clamp(12px,3.2vw,15px); color: var(--brown-deep); font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar__right { display: flex; gap: 8px; flex: none; }

/* ------------------------------------------------ 5. 探索画面 */
.stage {
  position: relative; overflow: hidden;
  border: 4px solid #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-md); background: var(--cream-deep);
}
.scene { position: relative; aspect-ratio: 16 / 9; }
.scene__bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scene__objects { position: absolute; inset: 0; }
.scene__neko {
  position: absolute; left: 3%; bottom: 3%; width: 12%;
  filter: drop-shadow(0 6px 10px rgba(80,58,40,.28));
  transition: transform .3s var(--bounce);
  pointer-events: none;
}
.scene__neko.is-hop { animation: nekoHop .6s var(--bounce); }
@keyframes nekoHop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-14px); } }
.scene__talk {
  position: absolute; left: 20%; bottom: 16%;
  margin: 0; padding: 8px 14px; border-radius: 14px; pointer-events: none;
  background: rgba(255,253,246,.96); border: 2px solid #fff;
  font-size: clamp(11px,2.6vw,14px); color: var(--brown-deep);
  box-shadow: var(--shadow-sm); max-width: 46%;
  animation: fadeUp .3s var(--ease) both;
}
.scene__talk[hidden] { display: none; }

/* 調べられる物 */
.obj {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 26px; min-height: 26px;   /* 絵が出るまでの間も、押せる大きさを確保します */
  border: none; background: none; padding: 0; cursor: pointer;
  transition: transform .2s var(--bounce), filter .2s var(--ease);
  touch-action: manipulation;
}
.obj img { display: block; width: 100%; height: auto; pointer-events: none; }
.obj:hover { transform: translate(-50%, -50%) scale(1.06); filter: brightness(1.08); }
.obj:active { transform: translate(-50%, -50%) scale(.97); }
.obj.is-hidden { display: none; }
/* 背景にもう描かれている物の「調べられる場所」。絵は重ねません */
.obj--spot { background: none; }
.obj--spot::after { border-color: rgba(255,253,246,.28); }
.scene.is-peek .obj--spot::after { border-color: rgba(255,253,246,.9); }
.obj.is-taken { display: none; }
.obj.is-glow img { filter: drop-shadow(0 0 10px rgba(243,196,83,.95)); }
.obj.is-done img { filter: saturate(.85) brightness(1.02); }
/* 調べられる場所が分かるよう、ふちをうっすら光らせます */
.obj::after {
  content: ""; position: absolute; inset: -12px;   /* 指で押しやすいよう、ふちを広げます */
  border-radius: 14px; border: 2px dashed rgba(255,253,246,0);
  transition: border-color .2s var(--ease);
}
.obj:hover::after { border-color: rgba(255,253,246,.8); }
.scene.is-peek .obj::after { border-color: rgba(255,253,246,.75); }

.scene-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 46px; border: 3px solid #fff; border-radius: 50%;
  background: rgba(124,81,54,.82); color: #fff; font-size: 17px; cursor: pointer;
  box-shadow: var(--shadow-sm); touch-action: manipulation;
}
.scene-nav:hover { background: rgba(124,81,54,.95); }
.scene-nav--prev { left: 10px; }
.scene-nav--next { right: 10px; }
.scene-nav[hidden] { display: none; }
.scene-name {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  margin: 0; padding: 4px 16px; border-radius: var(--pill); pointer-events: none;
  background: rgba(255,253,246,.9); border: 2px solid #fff;
  font-size: 11.5px; font-weight: 700; color: var(--brown); box-shadow: var(--shadow-sm);
}

.message {
  margin: 12px 0 10px; text-align: center; min-height: 2.6em;
  font-size: clamp(12.5px,3.2vw,15px); font-weight: 700; color: var(--brown);
  line-height: 1.7;
}

/* ------------------------------------------------ 6. アイテム欄 */
.inventory {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #fffdf6, #f4e7cd);
  border: 3px solid #fff; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 8px 12px;
}
.inventory__label { font-size: 11px; font-weight: 700; letter-spacing: .1em; color: #8a705a; flex: none; }
.inventory__list {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px;
  margin: 0; padding: 0; list-style: none; flex: 1;
}
.inv-slot {
  aspect-ratio: 1 / 1; min-height: 0; overflow: hidden; border-radius: 14px;
  background: #fffdf6; border: 2px dashed var(--line);
  display: grid; place-items: center; padding: 4px;
}
.inv-slot.is-filled { border-style: solid; cursor: pointer; }
.inv-slot.is-filled:hover { border-color: var(--orange); background: #fff7e6; }
.inv-slot.is-selected {
  border-color: var(--orange-deep); background: #ffeccd;
  box-shadow: 0 0 0 3px rgba(224,139,60,.28);
}
.inv-slot img { max-width: 84%; max-height: 84%; width: auto; height: auto;
  object-fit: contain; pointer-events: none; }

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

/* ------------------------------------------------ 7. 拡大表示・暗号入力 */
.zoom {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  padding: 20px; background: rgba(62,42,28,.58); animation: fadeIn .25s var(--ease) both;
}
.zoom[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.zoom__inner {
  width: min(460px, 100%); text-align: center;
  background: var(--cream); border: 4px solid #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 24px clamp(16px,5vw,30px) 22px;
  animation: cardIn .4s var(--bounce) both; max-height: 88svh; overflow-y: auto;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(18px) scale(.95); } to { opacity: 1; transform: none; } }
.zoom__title { margin: 0 0 12px; font-size: clamp(16px,4.4vw,21px); color: var(--brown-deep); }
.zoom__body {
  margin: 0 0 18px; padding: 16px; border-radius: var(--radius);
  background: #fffdf6; border: 2px solid var(--line);
  font-size: clamp(14px,3.8vw,17px); line-height: 2; color: var(--brown-deep);
}
.zoom__body .big { font-size: clamp(26px,8vw,40px); font-weight: 700; letter-spacing: .22em; color: var(--orange-deep); }
.zoom__body img { margin: 8px auto; max-width: 70%; }
.zoom__body .row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }
.zoom__body .row img { width: 54px; margin: 0; }

.keypad__display {
  margin: 0 0 14px; font-size: clamp(26px,8vw,38px); font-weight: 700;
  letter-spacing: .3em; color: var(--orange-deep); min-height: 1.2em;
}
.keypad__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad__grid button {
  font-family: inherit; font-size: clamp(18px,5vw,24px); font-weight: 700;
  color: var(--brown-deep); background: #fffdf6;
  border: 2px solid var(--line); border-radius: 16px;
  padding: 14px 0; cursor: pointer; touch-action: manipulation;
}
.keypad__grid button:hover { background: #fff3dc; border-color: var(--orange); }
.keypad__grid button:active { transform: translateY(2px); }
.keypad__grid button.is-wide { grid-column: span 1; font-size: 15px; }
.keypad__msg { margin: 12px 0 14px; min-height: 1.5em; font-size: 14px; font-weight: 700; color: var(--orange-deep); }

.symbolpad__grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.symbolpad__grid button {
  font-family: inherit; font-size: 26px; background: #fffdf6;
  border: 2px solid var(--line); border-radius: 16px; padding: 10px 0; cursor: pointer;
}
.symbolpad__grid button:hover { background: #fff3dc; border-color: var(--orange); }

/* ------------------------------------------------ 8. 結果画面 */
.overlay {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center;
  padding: 20px; background: rgba(62,42,28,.58); animation: fadeIn .3s var(--ease) both;
}
.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;
}
.ov-neko { width: clamp(110px,28vw,170px); margin: -6px auto 8px; }
.overlay-card.is-all .ov-neko { width: clamp(150px,40vw,220px); animation: nekoBob 2.6s 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; }
.ov-text { margin: 0 0 18px; font-size: clamp(13px,3.6vw,16px); color: var(--brown); line-height: 1.8; }
.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); }
}

/* キラキラ（謎がとけたとき） */
.spark {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px;
  background: var(--yellow); border-radius: 0 60% 0 60%; pointer-events: none;
  animation: sparkOut .8s var(--ease) forwards;
}
@keyframes sparkOut {
  0% { opacity: 1; transform: translate(0,0) scale(.4) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.1) rotate(200deg); }
}

/* ------------------------------------------------ 9. スマホ対応 */
@media (max-width: 720px) {
  #screen-game { padding: 8px 8px 24px; }
  .topbar { padding: 6px 8px 6px 12px; }
  .topbar__level span { display: none; }       /* ステージ名は下の帯に出しています */
  .topbar__right .btn { font-size: 12px; padding: 8px 10px; }
  .inventory { gap: 8px; padding: 7px 9px; }
  .inventory__label { display: none; }
  .inventory__list { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .scene__neko { width: 15%; }
  .scene-nav { width: 40px; height: 40px; font-size: 15px; }
}

@media (max-width: 600px) {
  .stage { margin-left: -8px; margin-right: -8px; }
  #screen-game.is-active {
    display: flex; flex-direction: column; justify-content: center;
    min-height: calc(100svh - 24px);
  }
}

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

/* しるし入力の「けす」だけ、少し小さい文字にします */
.symbolpad__grid .is-del { font-size: clamp(13px,3.6vw,16px); }
