/* ==========================================================================
   基本リセット & 全体レイアウト（上95%：エディタ / 下5%：罠ボタンバー）
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: #f8f9fa;
  color: #1f2328;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Meiryo", "Yu Gothic", sans-serif;
  user-select: none;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* 上95%：無慈悲なテキストエディタ領域 */
#editor-wrapper {
  width: 100%;
  height: 95vh;
  background-color: #ffffff;
  position: relative;
}

#void-editor {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  padding: 28px 36px;
  font-size: 17px;
  line-height: 1.85;
  color: #111111;
  background-color: #ffffff;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  user-select: text;
  overflow-y: auto;
}

#void-editor::placeholder {
  color: #a0a8b0;
  font-style: italic;
}

/* 消滅時の画面フラッシュ演出 */
@keyframes screenGlitchReset {
  0% { background-color: #ffffff; transform: translate(0, 0); }
  20% { background-color: #ffe5e5; transform: translate(-6px, 3px); }
  40% { background-color: #111111; color: #ffffff; transform: translate(6px, -3px); }
  60% { background-color: #ffcccc; transform: translate(-3px, -2px); }
  100% { background-color: #ffffff; transform: translate(0, 0); }
}

.editor-wiped {
  animation: screenGlitchReset 0.35s ease-out;
}

/* 下5%：罠ボタンバー */
#trap-toolbar {
  width: 100%;
  height: 5vh;
  min-height: 38px;
  background-color: #e9ecef;
  border-top: 1px solid #ced4da;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 16px;
  z-index: 100;
}

.trap-btn {
  height: 76%;
  min-height: 26px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: #212529;
  background-color: #ffffff;
  border: 1px solid #adb5bd;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.12s, transform 0.06s, border-color 0.12s;
  white-space: nowrap;
}

.trap-btn:hover {
  background-color: #f1f3f5;
  border-color: #495057;
}

.trap-btn:active {
  transform: translateY(1px);
}

#btn-x-post {
  background-color: #0f1419;
  color: #ffffff;
  border-color: #0f1419;
}

#btn-x-post:hover {
  background-color: #272c30;
}

.record-btn {
  background-color: #2b3a67;
  color: #ffffff;
  border-color: #1d2847;
  margin-left: 8px;
}

.record-btn:hover {
  background-color: #3b4f8c;
}

/* ==========================================================================
   消滅通知トースト（左上〜中央上部に冷酷に表示）
   ========================================================================== */
#void-toast {
  position: fixed;
  top: 20px;
  left: 24px;
  max-width: 440px;
  background: rgba(18, 18, 22, 0.94);
  color: #ffffff;
  border-left: 5px solid #e03131;
  border-radius: 6px;
  padding: 14px 18px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  z-index: 900;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#void-toast.hidden {
  opacity: 0;
  transform: translateY(-16px);
}

.void-toast-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  background-color: #e03131;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 3px;
  margin-bottom: 6px;
}

#void-toast-message {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 4px;
}

#void-toast-sub {
  font-size: 12px;
  color: #adb5bd;
}

/* ==========================================================================
   新規称号獲得：右上から豪華にスライドイン
   ========================================================================== */
#new-title-popup {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 390px;
  max-width: calc(100vw - 40px);
  background: linear-gradient(135deg, #1b1f3b 0%, #2c1e4a 55%, #4a1c40 100%);
  color: #ffffff;
  border: 2px solid #ffd43b;
  border-radius: 10px;
  padding: 16px 20px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 0 20px rgba(255, 212, 59, 0.35);
  z-index: 1000;
  pointer-events: none;
  transform: translateX(0);
  opacity: 1;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

#new-title-popup.hidden {
  transform: translateX(120%);
  opacity: 0;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.popup-tag {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: #1b1f3b;
  background: linear-gradient(90deg, #ffd43b, #fcc419);
  padding: 2px 8px;
  border-radius: 4px;
}

#popup-title-no {
  font-size: 12px;
  font-weight: 700;
  color: #ffe066;
  font-family: monospace;
}

.popup-name {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.45;
  margin-bottom: 8px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.popup-method {
  font-size: 12px;
  color: #e9d8fd;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 10px;
  border-radius: 5px;
  line-height: 1.45;
}

/* ==========================================================================
   既獲得称号再達成：E6系こまち＋E5系はやぶさ（はやこま）320km/h爆走軌道
   ========================================================================== */
#shinkansen-track {
  position: fixed;
  bottom: calc(5vh + 6px);
  left: 0;
  width: 100vw;
  height: 54px;
  pointer-events: none;
  overflow: hidden;
  z-index: 950;
}

/* 編成コンテナ：右端画面外から左端画面外へ時速320km/hの勢いで一気に通過 */
.hayakoma-train {
  position: absolute;
  bottom: 4px;
  left: 100vw;
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  white-space: nowrap;
  will-change: transform;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.28));
  animation: hayakomaPass320 var(--pass-duration, 2.4s) linear forwards;
}

@keyframes hayakomaPass320 {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-100vw - 100% - 120px));
  }
}

/* 車両共通スタイル（1両につき1〜3文字を搭載） */
.train-car {
  position: relative;
  height: 40px;
  min-width: 56px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  border-radius: 4px 4px 2px 2px;
  overflow: hidden;
}

