/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic Pro', 'Yu Gothic', sans-serif;
  background: #1a2530;
  color: #fff;
  overflow: hidden;
  height: 100vh;
  user-select: none;
  -webkit-user-select: none;
}

/* ===== 画面切替 ===== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active {
  display: flex;
}

/* ===== ボタン共通 ===== */
.btn-primary {
  display: inline-block;
  padding: 16px 48px;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: inherit;
  background: #F1C40F;
  color: #2C3E50;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.btn-secondary {
  display: inline-block;
  padding: 12px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  background: transparent;
  color: #FFF8E1;
  border: 2px solid #FFF8E1;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.btn-secondary:active {
  transform: scale(0.96);
}

/* ===== タイトル画面 ===== */
#screen-title {
  /* position: fixed は .screen から継承 — ここに position: relative を書かない */
  background: linear-gradient(150deg, #6B0000 0%, #C0392B 50%, #6B0000 100%);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#screen-title::-webkit-scrollbar { display: none; }

/* 背景画像: position fixed で、スクロールしても常にビューポートを覆う */
#title-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  z-index: 0;
  pointer-events: none;
}

/* 暗いオーバーレイ: 同じく fixed */
#title-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1;
  pointer-events: none;
}

/* コンテンツ全体 */
.title-content {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 28px 56px;
}

.title-header {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 56px;
  margin-bottom: 8px;
}

.font-title {
  font-size: 2.6rem;
  font-weight: 900;
  line-height: 1.2;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.9);
  margin: 0 0 10px;
}

.font-stick { font-family: 'Stick', sans-serif; }

.subtitle {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.1em;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
  margin: 8px 0 20px;
}

/* スライダー+ボタンのまとめ */
.title-bottom {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* スライダーグループ */
.slider-group {
  width: 100%;
}

.slider-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.slider-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.05em;
}

.slider-val {
  font-size: 1.7rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  min-width: 72px;
  text-align: right;
}

/* レンジスライダー本体 */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M14,5 C9,2 2,8 2,15 C2,22 8,28 15,28 C22,28 28,22 28,15 C28,8 21,2 16,5 Q15,3 14,5 Z' fill='%23FFB3C1'/%3E%3Cpath d='M15,3.5 C14.3,5 14,8 15,11 C16,8 15.7,5 15,3.5 Z' fill='%23E8809A'/%3E%3Cpath d='M15,4.5 C18,-0.5 25,1 22,7 C19,4 15,4.5 15,4.5 Z' fill='%2356A847'/%3E%3C/svg%3E") center/contain no-repeat;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 38px;
  height: 38px;
  border-radius: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath d='M14,5 C9,2 2,8 2,15 C2,22 8,28 15,28 C22,28 28,22 28,15 C28,8 21,2 16,5 Q15,3 14,5 Z' fill='%23FFB3C1'/%3E%3Cpath d='M15,3.5 C14.3,5 14,8 15,11 C16,8 15.7,5 15,3.5 Z' fill='%23E8809A'/%3E%3Cpath d='M15,4.5 C18,-0.5 25,1 22,7 C19,4 15,4.5 15,4.5 Z' fill='%2356A847'/%3E%3C/svg%3E") center/contain no-repeat;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* トグルスイッチ */
.toggle-group {
  width: 100%;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  padding: 6px 0;
  -webkit-tap-highlight-color: transparent;
}

.toggle-text {
  font-size: 0.9rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.05em;
}

#gap-toggle {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 52px;
  height: 30px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

#gap-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  transition: transform 0.2s, background 0.2s;
}

#gap-toggle:checked {
  background: #27AE60;
  border-color: #27AE60;
}

#gap-toggle:checked::after {
  transform: translateX(22px);
  background: #fff;
}

/* スタートボタン */
#btn-start {
  width: 100%;
  padding: 18px;
  font-size: 1.4rem;
  font-weight: 900;
  font-family: inherit;
  background: #27AE60;
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(39, 174, 96, 0.7);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.15em;
}

#btn-start:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(39, 174, 96, 0.5);
}

/* ===== ゲーム画面 ===== */
#screen-game {
  align-items: center;
  background: #1a2530;
}

#game-container {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #2C3E50;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

/* HUD */
#hud {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  position: relative;
  z-index: 21;
}

#score-area {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

#score-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: #F1C40F;
  min-width: 56px;
  text-align: right;
}

.score-unit {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

#combo-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #3498DB;
}

/* 中断ボタン(全モード常時表示) */
#btn-stop {
  display: inline-block;
  padding: 4px 14px;
  font-size: 0.8rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
#btn-stop:active {
  background: rgba(255, 255, 255, 0.3);
}

/* レーン */
#lanes-wrapper {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 3px;
  padding: 0 3px;
}

.lane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px 4px 0 0;
  transition: background-color 0.15s;
}

.lane.lane-flash {
  background: rgba(241, 196, 15, 0.25);
}

