/* =====================================================
   和風シンプルデザイン
   配色: 墨黒・和紙白・灰茶・朱赤
===================================================== */

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

body {
  font-family: "游ゴシック体", YuGothic, "游ゴシック", "Yu Gothic", "ヒラギノ角ゴ ProN", "Hiragino Kaku Gothic ProN", "メイリオ", Meiryo, sans-serif;
  background: #faf9f7; /* 和紙のような温かみのある白 */
  color: #2d2d2d; /* 墨黒 */
  min-height: 100vh;
  line-height: 1.7;
}

a, button { 
  cursor: pointer; 
  font-family: inherit;
}

/* =====================================================
   トップバー - 細い線の和風ヘッダー
===================================================== */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid #d4d0ca; /* 灰茶の細線 */
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

.nav { 
  display: flex; 
  gap: 12px;
  align-items: center;
  flex: 1;
}

.nav-btn {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid #d4d0ca;
  border-radius: 2px;
  background: transparent;
  color: #2d2d2d;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover {
  background: #faf9f7;
  border-color: #8b7e74;
}

.nav-btn.active {
  background: #2d2d2d;
  color: #ffffff;
  border-color: #2d2d2d;
}

/* ハンバーガーメニュー - シンプルな線 */
.hamburger {
  width: 48px; 
  height: 48px;
  border-radius: 2px;
  border: 1px solid #d4d0ca;
  background: #ffffff;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: 12px;
}

.hamburger:hover {
  border-color: #8b7e74;
  background: #faf9f7;
}

.hamburger span, 
.hamburger::before, 
.hamburger::after {
  content: '';
  position: absolute;
  left: 50%; 
  width: 24px; 
  height: 1px;
  background: #2d2d2d;
  transform: translateX(-50%);
  transition: all 0.2s ease;
}

.hamburger::before { top: 16px; }
.hamburger span { top: 23px; }
.hamburger::after { bottom: 16px; }

/* =====================================================
   メインコンテンツ - 余白を活かしたレイアウト
===================================================== */
main { 
  padding: 32px 20px; 
  max-width: 800px;
  margin: 0 auto;
}

.screen { 
  background: #ffffff;
  border: 1px solid #e8e5e0;
  padding: 32px 24px;
  display: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.02);
}

.screen.active { 
  display: block; 
}

.screen h1 {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
  color: #2d2d2d;
  border-bottom: 1px solid #e8e5e0;
  padding-bottom: 12px;
}

.screen h2 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  color: #2d2d2d;
}

.screen p {
  color: #5a5a5a;
  margin-bottom: 16px;
}

/* ホーム画面のアクション */
.home-actions { 
  display: grid; 
  gap: 12px; 
  margin-top: 24px; 
}

.ghost-btn, 
.draw-btn {
  border: 1px solid #d4d0ca;
  background: transparent;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #2d2d2d;
  transition: all 0.2s ease;
}

.ghost-btn:hover {
  background: #faf9f7;
  border-color: #8b7e74;
}

.draw-btn { 
  background: #c1504a; /* 朱赤 */
  color: #ffffff;
  border-color: #c1504a;
}

.draw-btn:hover {
  background: #a8443f;
  border-color: #a8443f;
}

