/* ── MapleStory V62 GM Handbook ── */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg:        #0a0a1a;
  --bg2:       #0f0f22;
  --bg3:       #151530;
  --panel:     #1a1a35;
  --border:    #2a2a55;
  --gold:      #d4a843;
  --gold2:     #f0c860;
  --gold3:     #a87830;
  --blue:      #4488ff;
  --blue2:     #2255cc;
  --green:     #44bb66;
  --red:       #ff4444;
  --purple:    #aa66ff;
  --cyan:      #44ddff;
  --text:      #e8e8f0;
  --text2:     #a0a0c0;
  --text3:     #606080;
  --card-h:    44px;
  --radius:    8px;
  --shadow:    0 4px 24px rgba(0,0,0,.6);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Starfield bg ── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(212,168,67,.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 70%, rgba(68,136,255,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 60% 10%, rgba(68,221,255,.25) 0%, transparent 100%),
    radial-gradient(1px 1px at 80% 50%, rgba(212,168,67,.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 50% 90%, rgba(170,102,255,.25) 0%, transparent 100%);
  pointer-events: none; z-index: 0;
}

/* ── Layout ── */
#app { position: relative; z-index: 1; max-width: 1400px; margin: 0 auto; padding: 0 16px 80px; }

/* ── Header ── */
header {
  text-align: center;
  padding: 32px 16px 24px;
  position: relative;
}
.logo-wrap {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 8px;
}
.logo-leaf {
  font-size: 2rem;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
h1 {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(14px, 3.5vw, 26px);
  background: linear-gradient(135deg, var(--gold2) 0%, var(--gold) 50%, var(--gold3) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.4;
  text-shadow: none;
  letter-spacing: 1px;
}
.subtitle {
  font-size: 12px;
  color: var(--text2);
  margin-top: 6px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.header-line {
  width: 100%; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--blue), var(--gold), transparent);
  margin-top: 20px;
  border-radius: 2px;
}

/* ── Search ── */
.search-wrap {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,10,26,.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.search-inner {
  display: flex; flex-direction: column; gap: 10px;
  max-width: 800px; margin: 0 auto;
}
.search-box {
  position: relative; display: flex; align-items: center;
}
.search-icon-svg {
  position: absolute; left: 14px;
  color: var(--gold); pointer-events: none;
  width: 18px; height: 18px;
}
/* Lucide SVG global size */
[data-lucide] { display: inline-flex; }
i[data-lucide] svg, i[data-lucide] { width: 1em; height: 1em; }
#searchInput {
  width: 100%;
  padding: 13px 48px 13px 44px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#searchInput:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,168,67,.15), inset 0 0 20px rgba(212,168,67,.04);
}
#searchInput::placeholder { color: var(--text3); }
.search-clear {
  position: absolute; right: 14px;
  background: none; border: none; color: var(--text3);
  cursor: pointer; padding: 4px;
  display: none; align-items: center; justify-content: center;
}
.search-clear svg { width: 18px; height: 18px; }
.search-clear.visible { display: flex; }
.search-clear:hover { color: var(--text); }

/* Search stats */
#searchStats {
  font-size: 10px; color: var(--text3);
  text-align: center; min-height: 16px;
  font-family: 'Press Start 2P', monospace;
  letter-spacing: .5px;
}

/* ── Filter tabs with arrow nav ── */
.filter-nav {
  display: flex; align-items: center; gap: 6px;
  position: relative;
}
.filter-arrow {
  flex-shrink: 0;
  width: 30px; height: 30px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  color: var(--text2);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .18s;
  font-size: 16px;
}
.filter-arrow:hover { border-color: var(--gold3); color: var(--gold); }
.filter-arrow.hidden { opacity: 0; pointer-events: none; }
.filter-arrow svg { width: 16px; height: 16px; }

.filter-scroll {
  flex: 1; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-tabs {
  display: flex; gap: 6px; padding: 2px;
  width: max-content;
}
.filter-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text2);
  font-size: 12px; font-family: 'Inter', sans-serif; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .18s, color .18s, background .18s, box-shadow .18s;
}
.filter-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.filter-btn:hover { border-color: var(--gold3); color: var(--gold); }
.filter-btn.active {
  background: linear-gradient(135deg, rgba(212,168,67,.2), rgba(212,168,67,.05));
  border-color: var(--gold);
  color: var(--gold2);
  box-shadow: 0 0 10px rgba(212,168,67,.15);
}
.filter-count {
  background: var(--bg);
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--text3);
  min-width: 20px;
  text-align: center;
}
.filter-btn.active .filter-count { color: var(--gold3); }

