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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e14;
  color: #c8ccd0;
  overflow-x: hidden;
  min-height: 100vh;
}

#app { max-width: 1500px; margin: 0 auto; }

/* --- ヘッダー --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(240, 160, 48, 0.15);
}
.header-apps-link {
  color: #f0a030;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  border: 1px solid rgba(240, 160, 48, 0.3);
  border-radius: 6px;
  transition: background 0.2s;
}
.header-apps-link:hover { background: rgba(240, 160, 48, 0.12); }
.header-title { font-size: 18px; font-weight: 700; }
.gradient-text {
  background: linear-gradient(135deg, #f0a030, #e07020);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- ワールドバー --- */
#resource-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 8px 16px;
  background: rgba(20, 25, 35, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
}
.res b { color: #fff; }

/* --- メインエリア --- */
#main-area {
  display: flex;
  gap: 0;
  height: 640px;
  max-height: 640px;
}

/* --- 神パネル --- */
#god-panel {
  width: 200px;
  min-width: 200px;
  padding: 8px;
  background: rgba(15, 20, 28, 0.95);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
  max-height: 600px;
}
#god-panel .panel-section { margin-bottom: 8px; }
#god-panel .panel-section h3 { margin-bottom: 4px; }
.god-target-row { margin-bottom: 5px; }
.god-target-row label { display: block; font-size: 11px; color: #aaa; margin-bottom: 3px; }
.god-target-row select {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #ddd;
  font-size: 11px;
  padding: 4px 6px;
  cursor: pointer;
}
.god-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}
.god-btn {
  padding: 4px 5px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: #ddd;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}
.god-btn:hover { background: rgba(255, 255, 255, 0.12); }
.god-btn.good {
  border-color: rgba(68, 204, 102, 0.2);
  background: rgba(68, 204, 102, 0.06);
}
.god-btn.good:hover { background: rgba(68, 204, 102, 0.18); border-color: #44cc66; }
.god-btn.bad {
  border-color: rgba(238, 68, 68, 0.2);
  background: rgba(238, 68, 68, 0.06);
}
.god-btn.bad:hover { background: rgba(238, 68, 68, 0.18); border-color: #ee4444; }
.god-btn.neutral {
  border-color: rgba(240, 160, 48, 0.2);
  background: rgba(240, 160, 48, 0.06);
}
.god-btn.neutral:hover { background: rgba(240, 160, 48, 0.18); border-color: #f0a030; }
.god-btn:active { transform: scale(0.95); }

/* --- イベントトグル --- */
.evt-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px 4px;
}
.evt-toggles label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #aaa;
  cursor: pointer;
  padding: 1px 0;
}
.evt-toggles label:hover { color: #ddd; }
.evt-toggles input[type="checkbox"] {
  accent-color: #f0a030;
  width: 12px;
  height: 12px;
  cursor: pointer;
}

/* --- 設定 --- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.setting-row label {
  font-size: 11px;
  color: #aaa;
}
.setting-row select {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: #ddd;
  font-size: 11px;
  padding: 3px 6px;
  cursor: pointer;
}

/* --- 文明パネル 神選択ハイライト --- */
.civ-row { cursor: pointer; transition: background 0.15s; }
.civ-row:hover { background: rgba(255, 255, 255, 0.04); }
.civ-row.god-selected {
  background: rgba(240, 160, 48, 0.12);
  border-left: 3px solid #f0a030;
  padding-left: 5px;
}

/* --- キャンバス --- */
#canvas-wrapper {
  flex: 1;
  position: relative;
  background: #0d1117;
  height: 640px;
}
#world { display: block; width: 100%; height: 100%; }

/* --- モードバー --- */
#mode-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 6px 12px;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
}
.mode-row { display: flex; align-items: center; gap: 4px; }
.mode-label { font-size: 11px; color: #888; margin-right: 2px; }
.speed-btn {
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.speed-btn:hover { background: rgba(255, 255, 255, 0.1); }
.speed-btn.active { background: rgba(240, 160, 48, 0.2); border-color: #f0a030; color: #fff; }

#tile-tooltip {
  display: none;
  position: absolute;
  background: rgba(15, 20, 30, 0.95);
  border: 1px solid rgba(240, 160, 48, 0.3);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: #ddd;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}
#tile-tooltip.show { display: block; }

#event-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%) translateY(-60px);
  background: rgba(15, 20, 30, 0.95);
  border: 1px solid rgba(240, 160, 48, 0.4);
  border-radius: 8px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.4s, opacity 0.4s;
  max-width: 90%;
  text-align: center;
}
#event-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* --- 情報パネル --- */
#info-panel {
  width: 260px;
  min-width: 260px;
  padding: 10px;
  background: rgba(15, 20, 28, 0.95);
  border-left: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
  max-height: 600px;
}
.panel-section { margin-bottom: 12px; }
.panel-section h3 {
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- タイル情報 --- */
#tile-info {
  font-size: 11px;
  line-height: 1.6;
  color: #aaa;
}

/* --- 文明パネル --- */
#civ-overview { font-size: 11px; }
.civ-row {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.civ-row.dead { opacity: 0.4; }
.civ-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.civ-pop { font-size: 11px; color: #aaa; }
.civ-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 3px;
}
.civ-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s;
}
.civ-stats { color: #999; font-size: 10px; }
.civ-res { color: #888; font-size: 9px; margin-top: 1px; letter-spacing: -0.3px; }
.civ-roles { color: #888; font-size: 10px; margin-top: 1px; }
.civ-meta { color: #777; font-size: 10px; margin-top: 1px; }
.civ-wonders {
  font-size: 10px;
  color: #ffd700;
  font-weight: 600;
  margin-top: 2px;
}
.civ-effects {
  font-size: 10px;
  color: #cc88ff;
  font-weight: 600;
  margin-top: 2px;
}
.civ-rels { font-size: 10px; margin-top: 2px; }

/* --- イベントログ --- */
#event-log {
  font-size: 11px;
  max-height: 200px;
  overflow-y: auto;
}
.event-item {
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #999;
  line-height: 1.4;
}
.event-item.important { color: #ddd; }
.event-item b { color: #eee; }
.event-year {
  color: #666;
  font-size: 9px;
  font-weight: 600;
  margin-right: 4px;
}

/* --- 実績ポップアップ --- */
#achievement-popup {
  position: fixed;
  top: 60px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.achievement-toast {
  background: linear-gradient(135deg, rgba(240, 160, 48, 0.9), rgba(224, 112, 32, 0.9));
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  animation: achieveIn 0.4s ease-out, achieveOut 0.5s 3s forwards;
  box-shadow: 0 4px 20px rgba(240, 160, 48, 0.3);
}
@keyframes achieveIn { from { transform: translateX(120px); opacity: 0; } }
@keyframes achieveOut { to { transform: translateX(120px); opacity: 0; } }

/* --- 画面揺れ --- */
.shake { animation: shakeAnim 0.4s; }
@keyframes shakeAnim {
  0%, 100% { transform: translate(0); }
  20% { transform: translate(-4px, 2px); }
  40% { transform: translate(4px, -2px); }
  60% { transform: translate(-3px, 3px); }
  80% { transform: translate(3px, -1px); }
}

/* --- 遊び方ガイド --- */
.guide-section {
  padding: 24px 16px;
}
.guide-title {
  font-size: 20px;
  font-weight: 700;
  color: #f0a030;
  margin-bottom: 16px;
  text-align: center;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.guide-card {
  background: rgba(20, 25, 35, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 14px 16px;
}
.guide-card h3 {
  font-size: 14px;
  color: #eee;
  margin-bottom: 8px;
}
.guide-card p {
  font-size: 12px;
  color: #aaa;
  margin-bottom: 8px;
  line-height: 1.6;
}
.guide-card ul {
  list-style: none;
  font-size: 12px;
  color: #999;
  line-height: 1.8;
}
.guide-card ul li { padding-left: 4px; }
.guide-card b { color: #ddd; }
.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  margin-right: 2px;
}
.tag.good { background: rgba(68,204,102,0.15); color: #44cc66; }
.tag.bad { background: rgba(238,68,68,0.15); color: #ee4444; }
.tag.neutral { background: rgba(240,160,48,0.15); color: #f0a030; }

/* --- ブログカード --- */
.blog-card-section { padding: 16px; }
.blog-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(20, 25, 35, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, border-color 0.2s;
}
.blog-card:hover { transform: translateY(-2px); border-color: rgba(240, 160, 48, 0.3); }
.blog-card-thumb { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }
.blog-card-title { font-weight: 700; font-size: 14px; color: #eee; }
.blog-card-desc { font-size: 12px; color: #888; margin-top: 2px; }

/* --- 関連アプリ --- */
.related-apps { padding: 0 16px; margin-top: 16px; }
.related-apps-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #888;
  margin-bottom: 12px;
}
.related-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.related-app-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(20, 25, 35, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, border-color 0.2s;
}
.related-app-link:hover {
  transform: translateY(-2px);
  border-color: rgba(240, 160, 48, 0.3);
}
.related-app-icon { font-size: 1.5rem; flex-shrink: 0; }
.related-app-info { flex: 1; min-width: 0; }
.related-app-name { font-size: 0.85rem; font-weight: 700; color: #eee; }
.related-app-desc { font-size: 0.7rem; color: #888; margin-top: 2px; }
.related-app-arrow { font-size: 0.9rem; color: #888; flex-shrink: 0; }

/* --- フッター --- */
.site-footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #555;
}
.footer-links { display: flex; justify-content: center; gap: 20px; margin-bottom: 8px; }
.footer-links a { color: #888; text-decoration: none; }
.footer-links a:hover { color: #f0a030; }

/* --- レスポンシブ --- */
@media (max-width: 900px) {
  #main-area { flex-direction: column; height: auto; max-height: none; }
  #god-panel {
    width: 100%;
    min-width: 0;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }
  #god-panel .panel-section { flex: 1; min-width: 160px; margin-bottom: 0; }
  .god-grid { flex-direction: row; flex-wrap: wrap; }
  .god-btn { width: auto; flex: 1; min-width: 100px; }
  .evt-toggles { flex-direction: row; flex-wrap: wrap; gap: 2px 12px; }
  #info-panel {
    width: 100%;
    min-width: 0;
    max-height: none;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
  }
  #canvas-wrapper { min-height: 400px; }
}
