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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background: #7494c0;
  height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ========== 画面切り替え ========== */
.screen {
  display: none;
  width: 100%;
  max-width: 420px;
  height: 100dvh;
  max-height: 780px;
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.screen.active {
  display: flex;
  flex-direction: column;
}

/* ========== スタート画面 ========== */
#start-screen {
  background: linear-gradient(135deg, #06c755 0%, #04a847 100%);
  justify-content: center;
  align-items: center;
}

.start-content {
  text-align: center;
  color: #fff;
}

.start-logo {
  font-size: 80px;
  font-weight: 900;
  letter-spacing: 8px;
  margin-bottom: 8px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.start-sub {
  font-size: 16px;
  opacity: 0.9;
  margin-bottom: 48px;
}

.start-button {
  background: #fff;
  color: #06c755;
  border: none;
  padding: 16px 48px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.start-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.start-button:active {
  transform: scale(0.98);
}

/* ========== チャット画面 ========== */
#chat-screen {
  background: #8cabd9;
}

.chat-header {
  background: #06c755;
  color: #fff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-arrow {
  font-size: 20px;
  font-weight: 700;
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
}

.header-name {
  font-size: 17px;
  font-weight: 600;
}

.end-button {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.end-button:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* ========== イライラゲージ ========== */
.gauge-container {
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.gauge-label {
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.gauge-bar {
  flex: 1;
  height: 14px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 7px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffeb3b, #ff9800, #f44336);
  border-radius: 7px;
  transition: width 0.5s ease;
}

.gauge-text {
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 60px;
  text-align: right;
}

/* ========== チャットメッセージ ========== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: messageIn 0.3s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-row.user {
  justify-content: flex-end;
}

.message-row.bot {
  justify-content: flex-start;
}

.bot-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #06c755;
  flex-shrink: 0;
}

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

.message-row.user .message-bubble {
  background: #06c755;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message-row.bot .message-bubble {
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
}

/* 既読 */
.read-indicator {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
  margin-right: 4px;
  white-space: nowrap;
  align-self: flex-end;
}

/* 既読スルー通知 */
.read-notice {
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  padding: 8px 0;
  animation: messageIn 0.3s ease;
}

/* タイピング中の演出 */
.typing-indicator {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: messageIn 0.3s ease;
}

.typing-dots {
  background: #fff;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 12px 18px;
  display: flex;
  gap: 5px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: #aaa;
  border-radius: 50%;
  animation: dotBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ========== 入力エリア ========== */
.chat-input-area {
  padding: 10px 12px;
  background: #f5f5f5;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.message-input {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  font-size: 15px;
  background: #fff;
  outline: none;
}

.message-input:focus {
  box-shadow: 0 0 0 2px #06c755;
}

.send-button {
  background: #06c755;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.send-button:hover {
  background: #05b34c;
}

.send-button:active {
  transform: scale(0.96);
}

/* ========== 通信簿画面 ========== */
#result-screen {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  justify-content: center;
  align-items: center;
}

.result-content {
  text-align: center;
  padding: 24px;
  width: 100%;
}

.result-title {
  color: #fff;
  font-size: 32px;
  margin-bottom: 24px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.result-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  margin: 0 8px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.result-stats {
  text-align: left;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid #eee;
  font-size: 15px;
  color: #333;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: #888;
}

.stat-value {
  font-weight: 700;
}

.result-rank {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed #ddd;
}

.rank-label {
  font-size: 13px;
  color: #888;
  margin-bottom: 8px;
}

.rank-value {
  font-size: 28px;
  font-weight: 900;
  color: #764ba2;
}

.retry-button {
  background: #fff;
  color: #764ba2;
  border: none;
  padding: 14px 40px;
  border-radius: 30px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  margin-bottom: 12px;
}

.retry-button:hover {
  transform: scale(1.05);
}

.share-button {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 10px 32px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.share-button:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* コピー完了表示 */
.share-button.copied {
  background: rgba(255, 255, 255, 0.3);
  border-color: #fff;
}

/* ========== イライラMAX演出 ========== */
.screen.shake {
  animation: shake 0.5s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ゲージMAX時の点滅 */
.gauge-fill.max {
  animation: gaugePulse 0.6s ease infinite;
}

@keyframes gaugePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ========== ずかんボタン（スタート画面） ========== */
.collection-button {
  display: block;
  margin: 16px auto 0;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 10px 28px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.collection-button:hover {
  background: rgba(255, 255, 255, 0.35);
  transform: scale(1.05);
}

.promo-link {
  display: block;
  margin-top: 24px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.2s;
}

.promo-link:hover {
  color: #fff;
}

/* ========== ずかんバッジ（チャットヘッダー） ========== */
.chat-collection-btn {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-collection-btn:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* ========== ずかんボタン（通信簿画面） ========== */
.result-collection-button {
  display: block;
  margin: 0 auto 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.5);
  padding: 10px 32px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.result-collection-button:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ========== ずかん画面 ========== */
#collection-screen {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.collection-header {
  background: rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.collection-back-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 8px;
}

.collection-header-title {
  color: #fff;
  font-size: 18px;
  font-weight: 800;
}

.collection-progress-area {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.collection-progress-bar {
  flex: 1;
  height: 16px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  overflow: hidden;
}

.collection-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd93d, #ff6b6b);
  border-radius: 8px;
  transition: width 0.5s ease;
}

.collection-progress-text {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  min-width: 60px;
  text-align: right;
}

.collection-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  align-content: start;
}

.collection-card {
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  transition: transform 0.2s;
}

.collection-card.discovered {
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.collection-card.locked {
  background: rgba(255, 255, 255, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.5);
}

.collection-card.discovered:hover {
  transform: scale(1.03);
}

.card-number {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.5;
  margin-bottom: 2px;
}

.collection-card.discovered .card-number {
  color: #f5576c;
}

.collection-card.locked .card-number {
  color: #fff;
}

.card-category {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 4px;
}

.collection-card.discovered .card-category {
  color: #999;
}

.collection-card.locked .card-category {
  color: rgba(255, 255, 255, 0.7);
}

.card-reply {
  font-size: 14px;
  font-weight: 800;
  color: #333;
  margin-bottom: 2px;
}

.card-hint {
  font-size: 10px;
  color: #aaa;
}

.card-mystery {
  font-size: 20px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.5);
  padding: 6px 0;
}

/* ========== トースト通知 ========== */
.toast {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  z-index: 1000;
  transition: top 0.4s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.toast.show {
  top: 20px;
}

.toast.new-discovery {
  background: linear-gradient(135deg, #f093fb, #f5576c);
}

/* ========== コンプリート演出 ========== */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.celebration-overlay.active {
  display: flex;
}

.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -10px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

.celebration-content {
  text-align: center;
  z-index: 2001;
  animation: celebrationPop 0.6s ease;
}

@keyframes celebrationPop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.celebration-text {
  font-size: 48px;
  font-weight: 900;
  color: #ffd93d;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  margin-bottom: 8px;
}

.celebration-sub {
  font-size: 18px;
  color: #fff;
  margin-bottom: 32px;
}

.celebration-close {
  background: linear-gradient(135deg, #ffd93d, #ff6b6b);
  color: #fff;
  border: none;
  padding: 14px 40px;
  border-radius: 30px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.5s, transform 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.celebration-close:hover {
  transform: scale(1.08);
}

/* ========== レスポンシブ ========== */
@media (max-width: 480px) {
  body {
    background: none;
  }

  .screen {
    max-width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }
}