/* ── Category sections ── */
.results-container { padding-top: 20px; }

.category-section {
  margin-bottom: 28px;
  animation: fadeIn .3s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.category-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.cat-icon { font-size: 20px; }
.cat-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(9px, 2vw, 12px);
  color: var(--gold);
}
.cat-count {
  margin-left: auto;
  font-size: 11px; color: var(--text3);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 2px 10px;
}

/* ── Item grid ── */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}

/* ── Item card ── */
.item-card {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color .18s, background .18s, box-shadow .18s;
  position: relative;
}
.item-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
  border-radius: var(--radius) 0 0 var(--radius);
  transition: background .18s;
}
.item-card:hover {
  border-color: var(--gold3);
  background: var(--bg3);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.item-card:hover::before { background: var(--gold); }
.item-card.expanded { border-color: var(--gold); background: var(--bg3); }
.item-card.expanded::before { background: var(--gold2); }

/* card-main: the clickable row inside each card */
.card-main {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  min-width: 0;
}

/* item image */
.item-img-wrap {
  flex-shrink: 0;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}
.item-img-wrap img {
  width: 32px; height: 32px;
  object-fit: contain;
  image-rendering: pixelated;
}
.item-img-wrap .img-placeholder {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  color: var(--text3);
}
.item-img-wrap .img-placeholder svg {
  width: 22px; height: 22px;
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.item-img-wrap .img-loading {
  width: 32px; height: 32px;
  border: none;
  border-radius: 4px;
  background: linear-gradient(
    90deg, var(--panel) 25%, rgba(212,168,67,.14) 50%, var(--panel) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* item info */
.item-info { flex: 1; min-width: 0; }
.item-name {
  font-size: 13px; font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.item-id {
  font-size: 11px; color: var(--text3);
  font-family: 'Press Start 2P', monospace;
  margin-top: 2px;
}
.item-desc {
  font-size: 11px; color: var(--text2);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* copy btn — sits between card-main and item-detail */
.copy-btn {
  display: flex; align-items: center; gap: 5px;
  margin: 0 12px 8px auto;
  width: fit-content;
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text3);
  padding: 4px 9px;
  font-size: 11px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
  white-space: nowrap;
}
.copy-btn svg { width: 13px; height: 13px; flex-shrink: 0; }
.copy-btn:hover { border-color: var(--gold3); color: var(--gold); background: rgba(212,168,67,.06); }
.copy-btn.copied { border-color: var(--green); color: var(--green); background: rgba(68,187,102,.06); }

/* ── Expanded detail panel ── */
.item-detail {
  display: none;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  flex-direction: column; gap: 8px;
}
.item-card.expanded .item-detail { display: flex; }

.detail-row { display: flex; gap: 8px; align-items: flex-start; }
.detail-label {
  font-size: 10px; color: var(--text3);
  font-family: 'Press Start 2P', monospace;
  min-width: 70px; flex-shrink: 0;
  margin-top: 1px;
}
.detail-val {
  font-size: 12px; color: var(--text2);
  line-height: 1.5;
}
.detail-val .highlight { color: var(--gold2); font-weight: 600; }

/* Large image in expanded */
.detail-img-large {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
}
.detail-img-large img {
  width: 64px; height: 64px;
  object-fit: contain;
  image-rendering: pixelated;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
}

/* ── No results ── */
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--text3);
}
.no-results-icon { font-size: 48px; margin-bottom: 16px; }
.no-results h3 {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px; color: var(--text2);
  margin-bottom: 8px;
}
.no-results p { font-size: 13px; }

/* ── Loading splash ── */
#loading {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  z-index: 999;
  transition: opacity .4s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.load-logo {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(12px, 3vw, 20px);
  background: linear-gradient(135deg, var(--gold2), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
}
.load-bar-wrap {
  width: 240px; height: 8px;
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.load-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold3), var(--gold2));
  border-radius: 4px;
  width: 0%;
  transition: width .2s;
}
.load-text {
  font-size: 11px; color: var(--text2);
  font-family: 'Press Start 2P', monospace;
}
.load-maple { font-size: 40px; animation: float 2s ease-in-out infinite; }

/* ── Scrolltop btn ── */
#scrollTop {
  position: fixed; bottom: 24px; right: 20px;
  width: 44px; height: 44px;
  background: var(--gold);
  color: var(--bg);
  border: none; border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(212,168,67,.4);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
#scrollTop svg { width: 22px; height: 22px; }
#scrollTop.visible { opacity: 1; pointer-events: auto; }
#scrollTop:hover { transform: scale(1.1); }

/* ── Category colors ── */
.cat-monsters .item-card:hover::before { background: var(--red); }
.cat-monsters .item-card.expanded::before { background: var(--red); }
.cat-monsters .cat-title { color: var(--red); }
.cat-monsters .item-id { color: #ff6666; }

.cat-skills .item-card:hover::before { background: var(--purple); }
.cat-skills .item-card.expanded::before { background: var(--purple); }
.cat-skills .cat-title { color: var(--purple); }
.cat-skills .item-id { color: #cc88ff; }

.cat-maps .item-card:hover::before { background: var(--cyan); }
.cat-maps .item-card.expanded::before { background: var(--cyan); }
.cat-maps .cat-title { color: var(--cyan); }
.cat-maps .item-id { color: #66eeff; }

.cat-npcs .item-card:hover::before { background: var(--green); }
.cat-npcs .item-card.expanded::before { background: var(--green); }
.cat-npcs .cat-title { color: var(--green); }
.cat-npcs .item-id { color: #66dd88; }

.cat-pets .item-card:hover::before { background: #ff88cc; }
.cat-pets .item-card.expanded::before { background: #ff88cc; }
.cat-pets .cat-title { color: #ff88cc; }
.cat-pets .item-id { color: #ffaadd; }

.cat-weapons .cat-title { color: #ff8844; }
.cat-weapons .item-id { color: #ffaa66; }
.cat-equips .cat-title { color: #88aaff; }
.cat-equips .item-id { color: #aabbff; }
.cat-use .cat-title { color: #44dd88; }
.cat-use .item-id { color: #66ffaa; }
.cat-jobs .cat-title { color: var(--gold); }

.cat-portals .cat-title { color: #44ffcc; }
.cat-portals .item-id { color: #66ffdd; }
.cat-etc .cat-title { color: #ffcc44; }
.cat-etc .item-id { color: #ffdd66; }
.cat-appearance .cat-title { color: #ff88dd; }
.cat-appearance .item-id { color: #ffaaee; }
.cat-appearance .item-card:hover::before { background: #ff88dd; }
.cat-appearance .item-card.expanded::before { background: #ff88dd; }

/* ── Highlight in search ── */
mark {
  background: rgba(212,168,67,.3);
  color: var(--gold2);
  border-radius: 2px;
  padding: 0 1px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .items-grid { grid-template-columns: 1fr; }
  .card-main { padding: 8px 10px; }
  .item-img-wrap { width: 36px; height: 36px; }
  .item-img-wrap img { width: 28px; height: 28px; }
}

@media (max-width: 400px) {
  h1 { font-size: 12px; }
  .filter-btn { padding: 6px 10px; font-size: 11px; }
}

@media (max-width: 480px) {
  .tips-bar { display: none; }
}


/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 16px; padding: 8px;
}
.page-btn {
  padding: 6px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px; cursor: pointer;
  font-family: 'Press Start 2P', monospace;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--gold3); color: var(--gold); }
.page-btn.active { border-color: var(--gold); color: var(--gold2); background: rgba(212,168,67,.1); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Tips bar ── */
.tips-bar {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  margin: 12px 0 0;
  background: rgba(212,168,67,.06);
  border: 1px solid rgba(212,168,67,.15);
  border-radius: var(--radius);
  font-size: 11px; color: var(--text2);
  flex-wrap: wrap; gap: 12px;
}
.tip { display: flex; align-items: center; gap: 4px; }
kbd {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: 'Press Start 2P', monospace;
  color: var(--gold3);
}

/* ── Toast notification ── */
#toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(12px);
  background: var(--panel);
  border: 1px solid var(--gold3);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--gold2);
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,.5);
  opacity: 0; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 200;
}
#toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

/* ── Cat-icon SVG sizing ── */
.cat-icon svg { width: 20px; height: 20px; }
