/* ================================================================
   自己ホスト Nunito（latin, 400 / 700 / 900）
   出典: @fontsource/nunito 5.2.5 — SIL Open Font License 1.1
   フォントファイルの場所: /fonts/ （リポジトリルート）
   make10/style.css と同じ定義です。外部リクエストは発生しません。
   ================================================================ */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/nunito-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/nunito-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../fonts/nunito-latin-900.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}


/* ================================================================
   style.css – テンパズル 全スタイル
   構成:
   01. CSS カスタムプロパティ（カラーパレット）
   02. リセット & ベース
   03. 背景アニメーション（光球）
   04. レイアウト（header / main / footer）
   05. 画面切り替え（.screen / .active）
   06. ガラスカード
   07. ヘッダー
   08. フッター
   09. トップ画面：ルール文とモード選択
   10. ボタン共通・バリアント
   11. ゲーム画面：ヘッダー行
   12. ゲーム画面：数字タイル
   13. ゲーム画面：式の表示
   14. ゲーム画面：演算子ボタン・補助ボタン
   15. リザルト画面
   16. アニメーション一覧
   17. レスポンシブ

   ★ 01〜10 と 15 は make10/style.css と同じ設計トークン・
     同じクラス名を使っています。見た目を揃えるためです。
     色や角丸を変えるときは両方を直してください。
   ================================================================ */


/* ──────────────────────────────────────────────────────────────
   01. CSS カスタムプロパティ
────────────────────────────────────────────────────────────── */
:root {
  --bg:           #f5f0e6;
  --card:         #ffffff;
  --choice-fill:  #fdf8ee;
  --primary:      #4d80d1;
  --accent:       #9a6bc7;
  --gauge-full:   #6bb884;
  --gauge-warn:   #cc7566;
  --gauge-bg:     #dbd9cc;
  --text:         #383843;
  --muted:        #858588;
  --glass:        rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.35);
  --shadow:       rgba(56, 56, 67, 0.08);
}


/* ──────────────────────────────────────────────────────────────
   02. リセット & ベース
────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; }

html, body {
  touch-action: manipulation;           /* ダブルタップズームを抑止する */
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  overflow-x: hidden;
}


/* ──────────────────────────────────────────────────────────────
   03. 背景アニメーション（光球）
────────────────────────────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-orbs .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbFloat 12s ease-in-out infinite alternate;
}

.bg-orbs .orb:nth-child(1) {
  width: 320px; height: 320px;
  background: var(--primary);
  top: -80px; left: -60px;
  animation-duration: 14s;
}

.bg-orbs .orb:nth-child(2) {
  width: 260px; height: 260px;
  background: var(--accent);
  bottom: -40px; right: -40px;
  animation-duration: 10s;
  animation-delay: -4s;
}

.bg-orbs .orb:nth-child(3) {
  width: 200px; height: 200px;
  background: var(--gauge-full);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 16s;
  animation-delay: -8s;
}


/* ──────────────────────────────────────────────────────────────
   04. レイアウト（header / main / footer）
────────────────────────────────────────────────────────────── */
#main-content {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 0 4px;
}

.game-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  height: calc(100dvh - 52px - 34px); /* 全画面高さ − ヘッダー − フッター */
  max-height: 720px;
  padding: 12px 20px 12px;
  display: flex;
  flex-direction: column;
}


/* ──────────────────────────────────────────────────────────────
   05. 画面切り替え
────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  animation: fadeIn 0.4s ease;
}

.screen.active { display: flex; }

/* ゲーム画面は上から順に積む。要素が多いので縦スクロールを許可する。 */
#screen-game {
  justify-content: flex-start;
  width: 100%;
  gap: 10px;
  overflow-y: auto;
}


/* ──────────────────────────────────────────────────────────────
   06. ガラスカード
────────────────────────────────────────────────────────────── */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 8px 32px var(--shadow);
  padding: 28px 24px;
  width: 100%;
}


