/* ===========================================================
   RO Database - style
   =========================================================== */
:root {
  /* โทนสว่าง ฟ้าอ่อน ให้เข้ากับเว็บหลัก NEX-RO */
  --bg: #eef6ff;
  --bg2: #f4f9ff;
  --panel: #ffffff;
  --panel2: #e3f0ff;
  --line: #d3e3f7;
  --text: #1d2b3f;
  --muted: #5f7390;
  --gold: #1e88ff;      /* สีเน้นหลัก (เดิมทอง -> ฟ้า) */
  --gold2: #0b6fe0;
  --navy: #0a4f9d;
  --blue2: #0b6fe0;
  --navy2: #073c7a;
  --red: #e8574a;
  --green: #2fb56b;
  --blue: #1e88ff;
  --purple: #7a5cff;
  --shadow: 0 8px 24px rgba(10, 79, 157, .10);
  --radius: 12px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Poppins", "Noto Sans Thai", "Sarabun", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
img { image-rendering: pixelated; image-rendering: crisp-edges; }
button, input, select { font: inherit; }

/* ---------- header (sub-nav ของ database ใต้เมนูหลัก) ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(10, 79, 157, .06);
}
.site-header .inner {
  max-width: 1280px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 12px; height: 56px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue), var(--gold2));
  display: grid; place-items: center; color: #fff; font-weight: 900; font-size: .8rem;
  box-shadow: 0 4px 10px rgba(30,136,255,.35);
}
.brand small { display: block; font-size: .7rem; color: var(--muted); font-weight: 400; line-height: 1; }
.nav { display: flex; gap: 2px; margin-left: auto; }
.nav a { color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { color: var(--navy); background: var(--panel2); text-decoration: none; }
.nav a.active { color: var(--blue2); background: var(--panel2); font-weight: 600; }
.nav a.back { color: var(--navy); border: 1px solid var(--line); margin-left: 6px; }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 6px 10px; }

/* ---------- layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.breadcrumb { color: var(--muted); font-size: .9rem; margin-bottom: 12px; }
.breadcrumb a { color: var(--muted); }
.page-title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.page-title h1 { margin: 0; font-size: 1.6rem; }
.page-title .sub { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.stat .v { font-size: 1.5rem; font-weight: 800; color: var(--gold2); line-height: 1.1; }
.stat .l { color: var(--muted); font-size: .85rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.section-title {
  display: flex; align-items: center; gap: 10px; margin: 28px 0 12px;
  font-size: 1.25rem; font-weight: 700;
}
.section-title .en { color: var(--muted); font-weight: 400; font-size: .95rem; letter-spacing: .15em; }
.section-title .count { margin-left: auto; color: var(--muted); font-size: .9rem; font-weight: 400; }
.region-title { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-weight: 700; color: var(--navy); }
.region-title .en { color: var(--muted); font-weight: 400; font-size: .9rem; }
.region-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- forms ---------- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.filters label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.filters .wide { grid-column: span 2; }
.input, .select {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; outline: none;
}
.input:focus, .select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,136,255,.15); }
.range { display: flex; align-items: center; gap: 6px; }
.btn {
  background: linear-gradient(180deg, var(--gold), var(--gold2)); color: #fff; border: 0;
  border-radius: 8px; padding: 9px 16px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 12px rgba(30, 136, 255, .3);
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); font-weight: 500; box-shadow: none; }
.btn-row { display: flex; gap: 8px; }
.chk { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; cursor: pointer; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.5; border: 1px solid transparent; }
.badge.mvp { background: rgba(232, 87, 74, .12); color: var(--red); border-color: rgba(232, 87, 74, .4); }
.badge.boss { background: rgba(122, 92, 255, .12); color: var(--purple); border-color: rgba(122, 92, 255, .4); }
.badge.dun { background: rgba(30, 136, 255, .12); color: var(--blue2); border-color: rgba(30, 136, 255, .4); }
.badge.town { background: rgba(47, 181, 107, .12); color: #1f8f52; border-color: rgba(47, 181, 107, .4); }
.badge.gray { background: var(--bg2); color: var(--muted); border-color: var(--line); }
.el { font-weight: 600; }
.el-Neutral { color: #5f7390; } .el-Water { color: #1e88ff; } .el-Earth { color: #a56f2d; }
.el-Fire { color: #e8574a; } .el-Wind { color: #1f9e5a; } .el-Poison { color: #8a4bd6; }
.el-Holy { color: #c99400; } .el-Dark { color: #5a3fb8; } .el-Ghost { color: #4f8ac9; } .el-Undead { color: #6b7a5a; }

/* ---------- map grid ---------- */
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.map-tile {
  position: relative; display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; color: var(--text); transition: transform .12s, border-color .12s;
}
.map-tile:hover { transform: translateY(-2px); border-color: var(--gold2); text-decoration: none; }
.map-tile.boss { border-color: rgba(232, 87, 74, .6); }
.map-tile.dun { border-color: rgba(30, 136, 255, .5); }
.map-tile.nolink { opacity: .75; }
.map-tile .thumb { aspect-ratio: 1; background: radial-gradient(circle at 50% 58%, #ffffff 0%, #eef6ff 55%, #dcebff 100%); display: grid; place-items: center; }
.map-tile .thumb { overflow: hidden; }
.map-tile .thumb img { width: 100%; height: 100%; object-fit: contain; image-rendering: auto; }
/* รูปมอนสเตอร์ในกริด: ไม่ขยายเกินขนาดจริง และไม่เต็มกรอบ */
.map-tile .thumb img[src*="monster/"], .map-tile .thumb img.mob { width: auto; height: auto; max-width: 58%; max-height: 58%; image-rendering: auto; filter: drop-shadow(0 6px 8px rgba(10, 79, 157, .18)); }
.mob-grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
.mob-grid .map-tile .thumb { aspect-ratio: 1 / .9; }
.map-tile.mini { border-color: rgba(122, 92, 255, .55); }
.map-tile .thumb img[src^="data:"] { width: 40px; height: 40px; }
.map-tile .thumb .noimg { color: var(--muted); font-size: .8rem; }
.map-tile .cap { padding: 8px 10px; }
.map-tile .cap .n { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.map-tile .cap .m { color: var(--muted); font-size: .75rem; font-family: Consolas, monospace; }
.map-tile .mobs { position: absolute; left: 6px; top: 6px; display: flex; flex-wrap: wrap; gap: 2px; max-width: 80%; }
.map-tile .mobs img { width: 26px; height: 26px; object-fit: contain; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
.map-tile .mobs .more { background: rgba(0,0,0,.6); color: #fff; font-size: .7rem; padding: 2px 5px; border-radius: 6px; align-self: center; }
.map-tile .flag { position: absolute; right: 6px; top: 6px; display: flex; gap: 4px; }
.map-tile .cnt { float: right; color: var(--gold2); font-size: .72rem; margin-left: 6px; }

/* tooltip */
.tip {
  position: fixed; z-index: 100; pointer-events: none; display: none;
  background: #fff; border: 1px solid var(--blue); border-radius: 8px; padding: 8px 10px;
  box-shadow: var(--shadow); min-width: 180px; max-width: 320px; font-size: .85rem;
}
.tip .t { color: var(--navy); font-weight: 700; margin-bottom: 4px; }
.tip ul { list-style: none; margin: 0; padding: 0; }
.tip li { display: flex; gap: 8px; align-items: center; padding: 1px 0; }
.tip li img { width: 22px; height: 22px; object-fit: contain; }
.tip li .a { color: var(--muted); margin-left: auto; }

/* ---------- monster cards ---------- */
.mob-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.mob-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.mob-card.mvp { border-color: rgba(232, 87, 74, .5); }
.mob-card.boss { border-color: rgba(122, 92, 255, .5); }
.mob-head { display: flex; gap: 12px; align-items: flex-start; }
.mob-head .sprite {
  width: 96px; height: 96px; flex: none; display: grid; place-items: center; border-radius: 8px;
  background: radial-gradient(circle at 50% 70%, #ffffff 0%, #dcebff 75%); border: 1px solid var(--line); overflow: hidden;
}
.mob-head .sprite img { max-width: 92px; max-height: 92px; object-fit: contain; cursor: zoom-in; }
.mob-head .sprite.big { width: 160px; height: 160px; }
.mob-head .sprite.big img { max-width: 156px; max-height: 156px; }
.mob-head .info { flex: 1; min-width: 0; }
.mob-head .id { color: var(--muted); font-size: .8rem; font-family: Consolas, monospace; }
.mob-head .name { font-size: 1.15rem; font-weight: 700; margin: 0; }
.mob-head .name a { color: var(--text); }
.mob-head .aegis { color: var(--muted); font-size: .78rem; letter-spacing: .05em; }
.mob-head .attrs { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: .85rem; color: var(--muted); }
.mob-head .attrs b { color: var(--text); font-weight: 600; }
.lv { background: var(--panel2); border: 1px solid var(--line); color: var(--navy); border-radius: 6px; padding: 0 8px; font-weight: 700; font-size: .85rem; }

.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; font-size: .85rem; }
.kv div { display: flex; justify-content: space-between; gap: 6px; background: var(--bg2); padding: 3px 8px; border-radius: 6px; white-space: nowrap; min-width: 0; }
.kv b { overflow: hidden; text-overflow: ellipsis; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; }
.kv.six { grid-template-columns: repeat(6, 1fr); }
.kv.six div { justify-content: center; gap: 4px; }

.sub-h { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 4px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: .8rem; font-family: Consolas, monospace; color: var(--blue); }
.chip:hover { border-color: var(--blue); text-decoration: none; }
.chip.more { color: var(--muted); font-family: inherit; cursor: pointer; }

.drops { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 10px; font-size: .85rem; }
.drop { min-width: 0; display: flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: 6px; color: var(--text); }
.drop:hover { background: var(--bg2); text-decoration: none; }
.drop img { width: 24px; height: 24px; object-fit: contain; flex: none; }
.drop .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop .r { color: var(--muted); font-family: Consolas, monospace; font-size: .8rem; }
.drop.card .n { color: var(--purple); }
.drop.mvp .r { color: var(--red); }

/* ---------- item cards ---------- */
.item-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; }
.item-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; gap: 12px; }
.item-card .icon { width: 56px; height: 56px; flex: none; display: grid; place-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; }
.item-card .icon img { max-width: 48px; max-height: 48px; object-fit: contain; }
.item-card .body { flex: 1; min-width: 0; }
.item-card .name { font-weight: 700; margin: 0; }
.item-card .name a { color: var(--text); }
.item-card .meta { color: var(--muted); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.item-card .script { background: #f3f7fc; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-family: Consolas, monospace; font-size: .78rem; white-space: pre-wrap; color: #0b4a8f; margin-top: 6px; max-height: 120px; overflow: auto; }
.item-card .item-kv { grid-template-columns: repeat(3, 1fr); margin-top: 6px; }
.item-card .item-kv .wide { grid-column: 1 / -1; white-space: normal; }
.item-card .item-kv .wide b { white-space: normal; text-align: right; }
.item-card .item-desc { margin-top: 8px; padding: 8px 10px; background: #f6faff; border-left: 3px solid var(--blue); border-radius: 0 8px 8px 0; white-space: pre-wrap; font-size: .88rem; line-height: 1.5; color: var(--text); }
.item-card .script-box { margin-top: 6px; }
.item-card .script-box summary { cursor: pointer; font-size: .78rem; color: var(--muted); user-select: none; }
.item-card .script-box .script { margin-top: 4px; }
.item-card .dropby { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.item-card .dropby a { display: inline-flex; align-items: center; gap: 4px; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px 1px 2px; font-size: .78rem; color: var(--text); }
.item-card .dropby img { width: 22px; height: 22px; object-fit: contain; }
.item-card .dropby .r { color: var(--muted); }

/* ---------- map detail ---------- */
.map-detail { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }
.map-detail .img { background: #e3f0ff; border: 1px solid var(--line); border-radius: var(--radius); display: grid; place-items: center; padding: 8px; }
.map-detail .img img { max-width: 100%; image-rendering: auto; }
.map-detail h2 { margin: 0 0 4px; }
.map-detail .code { color: var(--muted); font-family: Consolas, monospace; }
.spawn-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-top: 10px; }
.spawn-table th, .spawn-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.spawn-table th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.spawn-table img { width: 40px; height: 40px; object-fit: contain; vertical-align: middle; }
.spawn-table td a { color: var(--text); font-weight: 600; }
.npc-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* ---------- pagination ---------- */
.pager { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.pager a, .pager span { padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: .9rem; }
.pager a:hover { border-color: var(--gold2); text-decoration: none; }
.pager .cur { background: var(--blue); color: #fff; border-color: var(--blue); font-weight: 700; }
.pager .dots { border: 0; background: none; color: var(--muted); }
.result-line { color: var(--muted); font-size: .9rem; margin: 14px 0 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.result-line b { color: var(--text); }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(7, 44, 90, .55); z-index: 200; display: none; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow: auto; }
.modal-bg.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; max-width: 900px; width: 100%; padding: 18px; position: relative; box-shadow: var(--shadow); }
.modal .close { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--muted); font-size: 1.6rem; cursor: pointer; line-height: 1; }
.modal .close:hover { color: var(--text); }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }

/* ---------- home ---------- */
.hero { text-align: center; padding: 50px 10px 30px; }
.hero h1 { font-size: 2.2rem; margin: 0 0 6px; color: var(--navy); font-weight: 800; }
.hero p { color: var(--muted); margin: 0 0 18px; }
.hero form { display: flex; gap: 8px; max-width: 620px; margin: 0 auto; }
.cards3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 24px; }
.cards3 a { display: block; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.cards3 a:hover { border-color: var(--gold2); text-decoration: none; }
.cards3 .ic { font-size: 1.8rem; }
.cards3 h3 { margin: 6px 0 2px; }
.cards3 p { margin: 0; color: var(--muted); font-size: .9rem; }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.note { font-size: .85rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; font-size: .85rem; color: var(--muted); }
.legend .sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 2px solid; vertical-align: -2px; margin-right: 4px; }

footer.db-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; text-align: center; padding: 16px; }

@media (max-width: 760px) {
  .nav { display: none; position: absolute; top: 56px; left: 0; right: 0; background: #fff; flex-direction: column; padding: 8px; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .menu-btn { display: block; }
  .map-detail { grid-template-columns: 1fr; }
  .mob-list { grid-template-columns: 1fr; }
  .drops { grid-template-columns: 1fr; }
  .item-card .item-kv { grid-template-columns: repeat(2, 1fr); }
  .kv.six { grid-template-columns: repeat(3, 1fr); }
  .modal .grid2 { grid-template-columns: 1fr; }
  .filters .wide { grid-column: span 1; }
}