.lane-header {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px 4px 0 0;
  flex-shrink: 0;
  letter-spacing: 0.1em;
}

.notes-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* 判定ライン */
#judgment-line-row {
  height: 6px;
  display: flex;
  gap: 3px;
  padding: 0 3px;
  flex-shrink: 0;
}

.jbar {
  flex: 1;
  background: #F1C40F;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(241, 196, 15, 0.6);
}

/* タップ域 */
#tap-row {
  height: 100px;
  display: flex;
  gap: 3px;
  padding: 3px 3px 0;
  flex-shrink: 0;
}

.tap-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.08s;
}

.tap-zone:active {
  background: rgba(241, 196, 15, 0.2);
}

.key-label {
  font-size: 1.8rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.25);
}

/* タッチラベルはデフォルト非表示、タッチデバイスのみ表示 */
.key-touch { display: none; }

@media (hover: none) and (pointer: coarse) {
  .key-pc    { display: none; }
  .key-touch { display: block; font-size: 1.3rem; }
}

/* 判定テキスト(固定表示を廃止 — フローティング judge-popup に置換) */
#judgment-text {
  display: none;
}

.judgment-good { color: #F1C40F; }
.judgment-ok   { color: #3498DB; }
.judgment-miss { color: #E74C3C; }
#judgment-text.judgment-miss { font-size: 1.8rem; }

/* 口唱歌ガイド (Phase 3 で内容を追加) */
#kana-guide {
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(0, 0, 0, 0.25);
}

/* ===== ノーツ ===== */
.note {
  position: absolute;
  left: 50%;
  top: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.note-big {
  width: 70px;
  height: 70px;
  background: radial-gradient(circle at 35% 35%, #FF7675, #C0392B);
  border: 3px solid #FFAAAA;
  font-size: 1.1rem;
  box-shadow: 0 2px 16px rgba(192, 57, 43, 0.8);
}

.note-small {
  width: 35px;
  height: 35px;
  background: radial-gradient(circle at 35% 35%, #E74C3C, #922B21);
  border: 2px solid #E74C3C;
  font-size: 0.7rem;
  box-shadow: 0 1px 6px rgba(146, 43, 33, 0.5);
}

.note-separator {
  width: 100%;
  height: 3px;
  border-radius: 0;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  box-shadow: none;
  font-size: 0;
}

/* ===== リザルト画面 ===== */
#screen-result {
  align-items: center;
  justify-content: center;
  background: #0a0a1f;
}

#result-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  z-index: 0;
}

#result-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.result-inner {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
}

#result-rating {
  font-size: 2.2rem;
  font-weight: 900;
  color: #F1C40F;
  margin-bottom: 24px;
  text-shadow: 0 2px 8px rgba(241, 196, 15, 0.4);
}

.result-stats {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 16px;
  margin-bottom: 24px;
  text-align: left;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.95rem;
}

.stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.credit {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.35);
}
.credit a {
  color: rgba(255, 255, 255, 0.45);
  text-decoration: underline;
}

/* ===== 桃 装飾 + コンボ演出 ===== */
#deco-peach {
  position: absolute;
  top: 82px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  pointer-events: none;
  z-index: 2;
}

#deco-peach-img {
  width: 100px;
  height: 100px;
  display: block;
}

#combo-text {
  position: absolute;
  top: 55%;
  left: 50%;
  z-index: 1;
  font-size: 2.5rem;
  font-weight: 900;
  color: #FFD700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  font-family: inherit;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000;
}

@keyframes combo-text-full {
  0%   { opacity: 1; transform: translateX(-50%) scale(0);   }
  9%   {              transform: translateX(-50%) scale(1.2); }
  15%  { opacity: 1;  transform: translateX(-50%) scale(1.0); }
  89%  { opacity: 1;  transform: translateX(-50%) scale(1.0); }
  100% { opacity: 0;  transform: translateX(-50%) scale(1.0); }
}

.combo-text-playing {
  animation: combo-text-full 2.7s ease-out forwards;
}

@media (max-width: 480px) {
  .result-buttons {
    flex-direction: column;
    align-items: center;
  }
}

/* ===== タップ待ちオーバーレイ ===== */
#start-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

#start-overlay-text {
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  animation: pulse-text 1.2s ease-in-out infinite;
  pointer-events: none;
}

/* ===== 判定テキスト フロートポップアップ ===== */
@keyframes judge-float {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0px); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-30px); }
}

.judge-popup {
  position: absolute;
  z-index: 15;
  font-size: 1.75rem;
  font-weight: 900;
  pointer-events: none;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  animation: judge-float 0.5s ease-out forwards;
}

/* ===== パーティクル(良判定) ===== */
@keyframes particle-burst {
  0%   { opacity: 1; transform: translate(0, 0) scale(1.2); }
  100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(0.2); }
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 10;
  animation: particle-burst 0.4s ease-out forwards;
}
