body {
  font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background-color: rgb(183, 203, 207);
  color: #333;
  max-width: 920px;
  margin: 0 auto;
  padding: 15px;
  text-align: center;
}
h1 {
  color: #2c3e50;
  margin: 5px 0 12px 0;
  font-size: 1.4rem;
}

/* --- スクロールしても上に固定されるエリア（Sticky） --- */
.sticky-header {
  position: sticky;
  top: 0;
  background-color: rgba(183, 203, 207, 0.95);
  backdrop-filter: blur(4px);
  padding: 8px 0;
  z-index: 100;
  box-shadow: 0 4px 6px -4px rgba(0,0,0,0.1);
}

/* 上段：左右2カラムのレイアウト */
.sticky-main-layout {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: stretch;
  max-width: 880px;
  margin: 0 auto 8px auto;
}
.left-pane {
  flex: 1.1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}
.right-pane {
  flex: 0.9;
  display: flex;
  flex-direction: column;
}

/* 難易度選択とシェアボタンを並べる行（プレイ中はすっと格納） */
.left-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  background: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  max-height: 60px;
  opacity: 1;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.25s ease,
              padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              margin 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* プレイ中の状態クラス */
.sticky-header.is-playing .left-bottom-row {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  pointer-events: none;
}

/* --- 「難易度選択」ラベルグループ --- */
.difficulty-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.difficulty-group-title {
  font-size: 0.82rem;
  font-weight: bold;
  color: #475569;
  white-space: nowrap;
}

/* --- スライドする下線付きの難易度選択 --- */
.difficulty-selector {
  position: relative;
  display: flex;
  justify-content: flex-start;
  gap: 14px;
}
.diff-label {
  position: relative;
  background: transparent;
  border: none;
  padding: 4px 2px 8px 2px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.85rem;
  color: #64748b;
  transition: color 0.2s;
  user-select: none;
  white-space: nowrap;
}
.diff-label input {
  display: none;
}
.diff-label:has(input:checked) {
  color: #061d21;
}
.diff-label:has(input:disabled) {
  opacity: 0.5;
  cursor: not-allowed;
}
.difficulty-selector::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background-color: #061d21;
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateX(var(--indicator-left, 0px));
  width: var(--indicator-width, 0px);
  opacity: var(--indicator-opacity, 0);
}

/* --- 経過時間 ＆ 総正解数ボックス（右カラム） --- */
.status-box {
  background: #fff;
  border-radius: 8px;
  padding: 18px 15px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  box-sizing: border-box;
  gap: 8px;
}
.timer-display {
  font-size: 2.2rem;
  font-weight: bold;
  color: #2c3e50;
  letter-spacing: 0.5px;
}
.timer-display span {
  color: #061d21;
}
.score-display {
  font-size: 1.1rem;
  font-weight: bold;
  color: #555;
}
.score-display span {
  color: #061d21;
}

