/* Canvas で描くミニゲーム（おにぎり開封・弁当温めガチャ・次の方どうぞ）に共通の画面
   上の帯（戻る・ロゴ・音），店長のひとこと，画面下の説明，下から出るカード（はじめ・結果・エラー） */
:root {
  font-family: 'Hiragino Sans', 'Yu Gothic', 'Noto Sans JP', sans-serif;
  color: #213e36;
  font-synthesis: none;
  --table: #efe7d8;
  --paper: #fffdf4;
  --green: #285f48;
  --muted: #6f7a6e;
  --accent: #d9483b;
  --hint: #e58a2e;
  --line: #213e3622;
  --gutter: max(16px, env(safe-area-inset-left));
  --bottom: max(18px, env(safe-area-inset-bottom));
  --header-top: max(14px, env(safe-area-inset-top));
  /* 店長のひとことの高さ（上の帯からの距離）．ゲームごとに変えられる */
  --comment-offset: 52px;
  --comment-offset-large: 70px;
  --comment-offset-short: 44px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  height: 100dvh;
  background: radial-gradient(ellipse at 50% 40%, #f7f1e6, var(--table) 70%);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button,
a,
.stage {
  -webkit-touch-callout: none;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--hint);
  outline-offset: 3px;
}

.stage {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 上の帯（戻る・ロゴ・音） */
.game-header {
  position: fixed;
  top: var(--header-top);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.game-header > * {
  pointer-events: auto;
}

.back-link,
.sound-toggle {
  font-size: 11px;
  letter-spacing: .04em;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 9px 13px;
  background: #fffdf4d0;
  backdrop-filter: blur(10px);
  color: #375a47;
}

.back-link span {
  margin-right: 5px;
}

.mini-logo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -.03em;
}

.mini-logo b {
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  background: #47735b;
  color: #fff9e6;
  border-radius: 6px 6px 6px 0;
  font-size: 16px;
}

/* 店長のひとこと */
.boss-comment {
  position: fixed;
  top: calc(var(--header-top) + var(--comment-offset));
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 6px;
  margin: 0;
  padding: 0 var(--gutter);
  font-size: 12px;
  line-height: 1.6;
  pointer-events: none;
}

.boss-comment span,
.result-comment span {
  flex: none;
  font-size: 9px;
  border: 1px solid #61755640;
  padding: 0 5px;
  border-radius: 4px;
  margin-top: 3px;
}

.boss-comment b {
  font-weight: 600;
  background: #fffdf4e0;
  padding: 6px 12px;
  border-radius: 0 12px 12px 12px;
}

/* 画面下の説明 */
.play-hint {
  position: fixed;
  bottom: var(--bottom);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 3;
  margin: 0 auto;
  max-width: 420px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #fffdf4d8;
  backdrop-filter: blur(8px);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  color: #3d5a49;
  pointer-events: none;
}

/* 下から出るカード（はじめ・結果・エラー） */
.sheet {
  position: fixed;
  z-index: 4;
  bottom: var(--bottom);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 32px));
  padding: 20px 22px 14px;
  border-radius: 22px;
  border: 1px solid #ffffffb0;
  background: #fffdf4ee;
  box-shadow: 0 8px 40px #4a3a2214;
  backdrop-filter: blur(16px);
}

.eyebrow {
  display: block;
  font-size: 10px;
  letter-spacing: .14em;
  color: #7a8571;
}

.intro-sheet {
  text-align: center;
}

.intro-sheet h1 {
  font-size: 30px;
  letter-spacing: -.05em;
  margin: 6px 0 4px;
  font-weight: 900;
}

.lead {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--accent);
}

.howto {
  font-size: 11px;
  line-height: 1.8;
  margin: 0 0 14px;
  color: var(--muted);
}

.primary-button {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 50px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: var(--green);
  color: #fff9e7;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  transition: background .2s, transform .15s;
}

.primary-button:hover {
  background: #1c4936;
}

.primary-button:active {
  transform: translateY(2px);
}

.primary-button span {
  font-size: 18px;
  font-weight: 400;
}

.collection-note {
  min-height: 1em;
  font-size: 10px;
  margin: 10px 0 0;
  color: #8a937f;
}

.result-sheet h2 {
  font-size: clamp(22px, 7vw, 28px);
  letter-spacing: -.04em;
  margin: 6px 0 2px;
  font-weight: 900;
}

.result-sheet[data-quality="perfect"] h2 {
  color: #b9860f;
}

.result-meta {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 10px;
  color: var(--accent);
}

.result-comment {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  line-height: 1.7;
  margin: 0 0 10px;
}

.result-comment b {
  font-weight: 600;
}

.result-detail {
  font-size: 11px;
  margin: 0 0 10px;
  color: var(--muted);
}

.result-collection {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  margin: 0 0 12px;
  color: var(--muted);
}

.new-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 20px;
  color: #fff9ec;
  background: var(--hint);
}

.result-actions {
  display: flex;
  gap: 8px;
}

.result-actions .primary-button {
  flex: 1;
}

.photo-button {
  flex: none;
  border: 1px solid #45634128;
  border-radius: 12px;
  color: #4f684a;
  background: #f1f3e7;
  font-size: 12px;
  padding: 10px 14px;
  white-space: nowrap;
}

.photo-button:disabled {
  opacity: .45;
  cursor: default;
}

.result-back {
  display: block;
  text-align: center;
  font-size: 10px;
  color: #8a967b;
  margin-top: 12px;
}

.error-sheet h2 {
  font-size: 20px;
  margin: 0 0 8px;
}

.error-sheet p {
  font-size: 12px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

/* 横長の画面：左に絵，右にカード（各ゲームの View の WIDE_ASPECT・WIDE_COLUMN_RATIO と合わせる） */
@media (min-aspect-ratio: 5/4) {
  .boss-comment,
  .play-hint {
    right: 36%;
  }

  .play-hint {
    left: var(--gutter);
    margin: 0 auto;
  }

  .sheet {
    left: auto;
    right: max(24px, 3vw);
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    width: min(400px, max(280px, 32vw));
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
  }
}

/* パソコンなどの大きな画面では，文字を少し大きく */
@media (min-width: 900px) and (min-height: 600px) {
  .boss-comment {
    top: calc(var(--header-top) + var(--comment-offset-large));
    font-size: 14px;
  }

  .play-hint {
    font-size: 15px;
  }

  .sheet {
    padding: 26px 28px 18px;
  }

  .intro-sheet h1 {
    font-size: 36px;
  }

  .lead,
  .result-meta {
    font-size: 15px;
  }

  .howto,
  .result-comment {
    font-size: 13px;
  }
}

/* 横長で背の低い画面（スマホの横持ち）では，カードを下に寄せて小さく */
@media (max-height: 520px) and (min-aspect-ratio: 5/4) {
  .sheet {
    top: auto;
    bottom: var(--bottom);
    transform: none;
    padding: 14px 18px 10px;
  }

  .intro-sheet h1 {
    font-size: 24px;
  }

  .howto {
    display: none;
  }

  .boss-comment {
    top: calc(max(10px, env(safe-area-inset-top)) + var(--comment-offset-short));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