/* E6系こまちカラー（上半分：ジャパンレッド / 帯：アローシルバー / 下半分：飛雲ホワイト） */
.car-komachi {
  background: linear-gradient(
    to bottom,
    #d91e36 0%,
    #d91e36 48%,
    #adb5bd 48%,
    #adb5bd 56%,
    #f8f9fa 56%,
    #f8f9fa 100%
  );
  border: 1px solid #b0172b;
  color: #111111;
}

/* E6系先頭車（左向き流線形ロングノーズ） */
.car-komachi.head-left {
  border-radius: 34px 4px 2px 6px;
  padding-left: 20px;
  min-width: 72px;
}

/* E6系後尾車（E5系との連結面側） */
.car-komachi.tail-right {
  border-radius: 4px 8px 2px 2px;
}

/* E6系とE5系の幌（連結部） */
.train-coupler {
  width: 7px;
  height: 30px;
  background-color: #343a40;
  border-top: 3px solid #d91e36;
  border-bottom: 3px solid #008b74;
  border-radius: 2px;
  margin: 0 1px;
}

/* E5系はやぶさカラー（上半分：常盤グリーン / 帯：はやてピンク / 下半分：飛雲ホワイト） */
.car-hayabusa {
  background: linear-gradient(
    to bottom,
    #008b74 0%,
    #008b74 48%,
    #e64980 48%,
    #e64980 56%,
    #f8f9fa 56%,
    #f8f9fa 100%
  );
  border: 1px solid #006b59;
  color: #111111;
}

/* E5系連結側先頭車 */
.car-hayabusa.head-left {
  border-radius: 8px 4px 2px 2px;
}

/* E5系最後尾車（右向き流線形ロングノーズ） */
.car-hayabusa.tail-right {
  border-radius: 4px 34px 6px 2px;
  padding-right: 20px;
  min-width: 72px;
}

/* 車窓風に文字をくっきり浮かび上がらせるバッジ */
.car-text {
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  z-index: 2;
}

/* 車輪表現 */
.train-car::after {
  content: "";
  position: absolute;
  bottom: -3px;
  left: 14%;
  right: 14%;
  height: 4px;
  background: radial-gradient(circle, #212529 3px, transparent 4px) repeat-x;
  background-size: 16px 4px;
}

/* ==========================================================================
   記録・称号図鑑モーダル
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  padding: 20px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-window {
  width: 100%;
  max-width: 960px;
  height: 88vh;
  background: #ffffff;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.modal-header {
  padding: 18px 24px;
  background: #1e293b;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-group h2 {
  font-size: 19px;
  font-weight: 800;
}

.modal-subtitle {
  font-size: 12px;
  color: #fca5a5;
  margin-top: 3px;
}

.close-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* 統計サマリーバー */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 14px 24px;
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
}

.stat-box {
  background: #ffffff;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 700;
}

.stat-value {
  font-size: 15px;
  color: #0f172a;
  margin-top: 2px;
}

.stat-value strong {
  font-size: 18px;
  color: #2563eb;
}

/* 検索・フィルターバー */
.filter-bar {
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

#title-search-input {
  flex: 1;
  min-width: 240px;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
}

#title-search-input:focus {
  border-color: #2563eb;
}

.filter-buttons {
  display: flex;
  gap: 6px;
}

.filter-btn {
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 6px;
  cursor: pointer;
}

.filter-btn.active {
  background: #1e293b;
  color: #ffffff;
  border-color: #1e293b;
}

/* 称号一覧リスト */
.title-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
  user-select: text;
}

.title-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title-card.unlocked {
  border-left: 5px solid #eab308;
  background: #fffbeb;
}

.title-card.hanshin-slot.unlocked {
  border-left: 5px solid #f59e0b;
  background: linear-gradient(90deg, #fef3c7 0%, #ffffff 100%);
}

.title-card.locked {
  opacity: 0.78;
  background: #f1f5f9;
}

.title-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.title-no {
  font-family: monospace;
  font-size: 12px;
  font-weight: 800;
  color: #64748b;
}

.title-status-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.title-card.unlocked .title-status-badge {
  background: #fef08a;
  color: #854d0e;
}

.title-card.locked .title-status-badge {
  background: #e2e8f0;
  color: #475569;
}

.title-row {
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
}

.title-row-label {
  font-weight: 800;
  color: #475569;
  margin-right: 6px;
}

.title-card.locked .title-row-value {
  font-family: monospace;
  color: #94a3b8;
  letter-spacing: 0.08em;
}

/* モーダルフッター（ページネーション＆全消去） */
.modal-footer {
  padding: 12px 24px;
  background: #ffffff;
  border-top: 1px solid #cbd5e1;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-btn {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  cursor: pointer;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#page-indicator {
  font-size: 13px;
  font-weight: 700;
  min-width: 110px;
  text-align: center;
}

.wipe-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 5px;
  cursor: pointer;
}

.wipe-btn:hover {
  background: #fee2e2;
}

/* ==========================================================================
   208ページ目専用：禁断の隠し称号カード（EXTRAS）
   ========================================================================== */
.title-card.secret-slot.unlocked {
  border-left: 5px solid #9333ea;
  background: linear-gradient(90deg, #1e1b4b 0%, #311042 100%);
  color: #f8fafc;
}

.title-card.secret-slot.unlocked .title-no {
  color: #d8b4fe;
}

.title-card.secret-slot.unlocked .title-status-badge {
  background: #9333ea;
  color: #ffffff;
}

.title-card.secret-slot.unlocked .title-row,
.title-card.secret-slot.unlocked .title-row-label {
  color: #f3e8ff;
}