/* ==========================================
   BONBON DROP - スタイルシート
   すべて .bonbon-game スコープに限定
   ========================================== */

.bonbon-game {
  --bb-bg: #d8c8f5;
  --bb-accent: #9966dd;
  --bb-accent2: #7755bb;
  --bb-text: #5a3a8a;
  --bb-dim: #c8b8e8;

  position: relative;
  width: 100%;
  max-width: 749px;
  margin-left: auto;
  margin-right: auto;
  margin-top: -16px;
  height: 936px;
  background: var(--bb-bg);
  background-image: radial-gradient(circle, rgba(160,120,220,0.25) 2px, transparent 2px);
  background-size: 26px 26px;
  overflow: hidden;
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', sans-serif;
  font-weight: 800;
  color: var(--bb-text);
  box-sizing: border-box;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  border-radius: 18px;
}

.bonbon-game::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 25%, rgba(255,255,255,0.45) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.bonbon-game .game-wrapper {
  display: flex;
  gap: 14px;
  align-items: stretch;
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  padding: 8px 10px;
  box-sizing: border-box;
}

.bonbon-game .canvas-col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  flex: 1;
  min-width: 0;
}
.bonbon-game .top-btns {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.bonbon-game .top-btns .reset-btn { flex: 1; }

.bonbon-game .canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 2px solid rgba(255,255,255,0.30);
  border-radius: 18px;
  box-shadow: 0 2px 0 rgba(255,255,255,0.18), 0 4px 20px rgba(100,70,180,0.20), inset 0 1px 0 rgba(255,255,255,0.35);
  overflow: hidden;
  background: #a088d8;
  display: flex;
  align-items: stretch;
}

.bonbon-game #gc {
  display: block;
  image-rendering: pixelated;
  width: 100%;
  height: 100%;
}

.bonbon-game .side {
  width: 173px;
  min-width: 173px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 100%;
}
.bonbon-game .side .box {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.bonbon-game .box {
  border: 2px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 6px 8px 8px;
  position: relative;
  border-radius: 18px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.60) inset,
    0 -2px 0 rgba(120,80,200,0.18) inset,
    2px 0 0 rgba(255,255,255,0.25) inset,
    -1px 0 0 rgba(120,80,200,0.10) inset,
    0 4px 0 rgba(100,60,180,0.22),
    0 6px 18px rgba(120,80,200,0.12);
  text-align: center;
  box-sizing: border-box;
}
.bonbon-game .box::after {
  content: '';
  position: absolute;
  top: 4px; left: 6px; right: 6px; height: 40%;
  border-radius: 12px 12px 50% 50%;
  background: rgba(255,255,255,0.28);
  pointer-events: none;
}

.bonbon-game #next-canvas {
  width: 100%;
  display: block;
  image-rendering: pixelated;
  margin-top: 4px;
  background: #a088d8;
  border-radius: 10px;
}

.bonbon-game .box.danger { animation: bb-dangerPulse .4s infinite alternate; }
@keyframes bb-dangerPulse {
  from { border-color: rgba(255,100,100,0.5); box-shadow: 0 4px 0 rgba(255,80,80,0.3); }
  to   { border-color: rgba(255,80,80,1);     box-shadow: 0 4px 0 rgba(255,80,80,0.6), 0 0 24px rgba(255,80,80,0.3); }
}

.bonbon-game #flash {
  position: absolute; inset: 0;
  background: rgba(255,240,200,0.55);
  opacity: 0; pointer-events: none; z-index: 5;
  transition: opacity .05s;
  border-radius: 14px;
}
.bonbon-game #flash.show { opacity: 1; }

/* ==========================================
   オーバーレイ
   ========================================== */
.bonbon-game .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: 10px 0;
  background: rgba(253,232,248,0.93);
  z-index: 10;
  backdrop-filter: blur(4px);
  border-radius: 14px;
  overflow: hidden;
  box-sizing: border-box;
  gap: 0;
}

/* タイトルキャンバスを高さ基準でスケール */
.bonbon-game #title-canvas {
  display: block !important;
  margin: 0 auto !important;
  max-width: 90% !important;
  max-height: 223px !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

