/* =========================================================
   短期記憶力テスト
   スマホ縦持ちを基準に、640px以上でPC向けへ広げる。

   注意:
   ゲーム盤は main.js が読み込み時点の #canvas_wrapper の幅を見て
   サイズを決めている。したがって .main_wrap を display:none に
   してはいけない（幅が0になり盤面が潰れる）。
   ========================================================= */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", YuGothic,
               "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", Arial,
               "メイリオ", Meiryo, sans-serif;
  color: #2e2e2e;
  background: #f4f5f7;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

img { max-width: 100%; }
h1, p, ol, ul { margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }

/* ---------------- ページ見出し ---------------- */

.page_head {
  background: #2b3245;
  color: #fff;
  text-align: center;
  padding: 26px 16px 22px;
}

.page_title { font-size: 1.45rem; font-weight: 700; letter-spacing: 0.02em; }
.page_sub { font-size: 0.8rem; color: #aab2c6; margin-top: 4px; }

/* ---------------- 全体の器 ---------------- */

.kioku_content {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 12px 0;
}

/* ---------------- スタート画面 ---------------- */

.start {
  background: #fff;
  border-radius: 14px;
  padding: 22px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.lead {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.rules { list-style: none; }

.rules li {
  position: relative;
  padding-left: 34px;
  font-size: 0.86rem;
  line-height: 1.7;
  margin-bottom: 10px;
  color: #4a4a4a;
}

.rule_no {
  position: absolute;
  left: 0;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2b3245;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.caution {
  font-size: 0.72rem;
  color: #999;
  line-height: 1.7;
  margin-top: 14px;
  text-align: center;
}

/* ---------------- ボタン ---------------- */

.button_wrap { text-align: center; margin-top: 18px; }

.btn-square-shadow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 220px;
  padding: 13px 28px;
  background: #f5c94d;
  color: #3a3a3a;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 40px;
  box-shadow: 0 4px 0 #d8ac2c;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.btn-square-shadow:active { transform: translateY(3px); box-shadow: 0 1px 0 #d8ac2c; }
.btn-square-shadow img { width: 20px; height: auto; }

/* ---------------- 広告 ---------------- */

.ads_wrap { text-align: center; margin: 16px 0; }

/* ---------------- ゲーム画面 ---------------- */

/* visibility で隠す（display:none にすると盤面の幅が測れなくなる）。
   高さも詰めておき、開始時に main.js が height:auto に戻す。 */
.main_wrap {
  visibility: hidden;
  height: 0;
  overflow: hidden;
  background: #fff;
  border-radius: 14px;
  padding: 0 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.game_header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 2px 10px;
}

.stage {
  font-size: 1rem;
  font-weight: 700;
  color: #2b3245;
  letter-spacing: 0.03em;
}

.life { display: flex; gap: 4px; }
.life img { width: 22px; height: 22px; }
.clear { display: none; }

#canvas_wrapper {
  position: relative;
  max-width: 420px;
  margin: 0 auto;
  padding-bottom: 16px;
  text-align: center;
}

#timerCanvas { display: block; margin: 0 auto 8px; }
#myCanvas { display: block; margin: 0 auto; touch-action: manipulation; }

/* ---------------- 結果画面 ---------------- */

.result {
  display: none;
  background: #fff;
  border-radius: 14px;
  padding: 22px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.result_title { text-align: center; margin-bottom: 14px; }

.result_title_text {
  display: inline-block;
  padding: 3px 22px;
  background: #2b3245;
  color: #fff;
  border-radius: 30px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.rank_wrap { text-align: center; }

.rank {
  font-size: 1.7rem;
  font-weight: 700;
  color: #f74646;
  line-height: 1.4;
}

.rank_img { margin-top: 6px; }
.rank_img img { border-radius: 8px; }

.detail {
  text-align: center;
  font-size: 1rem;
  color: #3a3a3a;
  margin-top: 10px;
}

.detail p { margin: 0; }

/* 分布グラフ */

.graph_wrap {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #ececec;
}

.result_graph_title {
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #2b3245;
  margin-bottom: 6px;
}

.result_graph { max-width: 380px; margin: 0 auto; }

.graph_status {
  text-align: center;
  font-size: 0.78rem;
  color: #8a8a8a;
  margin-top: 2px;
}

.graph_text {
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.8;
  margin-top: 10px;
  color: #3a3a3a;
}

#percent { font-weight: 700; color: #f74646; }

/* 結果画面のボタン */

.all_button_wrap { margin-top: 22px; }
.twitter_share_wrap { text-align: center; }

.twitter_share_button a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 220px;
  padding: 13px 24px;
  background: #1da1f2;
  color: #fff;
  border-radius: 40px;
  font-size: 0.98rem;
  font-weight: 700;
}

.twitter_share_button img { width: 18px; height: 18px; }

/* ---------------- フッター ---------------- */

#foot { padding-bottom: 30px; }

.sns_share_button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 22px 0 26px;
}

.share_label {
  width: 100%;
  text-align: center;
  font-size: 0.78rem;
  color: #888;
  margin-bottom: 2px;
}

.sns {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
}

.sns img { width: 18px; height: 18px; }
.btn-twitter { background: #1da1f2; }
.btn-line { background: #00b900; }
.btn-facebook { background: #3b5998; }

.others { margin-top: 8px; }

.others_title {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #2b3245;
  margin-bottom: 12px;
}

.others_list { list-style: none; }

.others_list li { margin-bottom: 12px; }

.others_list a {
  display: block;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.others_list img {
  width: 100%;
  height: 128px;
  object-fit: cover;
  display: block;
}

.others .text {
  padding: 8px 12px;
  font-size: 0.8rem;
  line-height: 1.6;
  color: #3a3a3a;
}

.back_to_menu { text-align: center; margin: 26px 0 0; }

.back_to_menu a {
  display: inline-block;
  padding: 10px 24px;
  border: 1px solid #ccc;
  border-radius: 30px;
  color: #555;
  font-size: 0.85rem;
  background: #fff;
}

.maker {
  text-align: center;
  font-size: 0.78rem;
  color: #888;
  margin-top: 24px;
}

.maker a { color: #1da1f2; }

/* =========================================================
   PC / タブレット
   ========================================================= */

@media screen and (min-width: 640px) {

  .page_head { padding: 34px 16px 28px; }
  .page_title { font-size: 1.9rem; }
  .page_sub { font-size: 0.9rem; }

  .kioku_content { max-width: 640px; padding: 24px 20px 0; }

  .start, .result { padding: 28px 30px; }
  .lead { font-size: 1.2rem; }
  .rules li { font-size: 0.92rem; }

  .rank { font-size: 2rem; }
  .detail { font-size: 1.08rem; }
  .graph_text { font-size: 0.98rem; }

  /* その他のクイズは2列に */
  .others_list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .others_list li { margin-bottom: 0; }
  .others_list img { height: 120px; }
}
