* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #c8a97a;
  display: flex;
  justify-content: center;
  align-items: center;          /* 縦中央寄せ */
  min-height: 100vh;
  min-height: 100dvh;           /* iOS Safari の動的ビューポート高さ対応 */
  font-family: 'Segoe UI', sans-serif;
  /* iPhone ノッチ・ホームバー対応のセーフエリア余白 */
  padding: max(10px, env(safe-area-inset-top))
           max(10px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom))
           max(10px, env(safe-area-inset-left));
  /* ダブルタップ拡大・ピンチズームをブラウザレベルで抑止 */
  touch-action: manipulation;
  overscroll-behavior: none;
}

.hidden { display: none !important; }

/* ============ タイトル画面 ============ */
#title-screen {
  position: fixed;
  inset: 0;
  background: #c8a97a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#title-inner {
  text-align: center;
  padding: 24px 20px;
  max-width: 380px;
  width: 100%;
}

#title-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 6px;
}

.title-word {
  display: block;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 6px;
  background: linear-gradient(160deg, #fff6e0 0%, #ffe4b5 40%, #ffcba4 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 6px rgba(120,60,0,0.35));
  text-transform: uppercase;
}

.title-word:not(.jp) {
  font-size: 52px;
  letter-spacing: 10px;
}

.title-word.jp {
  font-size: 22px;
  letter-spacing: 8px;
  opacity: 0.85;
}

#title-sub {
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  margin-bottom: 16px;
  letter-spacing: 1px;
}

#title-flowers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: 20px;
  min-height: 70px;
}

#title-flowers img {
  object-fit: contain;
  flex-shrink: 0;
}

#title-start-btn {
  display: block;
  width: 100%;
  max-width: 220px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, #d4843a, #b86020);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 15px 0;
  font-size: 19px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(180,100,32,0.4);
  letter-spacing: 2px;
  transition: transform 0.12s, box-shadow 0.12s;
}

#title-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(180,100,32,0.5);
}

#title-start-btn:active { transform: translateY(0); }

#title-best {
  color: rgba(255,255,255,0.75);
  font-size: 13px;
}

/* ============ ゲーム画面 ============ */
#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 400px;
}

#hud {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

/* 高さ揃え：全バブル共通 */
.bubble {
  background: rgba(255,255,255,0.55);
  border-radius: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  min-width: 66px;
  height: 54px;
}

.bubble label {
  font-size: 10px;
  color: #7a5c2e;
  font-weight: bold;
}

.bubble span {
  font-size: 17px;
  font-weight: bold;
  color: #4a3200;
}

/* ネクスト花：白背景なし・高さ揃え */
.next-bubble {
  padding: 5px 10px;
  height: 54px;
}

.next-bubble img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

/* HUDボタン：太字・目立つ */
.hud-btn {
  background: rgba(255,255,255,0.55);
  border: none;
  border-radius: 50%;
  width: 54px;
  height: 54px;
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #5a3e10;
  flex-shrink: 0;
}

.hud-btn:hover { background: rgba(255,255,255,0.8); }

/* ポーズアイコン：縦棒2本 */
.pause-icon {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: center;
}

.pause-icon span {
  display: block;
  width: 4px;
  height: 16px;
  background: #5a3e10;
  border-radius: 2px;
}

#canvas-container {
  position: relative;
  width: 100%;
}

#gameCanvas {
  display: block;
  width: 100%;
  border: 4px solid rgba(180,140,80,0.8);
  border-radius: 4px;
  background: rgba(255,255,240,0.85);
  cursor: crosshair;
  touch-action: none; /* canvas上はJSでタッチを完全管理 */
}

/* ============ ゲームオーバー ============ */
#gameover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(100,60,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#gameover-modal {
  background: #fff8ec;
  border-radius: 24px;
  padding: 32px 36px 28px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  min-width: 260px;
}

#gameover-modal h2 {
  color: #b86020;
  font-size: 24px;
  margin-bottom: 12px;
}

#gameover-score {
  font-size: 20px;
  font-weight: bold;
  color: #4a3200;
  margin-bottom: 4px;
}

.modal-sub {
  color: #a07840;
  font-size: 13px;
  margin-bottom: 24px;
}

/* ============ ヘルプモーダル ============ */
#help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(100,60,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#help-modal {
  background: #fff8ec;
  border-radius: 24px;
  padding: 26px 22px 22px;
  width: 90%;
  max-width: 340px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.help-title {
  text-align: center;
  color: #b86020;
  font-size: 19px;
  margin-bottom: 14px;
  font-weight: 900;
  letter-spacing: 2px;
}

.help-content { display: flex; flex-direction: column; gap: 10px; }

.help-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(200,169,122,0.15);
  border-radius: 14px;
  padding: 10px 13px;
}

.help-icon { font-size: 22px; flex-shrink: 0; }
.help-item strong { color: #b86020; font-size: 13px; }
.help-item div { font-size: 12px; color: #5a3d10; line-height: 1.6; }

#help-flowers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 3px;
  padding: 10px 0 4px;
}

#help-flowers img {
  object-fit: contain;
  flex-shrink: 0;
}

.help-note {
  text-align: center;
  font-size: 11px;
  color: #b89060;
  margin-top: 2px;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(200,169,122,0.3);
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 13px;
  cursor: pointer;
  color: #7a5c2e;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover { background: rgba(200,169,122,0.55); }

/* ============ ポーズモーダル ============ */
#pause-overlay {
  position: fixed;
  inset: 0;
  background: rgba(100,60,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#pause-modal {
  background: #fff8ec;
  border-radius: 24px;
  padding: 24px 28px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  min-width: 250px;
}

.volume-section {
  background: rgba(200,169,122,0.2);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vol-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.vol-label {
  font-size: 13px;
  font-weight: bold;
  color: #7a5c2e;
  white-space: nowrap;
  width: 62px;
  flex-shrink: 0;
}

.vol-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

/* ＋／－ ボタン */
.vol-step-btn {
  background: rgba(200,169,122,0.35);
  border: none;
  border-radius: 8px;
  width: 26px;
  height: 26px;
  font-size: 15px;
  font-weight: bold;
  color: #7a5c2e;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.1s;
  user-select: none;
}

.vol-step-btn:hover  { background: rgba(200,169,122,0.6); }
.vol-step-btn:active { background: rgba(200,169,122,0.85); }

/* スライダー */
.vol-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(200,169,122,0.4);
  outline: none;
  cursor: pointer;
}

.vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f0a060, #d4843a);
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(180,100,32,0.45);
  transition: transform 0.1s;
}

.vol-slider::-webkit-slider-thumb:hover  { transform: scale(1.15); }
.vol-slider::-webkit-slider-thumb:active { transform: scale(1.05); }

.vol-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: radial-gradient(circle at 35% 35%, #f0a060, #d4843a);
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(180,100,32,0.45);
}

/* ============ ボタン共通 ============ */
.modal-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.modal-btns.vertical {
  flex-direction: column;
  align-items: stretch;
}

.btn-primary {
  background: linear-gradient(135deg, #d4843a, #b86020);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(180,100,32,0.3);
  transition: transform 0.1s;
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-secondary {
  background: rgba(200,169,122,0.25);
  color: #7a5c2e;
  border: none;
  border-radius: 50px;
  padding: 11px 24px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.1s;
}

.btn-secondary:hover { background: rgba(200,169,122,0.45); }
