/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --accent: #6200ee;
  --accent-light: #bb86fc;
  --text: #e0e0e0;
  --text-dim: #9e9e9e;
  --chip-bg: #2a2a4a;
  --chip-active: #6200ee;
  --card-bg: #1e1e3a;
  --header-h: 56px;
}

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== Splash ===== */
#splash-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#splash-logo {
  max-width: 80vw;
  max-height: 80vh;
  object-fit: contain;
}

/* ===== App Shell ===== */
#app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  padding-top: env(safe-area-inset-top);
}

/* ===== List View ===== */
#list-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#list-header {
  background: var(--bg2);
  padding: 10px 12px 8px;
  border-bottom: 1px solid #2a2a4a;
  flex-shrink: 0;
}

#search-bar-wrap {
  position: relative;
  margin-bottom: 8px;
}

#search-input {
  width: 100%;
  background: #2a2a4a;
  border: 1px solid #3a3a5a;
  border-radius: 24px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 36px 8px 16px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus { border-color: var(--accent-light); }
#search-input::placeholder { color: var(--text-dim); }

#search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}
#search-clear:hover { color: var(--text); }

#filter-chips-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

#chips-clear {
  background: #3a1a1a;
  border: 1px solid #6a2a2a;
  border-radius: 14px;
  color: #ff8888;
  cursor: pointer;
  font-size: 12px;
  padding: 4px 10px;
  white-space: nowrap;
  transition: background 0.15s;
}
#chips-clear:hover { background: #5a2a2a; }

.chip {
  background: var(--chip-bg);
  border: 1px solid #3a3a5a;
  border-radius: 16px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 12px;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
}

.chip:hover { border-color: var(--accent-light); }
.chip.active { background: var(--chip-active); border-color: var(--accent-light); }


/* ===== Investigator List ===== */
#investigator-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

#investigator-list::-webkit-scrollbar { width: 6px; }
#investigator-list::-webkit-scrollbar-track { background: var(--bg); }
#investigator-list::-webkit-scrollbar-thumb { background: #3a3a5a; border-radius: 3px; }

.inv-card {
  background: var(--card-bg);
  border: 1px solid #2a2a4a;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  gap: 18px;
  margin-bottom: 10px;
  padding: 16px;
  transition: border-color 0.15s, background 0.15s;
}

.inv-card:hover {
  background: #22225a;
  border-color: var(--accent-light);
}

.inv-token {
  flex-shrink: 0;
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  object-position: top center;
  border: 3px solid var(--accent);
}

.inv-info {
  flex: 1;
  min-width: 0;
}

.inv-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 4px;
}

.inv-quote {
  font-size: 16px;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 10px;
}

.inv-ability-name {
  font-size: 18px;
  font-weight: 600;
  color: #f0c040;
  margin-bottom: 5px;
}

.inv-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
}

.inv-level {
  font-size: 15px;
  color: var(--text-dim);
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.inv-level .level-label {
  color: var(--accent-light);
  font-weight: 600;
  flex-shrink: 0;
}

.ability-icon {
  height: 1.1em;
  vertical-align: middle;
  display: inline;
}

.inv-common-abilities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.inv-common-tag {
  background: #2a2a4a;
  border: 1px solid #4a4a7a;
  border-radius: 12px;
  color: var(--text-dim);
  font-size: 13px;
  padding: 2px 10px;
}

/* ===== Detail View ===== */
#detail-view {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #000;
}

#detail-header {
  background: var(--bg2);
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
  z-index: 10;
}

#back-btn {
  background: transparent;
  border: 1px solid #3a3a5a;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  padding: 5px 12px;
  transition: border-color 0.15s;
}
#back-btn:hover { border-color: var(--accent-light); }

#detail-title {
  flex: 1;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#color-toggle-btn {
  background: transparent;
  border: 1px solid #3a3a5a;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
  padding: 0;
  color: #6200ee;
}
#color-toggle-btn:hover { border-color: var(--accent-light); }

/* ===== Card Zoom Area ===== */
#card-container {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: crosshair;
  touch-action: none;
  background: #000;
}

#card-image {
  position: absolute;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

#marker-canvas {
  position: absolute;
  pointer-events: none;
}

/* ===== Color Picker Panel ===== */
#color-picker-panel {
  background: var(--bg2);
  border-top: 1px solid #2a2a4a;
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px;
  flex-shrink: 0;
}

#color-picker-panel.hidden { display: none !important; }

#color-wheel {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  cursor: crosshair;
}

#color-preview {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ===== No Results ===== */
#no-results {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 14px;
}