/* ──────────────────────────────────────────────────────────────
   07. ヘッダー
────────────────────────────────────────────────────────────── */
.site-header {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  text-align: center;
  padding: 10px 20px 6px;
  flex-shrink: 0;
}

.site-title {
  font-size: clamp(1.1rem, 5vw, 1.4rem);
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1;
}

.site-title .title-accent {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.site-tagline {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.12em;
  margin-top: 2px;
}


/* ──────────────────────────────────────────────────────────────
   08. フッター
────────────────────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 2;
  width: 100%;
  text-align: center;
  padding: 4px 12px 10px;
  flex-shrink: 0;
}

.footer-copy {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.8;
}

.footer-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  transition: color 0.2s;
}

.footer-link:hover,
.footer-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
  outline: none;
}


/* ──────────────────────────────────────────────────────────────
   09. トップ画面：ルール文とモード選択
────────────────────────────────────────────────────────────── */
.rule-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-transform: uppercase;
  text-align: center;
}

.title-rule {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  margin-bottom: 20px;
}

.title-rule strong { color: var(--text); }

/*
  日本語の従行（英語メイン・日本語サブ構成）

  ★ 明度を落とさず、文字サイズだけで従属を示している理由 ★
  .title-rule の色 var(--muted) #858588 は、背景 var(--bg) #f5f0e6 に対して
  コントラスト比が約 3.2:1 しかなく、WCAG AA の基準（通常文字 4.5:1）を
  すでに下回っています。ここから opacity で薄くすると日本語の行だけ
  さらに読みにくくなるため、サイズ差だけで主従を表現しています。
  make10/style.css と同じ定義です（両ページで見た目を揃えるため、
  片方を変えるときはもう片方も直してください）。
*/
.tip-ja {
  font-size: 0.9em;
}

/* モード選択ボタンの縦並び */
.mode-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 1つのモードボタン：アイコン＋テキスト＋ハイスコア */
.mode-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--card);
  box-shadow: 0 4px 16px var(--shadow);
  font-family: 'Nunito', sans-serif;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mode-btn:active { transform: scale(0.97); }

.mode-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.mode-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  width: 46px;
}

.mode-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.mode-title {
  font-size: 15px;
  font-weight: 900;
}

.mode-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1.4;
}

/* モードごとのベスト記録。記録がないときは空文字なので何も出ない。 */
.mode-hi {
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
  flex-shrink: 0;
}


/* ──────────────────────────────────────────────────────────────
   10. ボタン共通・バリアント
────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 16px 36px;
  text-decoration: none;
}

.btn:active { transform: scale(0.95); }

.btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 6px 24px rgba(77, 128, 209, 0.3);
}

.btn-primary:active { box-shadow: 0 2px 12px rgba(77, 128, 209, 0.2); }

.btn-appstore {
  background: #000;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.btn-appstore svg { width: 22px; height: 22px; fill: #fff; }

.btn-secondary {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 16px;
  padding: 14px 28px;
}

.btn-home {
  width: 36px; height: 36px;
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.12s ease;
  padding: 0;
  flex-shrink: 0;
}

.btn-home:active { transform: scale(0.9); }

.btn-home:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}


/* ──────────────────────────────────────────────────────────────
   11. ゲーム画面：ヘッダー行
────────────────────────────────────────────────────────────── */
.play-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.progress-display {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.score-display {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  flex-shrink: 0;
}

.score-display span {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  margin-left: 4px;
}


/* ──────────────────────────────────────────────────────────────
   12. ゲーム画面：数字タイル
   4枚の数字。1枚につき1回だけ使えるので、使用済みは薄く表示する。
────────────────────────────────────────────────────────────── */
.digits-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  flex-shrink: 0;
}