/* =====================================================
   タブ - シンプルな切り替え
===================================================== */
.tabs { 
  display: flex; 
  gap: 0; 
  margin-bottom: 20px; 
  flex-wrap: nowrap;
  border-bottom: 1px solid #e8e5e0;
  padding-bottom: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs::-webkit-scrollbar {
  height: 2px;
}

.tabs::-webkit-scrollbar-thumb {
  background: #d4d0ca;
}

.tab-btn {
  flex: 1;
  min-width: 0;
  padding: 12px 8px;
  border: none;
  background: transparent;
  color: #8b7e74;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #2d2d2d;
}

.tab-btn.active { 
  color: #2d2d2d;
  border-bottom-color: #c1504a;
}

/* =====================================================
   謎ステージ - 和紙テクスチャ風
===================================================== */
.nazo-stage {
  position: relative;
  background: #fdfcfb;
  border: 1px solid #e8e5e0;
  margin-bottom: 20px;
  width: 100%;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
  overflow: hidden;
}

.nazo-stage::before {
  content: '';
  display: block;
  padding-top: 133.3%; /* 1441/1081 * 100 = 133.3% (画像比率を固定) */
}

.nazo-stage > div {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.nazo-stage img { 
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block; 
  pointer-events: none; 
}

/* ホットスポット - 控えめな色使い */
.hotspot, 
.drop-target {
  position: absolute;
  border: 1.5px dashed transparent;
  background: transparent;
  display: grid;
  place-items: center;
  color: transparent;
  font-size: 11px;
  letter-spacing: 0.05em;
  pointer-events: auto;
  touch-action: none;
  z-index: 2;
  user-select: none;
  transition: all 0.2s ease;
}

/* デバッグモード時のホットスポット表示 */
body.debug-mode .hotspot,
body.debug-mode .drop-target {
  border: 1.5px dashed #8b7e74;
  background: rgba(139, 126, 116, 0.08);
  color: #5a5a5a;
}

body.debug-mode .hotspot:hover,
body.debug-mode .drop-target:hover {
  background: rgba(139, 126, 116, 0.15);
  border-color: #5a5a5a;
}

.drop-target {
  z-index: 2;
}

.pickup { 
  border-color: transparent;
  background: transparent;
  color: transparent;
  z-index: 10;
  font-weight: 500;
}

body.debug-mode .pickup {
  border-color: #c1504a;
  background: rgba(193, 80, 74, 0.08);
  color: #c1504a;
}

body.debug-mode .pickup:hover {
  background: rgba(193, 80, 74, 0.15);
}

/* =====================================================
   フォーム - シンプルな入力欄
===================================================== */
.answer-form { 
  display: grid; 
  gap: 12px; 
  margin-top: 20px; 
}

.answer-form label {
  display: block;
  color: #5a5a5a;
  font-size: 13px;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.answer-form input { 
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d4d0ca;
  background: #fdfcfb;
  font-size: 15px;
  font-family: inherit;
  color: #2d2d2d;
  transition: all 0.2s ease;
}

.answer-form input:focus {
  outline: none;
  border-color: #8b7e74;
  background: #ffffff;
}

.answer-form button[type="submit"] {
  padding: 12px 24px;
  border: 1px solid #2d2d2d;
  background: #2d2d2d;
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: all 0.2s ease;
}

.answer-form button[type="submit"]:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
}

.answer-feedback { 
  min-height: 20px;
  color: #8b7e74;
  font-size: 14px;
  letter-spacing: 0.03em;
}

/* =====================================================
   クリップボードドロワー - 和風サイドバー
===================================================== */
.clipboard-drawer {
  position: fixed;
  top: 0;
  right: -340px;
  width: 340px;
  max-width: 90vw;
  height: 100vh;
  background: #ffffff;
  border-left: 1px solid #d4d0ca;
  box-shadow: -4px 0 12px rgba(0,0,0,0.05);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 20px;
  z-index: 30;
}

.clipboard-drawer.open { 
  right: 0; 
}

.clipboard-header { 
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #e8e5e0;
  padding-bottom: 12px;
}

.clipboard-header h3 {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #2d2d2d;
}

.clipboard-list { 
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  padding: 8px 0;
}

.clipboard-item-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.clipboard-item { 
  border: 1px solid #e8e5e0;
  padding: 8px;
  display: grid;
  place-items: center;
  background: #fdfcfb;
  transition: all 0.2s ease;
  aspect-ratio: 201 / 109; /* クリップボード画像の比率を固定 */
  width: 100%;
}

.clipboard-item:hover {
  border-color: #8b7e74;
  background: #faf9f7;
}

.clipboard-item img { 
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.item-label {
  font-size: 11px;
  color: #5a5a5a;
  letter-spacing: 0.04em;
  text-align: center;
  line-height: 1.2;
  padding: 2px 4px;
}

.clipboard-empty { 
  color: #8b7e74;
  font-size: 13px;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 32px 16px;
}

/* =====================================================
   トースト - 控えめな通知
===================================================== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #2d2d2d;
  color: #ffffff;
  padding: 12px 20px;
  font-size: 14px;
  letter-spacing: 0.05em;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 40;
  pointer-events: none;
  border: 1px solid #2d2d2d;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.toast.show { 
  opacity: 0.95; 
}

/* =====================================================
   モーダル - 和風ダイアログ
===================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(45, 45, 45, 0.4);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal.show { 
  display: flex; 
}

.modal-content {
  background: #ffffff;
  border: 1px solid #d4d0ca;
  padding: 28px 24px;
  width: 90%;
  max-width: 440px;
  display: grid;
  gap: 20px;
  max-height: 85vh;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.modal-content h3 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #2d2d2d;
  border-bottom: 1px solid #e8e5e0;
  padding-bottom: 12px;
}

.modal-content p {
  color: #5a5a5a;
  line-height: 1.8;
  font-size: 14px;
  letter-spacing: 0.03em;
}

.modal-body.scroll { 
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 8px;
}

.modal-body.scroll::-webkit-scrollbar {
  width: 4px;
}

.modal-body.scroll::-webkit-scrollbar-track {
  background: #faf9f7;
}

.modal-body.scroll::-webkit-scrollbar-thumb {
  background: #d4d0ca;
}

.modal-actions { 
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding-top: 8px;
}

.modal-actions button {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* =====================================================
   ドラッグゴースト - 要素ドラッグ時の表示
===================================================== */
.ghost {
  position: fixed;
  width: 64px;
  height: 64px;
  opacity: 0.85;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 60;
  display: none;
  border: 1px solid #c1504a;
  box-shadow: 0 2px 12px rgba(193, 80, 74, 0.2);
}

/* =====================================================
   キーワード入力フォーム - グリッド配置
===================================================== */
.keywords-form {
  display: grid;
  gap: 20px;
  padding: 12px;
}

.keywords-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.keywords-grid input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d4d0ca;
  background: #fdfcfb;
  font-size: 15px;
  font-family: inherit;
  color: #2d2d2d;
  letter-spacing: 0.03em;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.keywords-grid input:focus {
  outline: none;
  border-color: #8b7e74;
  background: #ffffff;
}

.keywords-grid input::placeholder {
  color: #b0a9a0;
  letter-spacing: 0.02em;
}

/* =====================================================
   Loading Overlay
===================================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(250, 249, 247, 0.9);
  z-index: 70;
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-content {
  background: #ffffff;
  border: 1px solid #e0dbd4;
  padding: 24px 28px;
  border-radius: 6px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.08);
  display: grid;
  gap: 12px;
  place-items: center;
  min-width: 240px;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid #e6e0d8;
  border-top-color: #c1504a;
  animation: spin 0.9s linear infinite;
}

.loading-note {
  font-size: 13px;
  color: #6a625a;
  letter-spacing: 0.05em;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* =====================================================
   レスポンシブ対応 - モバイル表示
===================================================== */
@media (max-width: 520px) {
  .nav {
    gap: 8px;
  }

  .nav-btn {
    font-size: 12px;
    padding: 8px 6px;
    letter-spacing: 0.03em;
  }

  .hamburger {
    width: 44px;
    height: 44px;
    margin-left: 8px;
  }

  .hamburger::before { top: 14px; }
  .hamburger span { top: 21px; }
  .hamburger::after { top: 28px; }

  .tab-btn {
    font-size: 12px;
    padding: 10px 6px;
  }

  .clipboard-drawer {
    width: 100%;
    right: -100%;
    left: auto;
  }

  .clipboard-drawer.open {
    right: 0;
  }

  .keywords-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: 20px 16px;
  }
}
