* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #2b2540;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
}

#stage {
  position: relative;
  width: 100vw;
  max-width: 520px;          /* PCで開いたときも縦画面の比率で遊べるように */
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: #fdf3dc;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* セーフエリア上端の高さを JS から読むための計測用 */
#safeTop {
  position: absolute;
  top: 0; left: 0;
  width: 1px;
  height: env(safe-area-inset-top, 0px);
  pointer-events: none;
  visibility: hidden;
}

#mute {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 26px);
  right: 10px;
  width: 40px; height: 40px;
  border: 2px solid #4a3b2a;
  border-radius: 50%;
  background: #fffaf0;
  color: #4a3b2a;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}
#mute.off { color: #c9bfae; border-color: #c9bfae; text-decoration: line-through; }

/* ---- タイトル ---- */
#titleCard {
  position: absolute;
  left: 0; right: 0;
  top: 37%;
  text-align: center;
  pointer-events: none;
  color: #4a3b2a;
  transition: opacity .25s;
}
#titleCard.hide { opacity: 0; }
#titleCard h1 {
  font-size: 30px;
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: .02em;
  text-shadow: 0 2px 0 #fff, 0 -2px 0 #fff, 2px 0 0 #fff, -2px 0 0 #fff;
}
#titleCard small { font-size: 14px; }
#titleCard .tap {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  animation: blink 1.1s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .25; } }

/* ---- 結果 ---- */
#result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(43, 37, 64, .45);
  animation: fadeIn .25s ease-out;
}
#result[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.card {
  width: 100%;
  max-width: 340px;
  padding: 24px 20px 22px;
  border: 3px solid #4a3b2a;
  border-radius: 22px;
  background: #fffaf0;
  box-shadow: 0 8px 0 rgba(0, 0, 0, .18);
  text-align: center;
  color: #4a3b2a;
  animation: pop .35s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

.label { font-size: 14px; font-weight: 700; letter-spacing: .2em; }
.rate { font-size: 76px; font-weight: 900; line-height: 1.05; color: #e0356f; font-variant-numeric: tabular-nums; }
.rate i { font-size: 30px; font-style: normal; margin-left: 2px; }
.grade {
  display: inline-block;
  margin-top: 6px;
  padding: 6px 18px;
  border-radius: 999px;
  background: #4a3b2a;
  color: #fffaf0;
  font-size: 24px;
  font-weight: 900;
  min-height: 1.5em;
}
.quote { margin-top: 14px; font-size: 15px; font-weight: 700; line-height: 1.5; min-height: 3em; }
.quote::before { content: "「"; }
.quote::after { content: "」"; }
.stats { margin-top: 6px; font-size: 13px; color: #8a7a66; }

#retry {
  margin-top: 18px;
  width: 100%;
  padding: 16px 0;
  border: 3px solid #4a3b2a;
  border-radius: 16px;
  background: #ffd24a;
  color: #4a3b2a;
  font: inherit;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 5px 0 #4a3b2a;
}
#retry:active { transform: translateY(4px); box-shadow: 0 1px 0 #4a3b2a; }

.card { max-height: 100%; overflow-y: auto; touch-action: pan-y; }
.caught-list { margin-top: 12px; text-align: left; font-size: 13px; }
#caughtWords { margin-top: 6px; max-height: 100px; overflow-y: auto; line-height: 1.8; touch-action: pan-y; user-select: text; }

/* v2: 教室の黒板と結果 */
#titleCard { top:31%; }
#titleCard h1 { font-size:24px; }
#visit { margin-top:8px; font-size:12px; }
#restart { position:absolute;bottom:18px;left:12px;border:0;background:#fffaf0d9;color:#4a3b2a;padding:10px;border-radius:10px;font:inherit;font-size:12px; }
#next { margin-top:14px;width:100%;padding:14px;border:3px solid #4a3b2a;border-radius:16px;background:#ffd24a;font:inherit;font-size:20px;font-weight:900;box-shadow:0 5px #4a3b2a;color:#4a3b2a; }
#retry.secondary { background:transparent;box-shadow:none;border:0;font-size:14px;margin-top:8px;padding:8px; }
#stamp { border:2px solid currentColor;border-radius:50%;display:inline-block;padding:7px;font-weight:900;font-size:13px;transform:rotate(-8deg); }
#stamp.passed { color:#c53a37; } #stamp.failed { color:#8a7a66; }
#resultDay { font-weight:900;margin-bottom:6px; } #resultVisit { margin-top:12px;font-size:11px; }

/* v3: score decoration; pass criterion is outside the stamp. */
#resultStaff { width:100%; height:38px; display:block; margin-bottom:6px; }
#passLine { margin-top:5px; font-size:12px; color:#8a7a66; }
