@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&display=swap');

/* ==========================================================================
   1. Design Tokens & CSS Variables
   ========================================================================== */
:root {
  --bg-app: #020617;
  --bg-panel: rgba(15, 23, 42, 0.94);
  --bg-panel-solid: #0f172a;
  --bg-subtle: rgba(30, 41, 59, 0.85);
  --bg-hover: rgba(51, 65, 85, 0.85);

  --border-panel: rgba(51, 65, 85, 0.8);
  --border-subtle: rgba(51, 65, 85, 0.5);
  --border-light: rgba(255, 255, 255, 0.15);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --color-super: #f43f5e;
  --color-notvery: #22c55e;
  --color-immune: #3b82f6;

  --font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ==========================================================================
   2. Global Reset & Base
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  font-family: inherit;
  border: none;
  outline: none;
  background: none;
  cursor: pointer;
}

/* Utility Hidden & Display */
.hidden {
  display: none !important;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  height: 5px;
  width: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* ==========================================================================
   3. Header & Controls
   ========================================================================== */
.top-header {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-panel);
  padding: 10px 16px;
  flex-shrink: 0;
  z-index: 20;
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #22c55e 0%, #f43f5e 50%, #38bdf8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.header-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* Segmented Buttons (Layout & Selection Mode) */
.segmented-control {
  display: inline-flex;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.9);
  padding: 2px;
  border: 1px solid var(--border-panel);
  font-size: 12px;
  font-weight: 700;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.segment-btn {
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all 0.15s ease;
  font-size: 12px;
  font-weight: 700;
}

.segment-btn.active {
  background: #4f46e5;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.4);
}

/* Filter Box */
.filter-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-panel);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
}

.filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.filter-label:hover {
  opacity: 0.85;
}

.filter-label.filter-super { color: #fb7185; }
.filter-label.filter-notvery { color: #4ade80; }
.filter-label.filter-immune { color: #60a5fa; }

.filter-divider {
  color: #475569;
}

.filter-checkbox {
  cursor: pointer;
  accent-color: #6366f1;
}

/* Action Buttons (Legend toggle, Reset, Clear) */
.btn-action {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-panel);
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.btn-action:hover {
  background: var(--bg-hover);
  color: #ffffff;
}

.toggle-label {
  cursor: pointer;
  user-select: none;
}

/* ==========================================================================
   4. Quick Type Selector Ribbon
   ========================================================================== */
.quick-type-ribbon {
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-panel);
  padding: 6px 12px;
  overflow-x: auto;
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

@media (min-width: 768px) {
  .quick-type-ribbon {
    justify-content: center;
  }
}

.ribbon-container {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ribbon-btn {
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
  transition: all 0.15s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-light);
  cursor: pointer;
}

.ribbon-btn:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.ribbon-btn:active {
  transform: scale(0.96);
}

.ribbon-btn.text-dark {
  color: #0f172a;
}

.ribbon-btn.text-light {
  color: #ffffff;
}

/* ==========================================================================
   5. Main Graph Canvas & Overlays
   ========================================================================== */
.main-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-app);
}

#network-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#network-svg:active {
  cursor: grabbing;
}

.graph-link {
  transition: stroke-opacity 0.25s ease, stroke-width 0.25s ease;
}

.node-circle {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.2s ease, stroke-width 0.2s ease;
}

.node text {
  font-family: var(--font-family);
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Floating Glass Panels */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Floating Legend Overlay */
.legend-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  border: 1px solid var(--border-panel);
  border-radius: 16px;
  padding: 14px;
  font-size: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
  pointer-events: auto;
  z-index: 10;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-panel);
  padding-bottom: 6px;
}

