/* ============================================================
   けいさんカード — プレイ画面の部品(カード・○×・タイム・すうじボタン)
   アプリ本体(app.html。style.css の前に読む)と LP の「おためし5問」(index.html。lp.css の前に読む)で共用する。
   style.css から切り出したもので、カードや○×の見た目はアプリとLPで必ず一致させるためここだけを直す。
   色などの変数(--ink, --maru, --batsu 等)は読み込む側の :root が持つ。
   ============================================================ */

.num {
  font-family: var(--font-num);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

#confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ---------- ステッカー(共通部品) ---------- */
.sticker {
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
button.sticker:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--ink);
}

.play-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress {
  font-size: 1rem;
  opacity: 0.8;
}
.timer {
  margin-left: auto;
  font-size: 1.5rem;
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 2px 12px;
  box-shadow: 0 3px 0 var(--ink);
}

.card-area {
  position: relative;
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
}

.card {
  position: relative; /* .judge を内側にぴったり重ねる基準にする */
  width: 100%;
  min-width: 0; /* grid item のデフォルトmin-width:autoがnowrapテキストの幅に
                   引っ張られて100%を超えて広がってしまうのを防ぐ */
  padding: clamp(20px, 6vh, 48px) 12px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35em;
  font-size: clamp(2.5rem, 12.5vw, 3.6rem);
  background:
    linear-gradient(var(--white), var(--white)) padding-box,
    var(--white);
  border-radius: 30px;
  cursor: default;
}
.card-text {
  white-space: nowrap; /* "10 − 10" のような幅の広い式が2行に折り返さないようにする */
}
/* 通常の計算式(a op b = ?)の行。以前は.card自体がこのレイアウトだったが、
   .card-clockと共存させるため独立した要素に切り出した */
.card-arith {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35em;
  width: 100%;
}
.card-answer {
  color: #c9bfae;
}

/* ○ / × / カウントダウン のオーバーレイ */
.judge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 10;
}

.judge.maru::before {
  content: '';
  width: min(46vw, 210px);
  height: min(46vw, 210px);
  border: 14px solid var(--maru);
  border-radius: 50%;
  animation: maru-pop 0.55s ease-out forwards;
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.12));
}
@keyframes maru-pop {
  0%   { transform: scale(0.3); opacity: 0; }
  35%  { transform: scale(1.08); opacity: 1; }
  70%  { transform: scale(1); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

.judge.batsu {
  flex-direction: column;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  animation: batsu-shake 0.4s ease;
}
.batsu-mark {
  font-size: min(22vw, 96px);
  line-height: 1;
  color: var(--batsu);
  font-weight: 900;
  opacity: 0.4; /* 問題の数字が透けて見えるようにし、問題が読めなくなるのを防ぐ */
  filter: drop-shadow(0 3px 0 rgba(0, 0, 0, 0.12));
}
.batsu-text {
  font-size: 1.4rem;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 999px;
  padding: 4px 18px;
  box-shadow: 0 3px 0 var(--ink);
}
@keyframes batsu-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  50% { transform: translateX(10px); }
  75% { transform: translateX(-6px); }
}

.numpad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  /* 行の高さを固定し、ボタン数が少ない段階(例: clock30の分=0/30)でも
     見た目の段数によらず常に同じ高さになるようにする(内容に依存させない) */
  grid-auto-rows: 66px;
  gap: 8px;
  /* iPhoneは画面物理形状自体が角丸になっており、env(safe-area-inset-*)では
     考慮されない。左下の「6」など画面の角に一番近いボタンが角の丸みに
     少しかかって見切れて見えるため、下側に余分な余白を足して避ける */
  padding-bottom: 20px;
}
/* 計算モードは5列: 0のある/なしによらず上段1〜5・下段6〜10で指の位置が固定される。
   0は答えになることが少ない特別なキーなので、電話のキーパッドと同じく
   3段目の中央に置く(ボタンの並び順では最後: js/modes.js の answerChoices 参照) */
/* 計算モードは電卓・電話と同じ3列。1〜9が3×3にそろうので指の位置を覚えやすい。
   10は9のつぎ(4段目の左)、0は同じ段の右端に置く。
   0の有無で1〜10の位置が動かないので、設定を切り替えても指の記憶がそのまま使える。
   幅はカード・マイクの文言と同じ左右いっぱいにする(絞って中央寄せにすると
   左端がそろわず、画面全体で見たときにキーパッドだけ浮いて見える) */
.numpad.numpad-arith {
  grid-template-columns: repeat(3, 1fr);
  /* 横に広がるぶん、ボタンが平たくなりすぎないよう段の高さを上げる */
  grid-auto-rows: 76px;
}
/* 0は下段の中央に。ひきざん・あなうめでは答えが0になるカードが各10枚あり、
   実は答え全体で2番目に多い(=よく押す)ため、届きやすい位置に置く */
.numpad.numpad-arith .num-btn[data-value='0'] {
  grid-column: 2;
}
.num-btn {
  font-size: 1.5rem;
  padding: 12px 0;
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}
.num-btn:nth-child(odd) { background: #fff1de; }
/* ボタン数が少ない段階でもグリッドの段数(高さ)を保つための見えない埋め要素。
   .num-btnと同じ箱の大きさを保ちつつ、見た目・操作を完全に消す */
.num-btn-filler {
  visibility: hidden;
  pointer-events: none;
}

/* スタート待ちの覆い。カードの数字が先に見えないように、カードの内側をぴったり白く覆う */
.judge.cover {
  pointer-events: auto; /* スタートボタンをタップできるようにする */
  background: var(--white);
  border-radius: 27px; /* .card の30pxから枠線3px分小さくし、内側にぴったり収める */
}
.start-prompt {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(1.6rem, 8vw, 2.6rem);
  color: var(--ink);
  background: none;
  border: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  animation: start-pulse 1.6s ease-in-out infinite;
}
@keyframes start-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}
/* カウントダウン(js/countdown.js)。スタート待ち・カウントダウンの間、カード自体の数字(例: 3+2=?)が
   先読みできてしまったり重なって読みにくくならないよう完全に覆い隠す。
   .judge は .card の内側の要素になったので(index.html参照)、.card と
   別々にサイズを計算する必要がなく、常にぴったり同じ大きさになる。
   (以前は .card-area 基準の別要素だったため、フォントサイズの違いで
   高さがずれ、カードの縁が透けて見えてしまっていた) */
.judge.cover.count {
  font-family: var(--font-num);
  font-size: clamp(3rem, 20vw, 7rem);
  line-height: 1;
  color: var(--ink);
  background: var(--sun); /* 「カウント中」だと分かるよう問題カードの白と区別する */
}
/* 「スタート!」は数字より文字数が多いので、1行に収まるよう小さくする */
.judge.cover.count.start {
  font-size: clamp(2rem, 13vw, 4.2rem);
  white-space: nowrap;
}
/* ポップ演出は文字(.count-text)だけにかける。#judge自体にかけると
   アニメーション開始時のopacity:0で背景ごと透明になり、後ろの問題が
   一瞬見えてしまうため、常に不透明な背景(覆い)とは切り離す */
.count-text {
  display: inline-block; /* transformが効くように */
}
.count-text.pop {
  animation: count-pop 0.6s ease-out;
}
@keyframes count-pop {
  0%  { transform: scale(0.4); opacity: 0; }
  40% { transform: scale(1.15); opacity: 1; }
  70% { transform: scale(1); }
}
