* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #fbf3e6;
  color: #4a3a30;
  font-family: -apple-system, "Hiragino Maru Gothic ProN", "Hiragino Sans", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 上の帯（戻る・やり直す）の下の部分を、残りの場所の真ん中に置く。
   盤が画面の上に寄って、下半分が空かないようにするため（T04） */
.app { min-height: 100vh; min-height: 100dvh; }
.app > .top + * { margin-top: auto; }
.app > :last-child { margin-bottom: auto; }

.top { display: flex; justify-content: space-between; align-items: center; }
.mode-label { font-size: 15px; }

.btn {
  font: inherit;
  font-size: 15px;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: #e0884a;
  color: #fff;
}

.cat { width: 100%; height: 100%; display: block; overflow: visible; }

/* お題 */
.quest {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 16px;
  background: #fffaf2;
  box-shadow: 0 2px 0 #eadfd2;
}
.quest-cat { width: 72px; height: 72px; flex: none; }
.quest-text { flex: 1; }
.quest-title { font-size: 18px; font-weight: bold; }
.quest-acc { font-size: 13px; opacity: 0.75; margin: 2px 0 6px; }
.quest-count { display: flex; align-items: center; gap: 6px; }
.mark {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid #e0884a;
}
.mark.on { background: #e0884a; }
.count-text { font-size: 14px; margin-left: 4px; }

/* 盤面: 畳の上に猫が散らばっている */
.field {
  position: relative;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0.035) 0 2px, transparent 2px 9px),
    #d9cf9a;
  box-shadow: inset 0 0 0 3px #b8ab6c;
}
.fcat {
  position: absolute;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
}
.fcat-art {
  display: block;
  width: 100%; height: 100%;
  transform: rotate(var(--rot));
  transition: transform 0.25s;
}
.fcat.found { z-index: 2; }
.fcat.found .fcat-art { transform: rotate(0deg) scale(1.15); }
.fcat.found::after {
  content: '';
  position: absolute;
  inset: -12%;
  border: 4px solid #e5728a;
  border-radius: 50%;
  animation: pop 0.3s ease-out;
  pointer-events: none;
}
@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.fcat.shake .fcat-art { animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { translate: 0; }
  25% { translate: -4px; }
  75% { translate: 4px; }
}

/* 結果 */
.overlay {
  position: fixed; inset: 0;
  background: rgba(60, 40, 30, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 10;
}
.overlay[hidden] { display: none; }
.overlay-card {
  background: #fffaf2;
  padding: 24px 32px;
  border-radius: 16px;
  text-align: center;
}
.overlay-card p { font-size: 22px; margin: 0 0 16px; }
.overlay-buttons { display: flex; gap: 10px; justify-content: center; }
.btn-sub { background: #b9a08a; }
.overlay-stamp { font-size: 15px; margin: -4px 0 18px; }
.overlay-stamp[hidden] { display: none; }
.overlay-paws { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.overlay-paws .paw { width: 40px; height: 40px; fill: #e5728a; transform: rotate(-12deg); }
.back-link { display: block; margin-top: 8px; font-size: 15px; color: #8a6f5a; text-decoration: none; padding: 8px; }

/* ホーム・遊び方画面（難易度はホーム画面で選ぶ） */
.screen { background: #fbf3e6; }
.screen .overlay-card { background: transparent; width: min(320px, 100%); }
.title-name { font-size: 34px !important; font-weight: bold; margin-bottom: 8px !important; }
.title-name + .menu-buttons { margin-top: 28px; }
.home-modes { margin: 6px 0 0; }
.screen-title { font-size: 24px !important; font-weight: bold; }
.menu-buttons { display: flex; flex-direction: column; gap: 14px; }
.btn-big { font-size: 20px; padding: 14px 0; width: 100%; }
.option-group { margin-bottom: 28px; text-align: left; }
.option-label { font-size: 15px; margin-bottom: 8px; }
.modes { display: flex; gap: 8px; }
.mode-choice {
  flex: 1;
  font: inherit;
  font-size: 15px;
  padding: 12px 2px;
  white-space: nowrap;
  border-radius: 12px;
  border: 3px solid transparent;
  background: #eadfd2;
  color: #6b5a4c;
}
.mode-choice.selected { color: #fff; border-color: #4a3a30; }
.mode-easy.selected { background: #7cb97a; }
.mode-normal.selected { background: #e0884a; }
.mode-hard.selected { background: #c95a5a; }

/* 遊び方画面（ねこソートと同じ見た目） */
.howto-card { width: min(400px, 100%) !important; text-align: left; }
.howto-card .screen-title { text-align: center; }
.howto-list { margin: 0 0 16px; padding-left: 1.4em; font-size: 15px; line-height: 1.6; }
.howto-list li { margin-bottom: 8px; }
.howto-tip { font-size: 14px !important; margin: 0 0 10px !important; opacity: 0.85; }
.howto-card .btn-big { margin-top: 12px; }