.bonbon-game .go-title {
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', sans-serif;
  font-weight: 400;
  font-size: 60px;
  letter-spacing: .15em;
  padding-left: .15em;
  color: var(--bb-accent);
  text-shadow: 0 4px 0 rgba(255,120,180,0.4);
  text-align: center;
  line-height: 1.2;
  flex-shrink: 0;
}
.bonbon-game .go-block {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  flex-shrink: 0;
}
.bonbon-game .go-label {
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', sans-serif;
  font-weight: 400;
  font-size: 36px;
  letter-spacing: .1em;
  color: var(--bb-accent2);
  text-shadow: 0 3px 0 rgba(160,100,255,0.3);
}
.bonbon-game .go-score {
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', sans-serif;
  font-size: 70px;
  font-weight: 400;
  color: var(--bb-accent);
  text-shadow: 0 4px 0 rgba(255,120,180,0.4);
}

/* ==========================================
   ボタン
   ========================================== */
.bonbon-game .btn {
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', sans-serif;
  font-size: 20px;
  padding: 13px 43px;
  background: linear-gradient(135deg, #c099ff, #9966dd);
  border: 3px solid rgba(255,255,255,0.6);
  color: #fff;
  cursor: pointer;
  letter-spacing: .1em;
  border-radius: 50px;
  box-shadow: 0 5px 0 rgba(100,50,180,0.5), 0 8px 20px rgba(140,80,220,0.3);
  transition: all .2s;
  animation: bb-pulsebtn 1.6s ease-in-out infinite;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(80,30,150,0.4);
  outline: none;
  -webkit-appearance: none;
  flex-shrink: 0;
}
.bonbon-game .btn:hover,
.bonbon-game .btn:active {
  background: linear-gradient(135deg, #d0aaff, #aa77ee);
  box-shadow: 0 7px 0 rgba(100,50,180,0.5), 0 12px 24px rgba(140,80,220,0.4);
  transform: scale(1.05) translateY(-2px);
}
.bonbon-game .btn:focus-visible {
  outline: 4px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px rgba(180,120,255,0.7), 0 5px 0 rgba(100,50,180,0.5);
}
@keyframes bb-pulsebtn {
  0%,100% { box-shadow: 0 5px 0 rgba(100,50,180,0.5), 0 8px 16px rgba(140,80,220,0.25); }
  50%     { box-shadow: 0 5px 0 rgba(100,50,180,0.5), 0 10px 28px rgba(140,80,220,0.55); transform: translateY(-1px); }
}

.bonbon-game .bgm-btn {
  font-size: 20px;
  padding: 13px 31px;
}
.bonbon-game #start-btn {
  font-size: 28px;
  padding: 19px 72px;
}

.bonbon-game .bgm-btn.active {
  background: linear-gradient(135deg, #7744bb, #5522aa);
  box-shadow: 0 2px 0 rgba(40,10,100,0.6), inset 0 2px 6px rgba(0,0,0,0.25);
  transform: translateY(3px);
  border-color: rgba(255,255,255,0.35);
  color: #ffddff;
  animation: none;
}

/* ==========================================
   ラベル・値（固定px - vw不使用）
   ========================================== */
.bonbon-game .lbl {
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', sans-serif;
  font-weight: 400;
  font-size: 19px;
  letter-spacing: .1em;
  color: var(--bb-text);
  margin-bottom: 2px;
  white-space: nowrap;
  text-align: center;
}
.bonbon-game .val {
  font-family: 'Fredoka One', 'Arial Rounded MT Bold', sans-serif;
  font-weight: 400;
  font-size: 37px;
  color: var(--bb-accent);
  text-shadow: 0 2px 0 rgba(255,120,180,0.3);
  word-break: break-all;
  text-align: center;
  line-height: 1;
}
.bonbon-game .btn-icon {
  display: inline-block;
  transform: translateY(-2px);
  font-size: 0.75em;
}

/* ==========================================
   スタートガイド
   ========================================== */
.bonbon-game .start-guide {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 88%;
  align-self: center;
  flex-shrink: 0;
}
.bonbon-game .start-guide-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bonbon-game .guide-section {
  width: 100%;
}
.bonbon-game .guide-section--blackboard {
  background: linear-gradient(135deg, #c099ff, #9966dd);
  border: 3px solid rgba(255,255,255,0.6);
  border-radius: 14px;
  padding: 5px 12px 7px;
  box-shadow: 0 5px 0 rgba(100,50,180,0.5), 0 8px 20px rgba(140,80,220,0.3);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.bonbon-game .guide-section-title {
  font-family: 'Baloo 2', 'Arial Rounded MT Bold', sans-serif;
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  letter-spacing: .05em;
  text-shadow: 0 2px 6px rgba(140,60,200,0.35);
  margin-bottom: 3px;
  white-space: nowrap;
}
.bonbon-game .key-label {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(140,60,200,0.35);
  text-align: right;
  white-space: nowrap;
  line-height: 1.5;
}
.bonbon-game .key-colon {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(140,60,200,0.35);
  text-align: center;
  padding: 0 3px;
  line-height: 1.5;
}
.bonbon-game .key-action {
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  text-shadow: 0 2px 6px rgba(140,60,200,0.35);
  text-align: left;
  white-space: nowrap;
  line-height: 1.5;
}

/* ==========================================
   リセット・ポーズボタン
   ========================================== */
.bonbon-game .reset-btn {
  width: 100%;
  cursor: pointer;
  transition: all .2s;
  outline: none;
  -webkit-appearance: none;
}
.bonbon-game .reset-btn .lbl {
  font-size: 20px;
  letter-spacing: .1em;
  margin: 0;
}
.bonbon-game .reset-btn:hover,
.bonbon-game .reset-btn:active {
  background: rgba(255,255,255,0.30);
  transform: scale(1.04) translateY(-2px);
}

.bonbon-game .bgm-toggle-btn {
  width: 100%;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px;
  outline: none;
  -webkit-appearance: none;
}
.bonbon-game .bgm-toggle-btn:hover,
.bonbon-game .bgm-toggle-btn:active {
  transform: scale(1.04) translateY(-2px);
}
.bonbon-game #bgm-toggle-icon {
  color: var(--bb-accent);
  font-size: 24px;
}

/* ==========================================
   スマホ用（600px以下）
   ========================================== */
@media (max-width: 600px) {
  .bonbon-game {
    height: calc(100svh - 180px);
    max-height: calc(100svh - 180px);
    border-radius: 8px;
  }
  .bonbon-game .overlay {
    overflow-x: hidden;
    overflow-y: auto;
  }
  .bonbon-game #title-canvas {
    max-height: 120px !important;
  }
  .bonbon-game .game-wrapper { gap: 5px; padding: 4px 5px; }
  .bonbon-game .side { width: 72px; min-width: 72px; gap: 3px; }
  .bonbon-game .box { padding: 3px 3px 4px; }
  .bonbon-game .val { font-size: 20px; line-height: 1.1; }
  .bonbon-game .lbl { font-size: 9px; letter-spacing: .06em; margin-bottom: 1px; }
  .bonbon-game .go-title  { font-size: clamp(18px, 8vw, 32px); }
  .bonbon-game .go-label  { font-size: clamp(12px, 5vw, 20px); }
  .bonbon-game .go-score  { font-size: clamp(22px, 10vw, 46px); }
  .bonbon-game .btn       { font-size: 12px; padding: 10px 18px; }
  .bonbon-game .bgm-btn   { font-size: 11px; padding: 8px 14px; }
  .bonbon-game #start-btn { font-size: 15px; padding: 11px 40px; }
  .bonbon-game .reset-btn .lbl { font-size: 9px; }
  .bonbon-game .top-btns  { gap: 4px; }
  .bonbon-game .canvas-col { gap: 4px; }
  .bonbon-game .guide-section-title { font-size: 11px; }
  .bonbon-game .key-label,
  .bonbon-game .key-colon,
  .bonbon-game .key-action { font-size: 10px; }
  .bonbon-game .start-guide { gap: 4px; }
  .bonbon-game .guide-section--blackboard { padding: 4px 10px 5px; }
}