:root {
  --bg: #faf3ec;
  --card: #ffffff;
  --ink: #4a3428;
  --sub: #7d6355;
  --rose: #c96f6f;
  --rose-dark: #a85454;
  --green: #06c755;
  --line: #e7d6c8;
  --table: #efe2d4;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Meiryo", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--rose-dark); }

/* はじめの画面 */
#menu { max-width: 760px; margin: 0 auto; padding: 20px 16px 40px; }
.menu-head { text-align: center; margin-bottom: 8px; }
h1 { font-size: 30px; margin: 8px 0 4px; }
.sub { margin: 0 0 6px; font-size: 18px; color: var(--sub); font-weight: bold; letter-spacing: .1em; }
.lead { margin: 0; font-size: 19px; color: var(--sub); }
h2 { font-size: 22px; margin: 28px 0 12px; display: flex; align-items: center; gap: 10px; }
.num {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--rose); color: #fff; font-size: 19px;
}
.small { font-size: 15px; color: var(--sub); margin: 8px 0 0; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.pic {
  border: 4px solid transparent; border-radius: 16px; padding: 0;
  background: var(--card); cursor: pointer; overflow: hidden;
  box-shadow: 0 2px 8px rgba(74, 52, 40, .12);
  font: inherit; color: inherit; text-align: center;
}
.pic img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.pic span { display: block; padding: 6px 4px 8px; font-size: 18px; font-weight: bold; }
.pic.on { border-color: var(--rose); box-shadow: 0 0 0 3px rgba(201, 111, 111, .3); }

.photo-btn {
  display: block; margin-top: 14px; padding: 16px; text-align: center;
  border: 3px dashed var(--rose); border-radius: 16px; background: #fff;
  font-size: 20px; font-weight: bold; color: var(--rose-dark); cursor: pointer;
}
.photo-btn.on { border-style: solid; background: #fdeeee; }

.sizes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.size {
  border: 3px solid var(--line); border-radius: 16px; background: #fff;
  padding: 12px 6px; font: inherit; color: inherit; cursor: pointer;
}
.size b { display: block; font-size: 26px; }
.size small { font-size: 16px; color: var(--sub); }
.size.on { border-color: var(--rose); background: #fdeeee; }

.big-btn {
  display: block; width: 100%; padding: 16px; margin-top: 12px;
  border: 0; border-radius: 999px; background: #fff; color: var(--ink);
  font: inherit; font-size: 21px; font-weight: bold; cursor: pointer;
  box-shadow: 0 2px 6px rgba(74, 52, 40, .18);
}
.big-btn.rose { background: var(--rose); color: #fff; }
.big-btn.green { background: var(--green); color: #fff; }
.big-btn:disabled { opacity: .45; cursor: default; }
.start { margin-top: 28px; font-size: 24px; padding: 18px; }
.resume { margin-top: 18px; text-align: center; }
.foot { text-align: center; margin-top: 30px; font-size: 20px; }
.foot a { color: var(--ink); text-decoration: none; font-weight: bold; }

@media (min-width: 640px) {
  .gallery { grid-template-columns: repeat(3, 1fr); }
  .sizes { grid-template-columns: repeat(4, 1fr); }
}

/* 遊ぶ画面 */
#game { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--table); }
.bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px max(8px, env(safe-area-inset-left)) 8px max(8px, env(safe-area-inset-right));
  background: #fff; border-bottom: 2px solid var(--line);
}
.tool {
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: 8px 12px; font: inherit; font-size: 17px; font-weight: bold;
  cursor: pointer; white-space: nowrap;
}
.tool:active { background: #fdeeee; }
.stat { flex: 1; display: flex; justify-content: center; gap: 14px; font-size: 19px; font-weight: bold; font-variant-numeric: tabular-nums; }
.stat span { white-space: nowrap; }
@media (max-width: 440px) {
  .tool { padding: 8px 9px; font-size: 16px; }
  .stat { gap: 8px; font-size: 17px; }
}
#board { flex: 1; width: 100%; min-height: 0; display: block; touch-action: none; cursor: grab; }

/* 重ねる画面 */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(40, 28, 20, .55);
  display: grid; place-items: center; padding: 16px;
}
.peek-box, .done-box {
  position: relative; background: #fff; border-radius: 20px; padding: 16px;
  width: min(560px, 100%); max-height: 100%; overflow: auto; text-align: center;
}
.peek-box img { display: block; width: 100%; border-radius: 10px; }
.done-title { font-size: 34px; font-weight: bold; margin: 4px 0; }
.done-text { font-size: 20px; margin: 0 0 6px; }
#confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* この1枚：合言葉 */
a.big-btn { text-decoration: none; box-sizing: border-box; }
.prize { margin: 10px 0 6px; padding: 14px; border: 3px dashed var(--rose); border-radius: 18px; background: #fff8f4; }
.prize-label { margin: 0; font-size: 18px; color: var(--sub); font-weight: bold; }
.prize-word { margin: 2px 0 8px; font-size: 40px; font-weight: bold; color: var(--rose); letter-spacing: .08em; }
.prize-note { margin: 0; font-size: 18px; line-height: 1.6; }

/* ランキング（バージョン2） */
.week {
  display: block; margin: 18px 0 0; padding: 16px; border-radius: 18px; text-decoration: none;
  background: #fff4d6; border: 3px solid #f5b942; color: var(--ink); text-align: center;
}
.week b { display: block; font-size: 22px; }
.week span { display: block; font-size: 17px; color: var(--sub); }
.champ { margin: 10px 0 0; text-align: center; font-size: 19px; font-weight: bold; }
.rank-box { margin: 10px 0 6px; padding: 14px; border: 3px solid #f5b942; border-radius: 18px; background: #fffaf0; }
.rank-input {
  display: block; width: 100%; margin-top: 8px; padding: 14px; font: inherit; font-size: 21px;
  border: 3px solid var(--line); border-radius: 14px; text-align: center; color: var(--ink); background: #fff;
}
.rank-input:focus { outline: none; border-color: var(--rose); }
.err { margin: 8px 0 0; color: #b3261e; font-weight: bold; font-size: 18px; }
.rank-me { margin: 4px 0; font-size: 24px; font-weight: bold; color: var(--rose-dark); }
.rank-code { margin: 0 0 6px; font-size: 18px; line-height: 1.6; }
.rank-code b { font-size: 26px; letter-spacing: .15em; }
.rank-list { list-style: none; margin: 8px 0 0; padding: 0; text-align: left; font-size: 19px; }
.rank-list li { display: flex; gap: 10px; padding: 6px 8px; border-bottom: 1px dashed var(--line); }
.rank-list li.me { background: #fdeeee; border-radius: 8px; font-weight: bold; }
.rank-list .r { width: 2.6em; text-align: right; font-weight: bold; }
.rank-list .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .t { font-variant-numeric: tabular-nums; }
.rank-box .small { font-size: 17px; }

/* 名前は公開される、の注意（見落とさない大きさで） */
.notice { background: #fff4d6; border: 2px solid #e0a800; color: #4a3500; border-radius: 10px; padding: 10px 12px; font-size: 17px; line-height: 1.6; margin: 0 0 10px; text-align: left; }