.legend-title {
  font-weight: 700;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-close-btn {
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 6px;
  font-size: 12px;
  transition: all 0.15s ease;
}

.legend-close-btn:hover {
  color: #ffffff;
  background: var(--bg-hover);
}

.legend-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.legend-subgroup {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legend-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-color-tag {
  font-weight: 700;
  flex-shrink: 0;
}

.legend-color-tag.tag-super { color: #fb7185; }
.legend-color-tag.tag-notvery { color: #4ade80; }
.legend-color-tag.tag-immune { color: #60a5fa; }

.legend-lines-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: #e2e8f0;
}

.legend-line-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-divider {
  padding-top: 6px;
  border-top: 1px solid var(--border-subtle);
}

.guide-instructions {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.guide-instructions-title {
  font-weight: 700;
  color: #cbd5e1;
  margin-bottom: 2px;
}

/* ==========================================================================
   6. Bottom Inspector Drawer
   ========================================================================== */
.inspector-panel {
  --inspector-height: 40%;
  position: absolute;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 12px;
  right: 12px;
  border: 1px solid var(--border-panel);
  border-radius: 16px;
  padding: 4px 16px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 25px 30px -5px rgba(0, 0, 0, 0.7);
  height: var(--inspector-height);
  min-height: 100px;
  max-height: calc(100% - 20px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  transition: height 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.inspector-panel.is-empty {
  height: auto;
  min-height: 0;
  overflow: visible;
}

.inspector-panel.is-resizing {
  transition: none !important;
  user-select: none;
  -webkit-user-select: none;
}

/* Resize Handle Bar */
.inspector-resizer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 22px;
  cursor: row-resize;
  cursor: ns-resize;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  padding: 4px 0 6px;
  margin-bottom: 2px;
  flex-shrink: 0;
}

.resizer-pill {
  width: 48px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.inspector-resizer:hover .resizer-pill,
.inspector-panel.is-resizing .resizer-pill {
  width: 64px;
  height: 5px;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}

/* Inspector Actions Group & Size Presets */
.inspector-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspector-size-presets {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-panel);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.btn-size-preset {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.btn-size-preset:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.btn-size-preset.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.25);
}

@media (min-width: 768px) {
  .inspector-panel {
    left: 24px;
    right: 24px;
  }
}

.inspector-empty {
  text-align: center;
  padding: 12px;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.inspector-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  gap: 8px;
}

.inspector-top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border-panel);
  padding-bottom: 8px;
  flex-shrink: 0;
}

.inspector-selection-area {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.inspector-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.inspector-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 10px;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-light);
}

.inspector-badge.text-dark { color: #0f172a; }
.inspector-badge.text-light { color: #ffffff; }

.badge-dismiss-btn {
  margin-left: 4px;
  opacity: 0.75;
  font-size: 12px;
  transition: all 0.15s ease;
}

.badge-dismiss-btn:hover {
  opacity: 1;
  transform: scale(1.15);
}

.inspector-plus-sign {
  color: var(--text-dim);
  font-weight: 900;
  font-size: 14px;
}

/* Results Grid (攻撃相性 & 被弾相性) */
.results-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

@media (min-width: 1024px) {
  .results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.compat-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  min-height: auto;
}

.compat-group-header {
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 5px;
  flex-shrink: 0;
  transition: font-size 0.2s ease, padding 0.2s ease;
}

.compat-group-header.atk {
  color: #fb7185;
  border-color: rgba(244, 63, 94, 0.4);
}

.compat-group-header.def {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}

.compat-group-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 400;
  transition: font-size 0.2s ease;
}

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
}

.compat-card {
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: padding 0.2s ease, border-radius 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  flex-shrink: 0;
  min-height: auto;
}

.card-super {
  background: rgba(76, 5, 25, 0.35);
  border: 1px solid rgba(244, 63, 94, 0.5);
}

.card-notvery {
  background: rgba(6, 78, 59, 0.35);
  border: 1px solid rgba(34, 197, 94, 0.5);
}

.card-immune {
  background: rgba(30, 58, 138, 0.35);
  border: 1px solid rgba(59, 130, 246, 0.5);
}

.compat-card-title {
  font-weight: 900;
  font-size: 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: font-size 0.2s ease, margin 0.2s ease;
}

.card-super .compat-card-title { color: #fb7185; }
.card-notvery .compat-card-title { color: #4ade80; }
.card-immune .compat-card-title { color: #60a5fa; }

.badge-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 24px;
  transition: gap 0.2s ease;
}

.badge-none {
  color: var(--text-dim);
  font-style: italic;
  font-size: 11px;
  align-self: center;
  padding: 4px 0;
  transition: font-size 0.2s ease;
}

.type-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-light);
  letter-spacing: -0.01em;
  user-select: none;
  transition: padding 0.2s ease, font-size 0.2s ease, transform 0.15s ease, border-radius 0.2s ease;
}

.type-pill:hover {
  transform: scale(1.05);
}

.type-pill.text-dark { color: #0f172a; }
.type-pill.text-light { color: #ffffff; }

.type-pill-multiplier {
  font-size: 10px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  transition: font-size 0.2s ease, padding 0.2s ease;
}

.type-pill.text-dark .type-pill-multiplier {
  background: rgba(0, 0, 0, 0.18);
  color: #0f172a;
}

.type-pill.text-light .type-pill-multiplier {
  background: rgba(0, 0, 0, 0.32);
  color: #ffffff;
}

/* ==========================================================================
   Content Sizing Modes (小・中・大 連動)
   ========================================================================== */

/* --- 1. Compact Mode (小) --- */
.inspector-panel.size-compact {
  padding: 3px 10px 8px;
}
.inspector-panel.size-compact .inspector-top-bar {
  padding-bottom: 4px;
  gap: 6px;
}
.inspector-panel.size-compact .inspector-badge {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 6px;
}
.inspector-panel.size-compact .results-grid {
  gap: 8px;
}
.inspector-panel.size-compact .compat-group {
  gap: 4px;
}
.inspector-panel.size-compact .compat-group-header {
  font-size: 10.5px;
  padding-bottom: 2px;
}
.inspector-panel.size-compact .compat-group-subtitle {
  font-size: 9px;
}
.inspector-panel.size-compact .cards-container {
  gap: 6px;
}
.inspector-panel.size-compact .compat-card {
  padding: 4px 7px;
  border-radius: 8px;
}
.inspector-panel.size-compact .compat-card-title {
  font-size: 10px;
  margin-bottom: 2px;
  gap: 3px;
}
.inspector-panel.size-compact .badge-list {
  gap: 4px;
  min-height: 20px;
}
.inspector-panel.size-compact .type-pill {
  padding: 2px 6px;
  font-size: 10px;
  border-radius: 5px;
  gap: 3px;
}
.inspector-panel.size-compact .type-pill-multiplier {
  font-size: 9px;
  padding: 0 3px;
}
.inspector-panel.size-compact .badge-none {
  font-size: 9.5px;
  padding: 1px 0;
}

/* --- 2. Default Mode (中) --- */
.inspector-panel.size-default .compat-card {
  padding: 8px 10px;
}
.inspector-panel.size-default .compat-card-title {
  font-size: 12px;
  margin-bottom: 5px;
}
.inspector-panel.size-default .type-pill {
  padding: 4px 9px;
  font-size: 11px;
}
.inspector-panel.size-default .type-pill-multiplier {
  font-size: 10px;
  padding: 1px 5px;
}

/* --- 3. Expanded Mode (大) --- */
.inspector-panel.size-expanded {
  padding: 6px 18px 16px;
}
.inspector-panel.size-expanded .inspector-top-bar {
  padding-bottom: 8px;
  gap: 12px;
}
.inspector-panel.size-expanded .inspector-badge {
  padding: 6px 14px;
  font-size: 14px;
  border-radius: 10px;
}
.inspector-panel.size-expanded .results-grid {
  gap: 16px;
}
.inspector-panel.size-expanded .compat-group {
  gap: 10px;
}
.inspector-panel.size-expanded .compat-group-header {
  font-size: 14px;
  padding-bottom: 6px;
}
.inspector-panel.size-expanded .compat-group-subtitle {
  font-size: 12px;
}
.inspector-panel.size-expanded .cards-container {
  gap: 12px;
}
.inspector-panel.size-expanded .compat-card {
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}
.inspector-panel.size-expanded .compat-card-title {
  font-size: 13.5px;
  margin-bottom: 8px;
  gap: 6px;
}
.inspector-panel.size-expanded .badge-list {
  gap: 8px;
  min-height: 38px;
}
.inspector-panel.size-expanded .type-pill {
  padding: 6px 13px;
  font-size: 13px;
  border-radius: 9px;
  gap: 6px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.inspector-panel.size-expanded .type-pill-multiplier {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 5px;
}
.inspector-panel.size-expanded .badge-none {
  font-size: 12.5px;
  padding: 5px 0;
}

/* ==========================================================================
   7. Mobile Responsive Enhancements
   ========================================================================== */
@media (max-width: 640px) {
  .top-header {
    padding: 8px 10px;
  }

  .header-title {
    font-size: 14px;
  }

  .logo-icon {
    width: 26px;
    height: 26px;
    font-size: 13px;
  }

  .inspector-panel {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    padding: 4px 10px 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    max-height: calc(100% - 14px);
    border-radius: 14px;
  }

  .compat-card {
    padding: 8px;
  }

  .inspector-top-bar {
    gap: 6px;
    padding-bottom: 6px;
  }

  .inspector-selection-area {
    gap: 5px;
  }

  .inspector-badge {
    padding: 3px 8px;
    font-size: 11.5px;
  }

  .inspector-actions-group {
    gap: 4px;
    margin-left: auto;
  }

  .btn-size-preset {
    padding: 2px 6px;
    font-size: 10.5px;
  }
}

