/* 3sec — 音程チャレンジ / styles.css
   モバイルファースト（390px基準・縦持ち前提）。外部リソース参照なし・システムフォントのみ。 */

:root {
  color-scheme: dark;

  --bg: #0b0d13;
  --bg-2: #11151f;
  --panel: #161b26;
  --panel-2: #1c2230;
  --line: #2a3244;

  --text: #e9edf6;
  --muted: #8e99ae;

  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --good: #34d399;
  --mid: #fbbf24;
  --bad: #f87171;

  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN",
               "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(120% 60% at 50% 0%, #16203a 0%, rgba(11, 13, 19, 0) 60%),
    var(--bg);
  min-height: 100vh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- ヘッダー */
.app-header { padding: 6px 0 10px; }

.brand {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.brand-main {
  font-weight: 800;
  background: linear-gradient(100deg, var(--accent-2), #b8c9ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---------------------------------------------------------------- 画面切替 */
.screen { display: none; flex: 1 1 auto; }
.screen.is-active { display: block; }
/* プレイ中は「やめる」を画面下端に寄せる（親指の届く位置・誤タップ回避） */
#screen-play.is-active { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- 共通部品 */
.lede {
  margin: 6px 0 16px;
  font-size: 0.95rem;
  color: #c9d2e4;
}
.lede strong { color: var(--text); }

.section-h {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 22px 0 8px;
}

.btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(:disabled) { background: var(--panel-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(180deg, #3f6ff0, #3157cf);
  border-color: #4d7bff;
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #4d7bff, #3a63e0); }

.btn-title { display: block; font-size: 1.05rem; font-weight: 700; }
.btn-sub { display: block; font-size: 0.78rem; opacity: .82; margin-top: 1px; }

.btn-sm {
  display: inline-block;
  width: auto;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--panel); color: var(--text); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row .btn { flex: 1 1 auto; }

.modes { display: flex; flex-direction: column; gap: 4px; }
.mode-note {
  margin: 2px 2px 12px;
  font-size: 0.78rem;
  color: var(--muted);
}
.linkish {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-2);
  font: inherit;
  font-size: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid var(--bad);
  border-radius: var(--radius-sm);
  background: rgba(248, 113, 113, .12);
  color: #ffc9c9;
  font-size: 0.85rem;
}

.howto {
  margin: 0;
  padding-left: 1.25em;
  font-size: 0.88rem;
  color: #c3ccdd;
}
.howto li { margin-bottom: 4px; }
.howto b { color: var(--text); }

.callout {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  font-size: 0.83rem;
  color: #c3ccdd;
}
.callout b { color: var(--text); }
.callout.privacy { border-color: #2c5c46; background: rgba(52, 211, 153, .08); }

.faq { margin-top: 22px; }
.faq > summary {
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 10px 0;
  color: var(--text);
}
.faq dl { margin: 0; font-size: 0.83rem; }
.faq dt { font-weight: 700; margin-top: 12px; color: var(--text); }
.faq dd { margin: 2px 0 0; color: var(--muted); }
.faq dd b { color: #c3ccdd; }

/* ---------------------------------------------------------------- HUD */
.hud {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.hud-item { display: flex; flex-direction: column; align-items: center; flex: 1 1 0; min-width: 0; }
.hud-label {
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}
.hud-value { font-size: 1.15rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hud-lives { color: var(--bad); letter-spacing: 1px; }

/* ---------------------------------------------------------------- ステージ */
.stage {
  margin-top: 16px;
  padding: 14px 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  text-align: center;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 1.9em;
}

.phase-icon {
  font-size: 1.5rem;
  line-height: 1;
}
#screen-play[data-phase="sing"] .phase-icon { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.16); opacity: .78; }
}
@media (prefers-reduced-motion: reduce) {
  #screen-play[data-phase="sing"] .phase-icon { animation: none; }
}

.phase-label { font-size: 1.15rem; font-weight: 800; }
#screen-play[data-phase="listen"] .phase-label { color: var(--accent-2); }
#screen-play[data-phase="sing"] .phase-label { color: var(--good); }

/* ------------------------------------------------------------ 音程バーレーン */
.lane-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #0a0d14;
  margin-bottom: 12px;
}
#screen-play[data-phase="sing"] .lane-wrap { border-color: #2c6b52; }
.lane {
  display: block;
  width: 100%;
  height: 190px;
}
@media (max-height: 700px) {
  .lane { height: 158px; }
}

.meter {
  height: 8px;
  border-radius: 99px;
  background: #0a0d14;
  overflow: hidden;
  border: 1px solid var(--line);
}
.meter-bar {
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}
#screen-play[data-phase="sing"] .meter-bar { background: linear-gradient(90deg, #10b981, var(--good)); }

.phase-hint {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.4em;
}

.round-feedback {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
}
.round-feedback.fb-good { border-color: #2c6b52; background: rgba(52, 211, 153, .10); }
.round-feedback.fb-mid  { border-color: #6d5a20; background: rgba(251, 191, 36, .10); }
.round-feedback.fb-bad  { border-color: #6d3232; background: rgba(248, 113, 113, .10); }
.round-feedback.fb-nodetect { border-color: var(--line); background: var(--panel); }
.fb-big { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.fb-good .fb-big { color: var(--good); }
.fb-mid .fb-big { color: var(--mid); }
.fb-bad .fb-big { color: var(--bad); }
.fb-sub { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.play-foot { margin-top: auto; padding-top: 20px; text-align: center; }
.mic-note { font-size: 0.72rem; color: var(--muted); margin: 0 0 10px; }

/* ---------------------------------------------------------------- 結果画面 */
.result-title { font-size: 1.05rem; margin: 6px 0 4px; }

.total { text-align: center; margin: 6px 0 2px; }
.total-num {
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(100deg, var(--accent-2), #c7d6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.total-unit { font-size: 1rem; font-weight: 700; color: var(--muted); margin-left: 4px; }

.emoji-row {
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 2px;
  line-height: 1.5;
  word-break: break-all;
  min-height: 1.5em;
}
#result-extra { text-align: center; }

.round-cards { display: flex; flex-direction: column; gap: 8px; }

.round-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.rc-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
}
.rc-round { font-size: 0.8rem; font-weight: 800; color: var(--accent-2); }
.rc-meta { font-size: 0.72rem; color: var(--muted); }
.rc-score {
  margin-left: auto;
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.rc-score-unit { font-size: 0.68rem; font-weight: 600; color: var(--muted); margin-left: 2px; }

.rc-notes { list-style: none; margin: 0; padding: 0; }
.rc-note {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  border-bottom: 1px solid rgba(42, 50, 68, .55);
}
.rc-note:last-child { border-bottom: none; }
.rn-name { min-width: 3.4em; font-weight: 700; }
.rn-cents { color: var(--muted); }
.rn-score { margin-left: auto; font-weight: 800; }
.rc-note.is-good .rn-cents, .rc-note.is-good .rn-score { color: var(--good); }
.rc-note.is-mid  .rn-cents, .rc-note.is-mid  .rn-score { color: var(--mid); }
.rc-note.is-bad  .rn-cents, .rc-note.is-bad  .rn-score { color: var(--bad); }
.rc-note.is-silent { opacity: .72; }
.rc-note.is-silent .rn-cents { font-size: 0.74rem; }

.fineprint { font-size: 0.72rem; color: var(--muted); margin: 8px 2px 0; }

.share-text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  resize: vertical;
}
.copied-flag {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: var(--good);
  text-align: center;
}

/* ---------------------------------------------------------------- フッター */
.app-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.72rem;
  color: #a8b3c7;
}
.app-footer p { margin: 2px 0; }
.app-footer .muted { color: var(--muted); }

/* 幅の広い画面ではやや余裕を持たせる（レイアウトはモバイル基準のまま） */
@media (min-width: 520px) {
  .brand { font-size: 1.7rem; }
  .stage { padding: 18px 16px 20px; }
  .lane { height: 220px; }
}
