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

body {
  font-family: -apple-system, 'Helvetica Neue', sans-serif;
  background: #f0e6f6;
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100dvh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ── ステージ選択画面 ── */
#stage-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
  height: 100dvh;
  background: #fdf8ff;
  padding: 48px 24px 32px;
  gap: 20px;
  overflow-y: auto;
}

#game-title {
  font-size: 24px;
  font-weight: 800;
  color: #6d28d9;
  letter-spacing: 0.04em;
}

/* ── タブ ── */
#tab-bar {
  display: flex;
  width: 100%;
  background: #ede9fe;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}

.tab {
  flex: 1;
  padding: 8px 0;
  border: none;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: none;
  color: #7c3aed;
  letter-spacing: 0.05em;
  transition: background 0.15s, color 0.15s;
}

.tab.active {
  background: #fff;
  color: #4c1d95;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.tab[data-tab="hard"] {
  color: #dc2626;
}

.tab[data-tab="hard"].active {
  color: #991b1b;
}

/* ── タブパネル ── */
.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.hard-locked-msg {
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
  padding: 32px 0;
  line-height: 1.8;
}

#stage-list-normal,
#stage-list-hard {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.stage-card {
  width: 100%;
  padding: 16px 20px;
  border-radius: 16px;
  border: 2px solid #d8b4fe;
  background: #fff;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: background 0.15s, transform 0.1s;
}

.stage-card:hover {
  background: #f3e8ff;
}

.stage-card:active {
  transform: scale(0.98);
}

.stage-card.locked {
  border-color: #e5e7eb;
  background: #f9fafb;
  cursor: default;
  opacity: 0.6;
}

.stage-card.locked:hover {
  background: #f9fafb;
}

.stage-num {
  font-size: 11px;
  font-weight: 700;
  color: #a78bfa;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.stage-card.locked .stage-num {
  color: #9ca3af;
}

.stage-title {
  font-size: 15px;
  font-weight: 600;
  color: #4c1d95;
}

.stage-card.locked .stage-title {
  color: #9ca3af;
  font-size: 20px;
}

/* ── ハードモード（ステージ選択） ── */
.stage-card.hard {
  border-color: #fca5a5;
  background: #fff7f7;
}

.stage-card.hard:hover {
  background: #fee2e2;
}

.stage-card.hard .stage-num {
  color: #ef4444;
}

.stage-card.hard .stage-title {
  color: #991b1b;
}

.stage-card.hard.locked {
  border-color: #e5e7eb;
  background: #f9fafb;
}

/* ── ハードモード（ゲーム画面） ── */
#app.hard #header {
  background: #fff7f7;
  border-bottom-color: #fecaca;
}

#app.hard #gauge-label {
  color: #ef4444;
}

#app.hard #gauge-track {
  background: #fecaca;
}

#app.hard #gauge-value {
  color: #dc2626;
}

#app.hard #choices {
  border-top-color: #fecaca;
  background: #fff7f7;
}

#app.hard #choices button {
  border-color: #fca5a5;
  color: #991b1b;
}

#app.hard #choices button:hover {
  background: #fee2e2;
}

#reset-btn {
  margin-top: auto;
  padding: 10px 24px;
  background: none;
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  font-size: 13px;
  color: #9ca3af;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

#reset-btn:hover {
  border-color: #f87171;
  color: #ef4444;
}

/* ── アプリ外枠 ── */
#app {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 420px;
  height: 100dvh;
  background: #fdf8ff;
}

/* ── ヘッダー（ゲージ） ── */
#header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e8d8f0;
  position: sticky;
  top: 0;
  z-index: 10;
}

#home-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

#home-btn:hover {
  opacity: 1;
}

#gauge-label {
  font-size: 12px;
  color: #a070c0;
  white-space: nowrap;
  font-weight: 600;
}

#gauge-track {
  flex: 1;
  height: 10px;
  background: #ead8f5;
  border-radius: 5px;
  overflow: hidden;
}

#gauge-fill {
  height: 100%;
  width: 50%;
  border-radius: 5px;
  background: linear-gradient(to right, #f87171, #fbbf24, #34d399);
  transition: width 0.4s ease, background-color 0.4s ease;
}

#gauge-value {
  font-size: 13px;
  font-weight: 700;
  color: #7c3aed;
  min-width: 28px;
  text-align: right;
}

/* ── チャットエリア ── */
#chat {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}

/* ── 日付区切り ── */
.date-separator {
  align-self: center;
  font-size: 11px;
  color: #999;
  background: rgba(200, 180, 220, 0.25);
  border-radius: 999px;
  padding: 3px 12px;
  margin: 4px 0;
}

/* ── 吹き出し共通 ── */
.bubble {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-all;
  animation: pop-in 0.18s ease;
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

/* 左吹き出し（彼女） */
.bubble.left {
  align-self: flex-start;
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* 右吹き出し（自分） */
.bubble.right {
  align-self: flex-end;
  background: #c084fc;
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}

/* ── 選択肢エリア ── */
#choices {
  padding: 10px 12px 20px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fdf8ff;
  border-top: 1px solid #e8d8f0;
}

#choices button {
  width: 100%;
  padding: 12px 16px;
  background: #fff;
  border: 1.5px solid #d8b4fe;
  border-radius: 12px;
  font-size: 13px;
  color: #5b21b6;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, transform 0.1s;
  line-height: 1.4;
}

#choices button:hover {
  background: #f3e8ff;
}

#choices button:active {
  transform: scale(0.98);
  background: #ede9fe;
}

/* ── 結果画面 ── */
#result-screen {
  position: fixed;
  inset: 0;
  background: rgba(120, 60, 180, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#result-screen.hidden {
  display: none;
}

#result-card {
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  animation: pop-in 0.25s ease;
}

#result-emoji {
  font-size: 64px;
  margin-bottom: 16px;
}

#result-text {
  font-size: 18px;
  font-weight: 700;
  color: #4c1d95;
  margin-bottom: 28px;
  line-height: 1.5;
  white-space: pre-line;
}

#result-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

#restart-btn,
#to-select-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#restart-btn {
  background: #c084fc;
  color: #fff;
}

#restart-btn:hover {
  background: #a855f7;
}

#to-select-btn {
  background: #ede9fe;
  color: #6d28d9;
}

#to-select-btn:hover {
  background: #ddd6fe;
}