/* --- 下段：操作カード（ボタン・入力フォーム） --- */
.controls-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px 15px;
  max-width: 880px;
  margin: 0 auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.action-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.input-form {
  display: flex;
  justify-content: center;
  gap: 8px;
}
input[type="text"] {
  width: 65%;
  max-width: 380px;
  padding: 8px 12px;
  font-size: 1rem;
  border: 2px solid #061d21;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}
input[type="text"]:disabled {
  background-color: #e9ecef;
  border-color: #cbd5e1;
}
button {
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #fff;
  background-color: #061d21;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}
button:hover:not(:disabled) { background-color: #0a383f; }
button.hint-btn { background-color: #d68910; }
button.hint-btn:hover:not(:disabled) { background-color: #b9770e; }
button.giveup { background-color: #c0392b; }
button.giveup:hover:not(:disabled) { background-color: #a93226; }
button.submit-btn { background-color: #061d21; }
button.submit-btn:hover:not(:disabled) { background-color: #0a383f; }
button:disabled { background-color: #bdc3c7; color: #7f8c8d; cursor: not-allowed; }

/* シェアボタン */
.share-btn {
  display: inline-block;
  background-color: #0f1419;
  color: #fff;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: 9999px;
  font-weight: bold;
  font-size: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: opacity 0.2s;
  white-space: nowrap;
}
.share-btn:hover { opacity: 0.85; }

/* --- ブルッと揺れるシェイクアニメーション --- */
@keyframes shake {
  0% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
  100% { transform: translateX(0); }
}
.shake {
  animation: shake 0.3s ease-in-out;
}

/* --- キャラクター＆吹き出しエリア --- */
.master-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0; /* これがポイント：親要素からはみ出したり押し出されるのを防ぎます */
}
.master-avatar {
  width: 58px;
  height: 58px;
  background: #fff;
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  flex-shrink: 0;
  overflow: hidden;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sticky-header.is-playing .master-avatar {
  width: 96px;
  height: 96px;
}
.master-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.speech-bubble {
  position: relative;
  background: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: bold;
  color: #2c3e50;
  
  /* 幅を固定・またはフレックスで均等にコントロールする設定 */
  flex: 1;
  width: 0; /* フレックスコンテナ内で安全に収まるように幅を制御 */
  box-sizing: border-box;
  
  text-align: left;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  line-height: 1.45;
  min-height: 95px;
  
  /* 中央寄せではなく上部に揃える、または改行に対応できるようにする */
  display: flex;
  align-items: center;
  
  /* 長い文字が来ても枠をはみ出さず、自然に折り返すようにする設定 */
  word-break: break-all;
  overflow-wrap: break-word;
  
  transition: min-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              font-size 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sticky-header.is-playing .speech-bubble {
  min-height: 80px;
  font-size: 0.98rem;
  padding: 14px 18px;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 8px 10px 8px 0;
  border-style: solid;
  border-color: transparent #fff transparent transparent;
  display: block;
  width: 0;
}

/* カウントダウンオーバーレイ */
#countdown-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 6rem;
  font-weight: bold;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* --- レアリティ別セクション & 進捗バー --- */
#board-container {
  margin-top: 20px;
}
.region-section {
  background: #fff;
  border-radius: 10px;
  padding: 15px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
  text-align: left;
}
.region-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #061d21;
  padding-bottom: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.region-title {
  font-size: 1.05rem;
  font-weight: bold;
  color: #2c3e50;
}
.region-counter {
  font-size: 0.85rem;
  color: #7f8c8d;
  font-weight: bold;
}
.progress-bar-container {
  width: 100%;
  height: 10px;
  background-color: #ffffff;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 6px,
    rgba(0, 0, 0, 0.04) 6px,
    rgba(0, 0, 0, 0.04) 12px
  );
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  margin-bottom: 12px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background-color: rgb(6, 29, 33);
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  gap: 8px;
}
.card {
  background: #f8f9fa;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px 6px;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  transition: all 0.2s;
  color: #64748b;
  font-weight: bold;
  font-size: 0.9rem;
  text-align: center;
  word-break: break-all;
}
.card.solved {
  background-color: #e2f0d9;
  border-color: #28a745;
  color: #155724;
}
.card.missed {
  background-color: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}

/* --- フッター (120pxの黒帯・上右寄せ・白文字) --- */
.site-footer {
  height: 120px;
  background-color: #000;
  color: #fff;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  padding: 15px 25px;
  box-sizing: border-box;
  font-size: 0.9rem;
  font-weight: bold;
  margin-top: 30px;
  border-radius: 8px;
}

/* スマホ表示時の縦並び調整 */
@media (max-width: 768px) {
  .sticky-main-layout {
    flex-direction: column;
    align-items: stretch;
  }
  .left-bottom-row {
    flex-direction: column;
    gap: 8px;
    max-height: 100px;
  }
  .sticky-header.is-playing .master-avatar {
    width: 76px;
    height: 76px;
  }
  .sticky-header.is-playing .speech-bubble {
    min-height: 64px;
  }
}

#fireworks-canvas {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* 下にあるボタンや要素をクリックできるようにする */
  z-index: 999;
}


/* --- クイズカード（未回答時の2段表示対応） --- */
.card {
  /* 既存のプロパティはそのまま活かしつつ以下を追加・調整 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  box-sizing: border-box;
}

/* 未回答時の日本語職業名（大きく） */
.card-job-ja {
  font-size: 0.95rem;
  font-weight: bold;
  color: #b6babd;
  line-height: 1.2;
}

/* 未回答時の英語職分名（一段薄いグレーで小さく） */
.card-job-en {
  font-size: 0.68rem;
  font-weight: 600;
  color: #d3dfdf;
  letter-spacing: 0.03em;
  line-height: 1;
}

/* 正解時（solved）やギブアップ時（missed）は通常通り1行で表示する */
.card.solved,
.card.missed {
  flex-direction: row;
  font-size: 0.9rem;
  font-weight: bold;
}