.digit-tile {
  aspect-ratio: 1;
  border-radius: 18px;
  border: 1px solid var(--glass-border);
  background: var(--card);
  box-shadow: 0 4px 16px var(--shadow);
  font-family: 'Nunito', sans-serif;
  font-size: 34px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease;
  animation: tileAppear 0.3s ease backwards;
}

.digit-tile:active { transform: scale(0.93); }

.digit-tile:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* 式の中で使用済みの数字。押せなくなるので見た目でも伝える。 */
.digit-tile.used {
  opacity: 0.28;
  cursor: default;
  box-shadow: none;
}


/* ──────────────────────────────────────────────────────────────
   13. ゲーム画面：式の表示
────────────────────────────────────────────────────────────── */
.expr-area {
  width: 100%;
  flex-shrink: 0;
}

.expr-display {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 16px;
  background: var(--choice-fill);
  border: 1px solid var(--glass-border);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--text);
  word-break: break-all;
  text-align: center;
}

/* 式が空のときの案内文 */
.expr-placeholder {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0;
}

/* ヒントの式。💡 を押すまで空。 */
.hint-text {
  min-height: 18px;
  margin-top: 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* 判定メッセージ（正解・ちがう…など） */
.judge-text {
  min-height: 20px;
  margin-top: 2px;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
}

.judge-text.ok   { color: var(--gauge-full); animation: scoreReveal 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.judge-text.ng   { color: var(--gauge-warn); animation: shake 0.4s ease; }


/* ──────────────────────────────────────────────────────────────
   14. ゲーム画面：演算子ボタン・補助ボタン
────────────────────────────────────────────────────────────── */
.ops-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}

.op-btn {
  aspect-ratio: 1;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: 'Nunito', sans-serif;
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.op-btn:active { transform: scale(0.9); }

.op-btn:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.tool-row {
  display: flex;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
}

.btn-tool {
  flex: 1;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease;
}

.btn-tool:active { transform: scale(0.94); }

.btn-tool:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

/* ヒントを使ったあとは押せなくする（見た目でも伝える） */
.btn-tool[disabled] {
  opacity: 0.4;
  cursor: default;
}

.judge-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  flex-shrink: 0;
  padding-bottom: 4px;
}

.btn-judge { width: 100%; padding: 14px 20px; }

/* チャレンジモードだけに出る「作れない！」ボタン */
.btn-impossible {
  width: 100%;
  padding: 12px 20px;
  font-size: 15px;
}


/* ──────────────────────────────────────────────────────────────
   15. リザルト画面
────────────────────────────────────────────────────────────── */
.result-score-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.result-score {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
  animation: scoreReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-message {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 6px;
}

.result-combo {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 28px;
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

.result-hi {
  font-size: 15px;
  font-weight: 900;
  color: var(--muted);
  min-height: 22px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.result-hi.new-record {
  color: var(--gauge-full);
  font-size: 18px;
  animation: scoreReveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ──────────────────────────────────────────────────────────────
   16. アニメーション一覧
────────────────────────────────────────────────────────────── */
@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -40px) scale(1.15); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes tileAppear {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes scoreReveal {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* 不正解時の横揺れ */
@keyframes shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-6px); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); }
}

/*
  ★ アニメーションを減らす設定への配慮 ★
  OS 側で「視差効果を減らす」を有効にしている利用者には、
  背景の光球やポップの動きが不快になることがあります。
  prefers-reduced-motion で動きをほぼ止めます。
*/
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ──────────────────────────────────────────────────────────────
   17. レスポンシブ
────────────────────────────────────────────────────────────── */

/* 画面高さ 640px 以下（古いスマートフォン）向けに各要素を縮小する */
@media (max-height: 640px) {
  .digit-tile   { font-size: 28px; border-radius: 14px; }
  .expr-display { min-height: 48px; font-size: 22px; }
  .op-btn       { font-size: 19px; border-radius: 12px; }
  .glass-card   { padding: 20px 18px; }
  .mode-sub     { display: none; }  /* 説明文を隠して縦幅を稼ぐ */
}
