/* ═══════════════════════════════════════════════════════════════
   ธีมหลัก — ทุ่งพรอนเทร่า + หน้าต่าง UI สไตล์ Ragnarok Online
   ═══════════════════════════════════════════════════════════════ */
:root {
  --sky-top: #58b8ee;
  --sky-mid: #9fdcff;
  --sky-low: #d9f2ff;
  --grass: #6fc24a;
  --grass-dark: #3f8f2c;

  --ro-frame: #5d4a34;          /* ขอบหน้าต่าง */
  --ro-frame-lt: #b79a72;
  --ro-bg: #f4ebd8;             /* พื้นหน้าต่าง */
  --ro-bg-alt: #e6d8bd;
  --ro-bar-1: #6a90c8;          /* แถบหัวหน้าต่าง */
  --ro-bar-2: #2f4d7e;
  --ink: #3a2a1c;
  --ink-soft: #6b5741;

  --gold: #ffd75e;
  --gold-dp: #e09a1f;
  --hp: #e04a4a;
  --hp-lt: #ff8a6d;
  --sp: #4a8fe0;
  --exp: #6fd44a;
  --warn: #ffb020;
  --down: #d2384f;

  --shadow-win: 0 6px 0 #00000022, 0 14px 30px #0000002e;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-th: "Kanit", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }   /* กดเมนูแล้วไหลลงไปนุ่ม ๆ */
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  font-family: var(--font-th);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 42%, var(--sky-low) 72%, #cdeeb4 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--gold); color: var(--ink); }

/* ═══════ ฉากหลัง ═══════ */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.sun {
  position: absolute; top: 4vh; right: 8vw; width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, #fffbe6 0 38%, #ffe89a 55%, #ffd75e00 72%);
  box-shadow: 0 0 90px 30px #ffe89a66;
  animation: sun-pulse 6s ease-in-out infinite;
}
@keyframes sun-pulse { 0%,100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.08); opacity: 1; } }

.clouds { position: absolute; inset: 0; }
.cloud {
  position: absolute; width: 190px; height: 56px; background: #ffffffdd; border-radius: 60px;
  filter: drop-shadow(0 6px 10px #4aa8d820);
}
.cloud::before, .cloud::after {
  content: ""; position: absolute; background: #ffffffdd; border-radius: 50%;
}
.cloud::before { width: 84px; height: 84px; top: -36px; left: 30px; }
.cloud::after  { width: 60px; height: 60px; top: -24px; right: 32px; }
.cloud--1 { top: 8vh;  left: -25%; transform: scale(.9);  animation: drift 58s linear infinite; }
.cloud--2 { top: 20vh; left: -35%; transform: scale(1.3); animation: drift 84s linear infinite 6s; opacity: .8; }
.cloud--3 { top: 34vh; left: -20%; transform: scale(.65); animation: drift 44s linear infinite 12s; opacity: .7; }
.cloud--4 { top: 52vh; left: -30%; transform: scale(1.05); animation: drift 96s linear infinite 3s; opacity: .55; }
@keyframes drift { to { transform: translateX(160vw); } }

.hills { position: absolute; left: 0; right: 0; bottom: 0; height: 42vh; }
.hill { position: absolute; bottom: 0; left: -10%; width: 120%; border-radius: 50% 50% 0 0 / 100% 100% 0 0; }
.hill--far  { height: 30vh; background: linear-gradient(180deg, #8fd06a, #63ad46); opacity: .55; transform: translateX(-4%); }
.hill--near { height: 20vh; background: linear-gradient(180deg, #7ac74f, #4c9c33); opacity: .8; transform: translateX(6%); }

.field-grass {
  position: absolute; left: 0; right: 0; bottom: 0; height: 90px;
  background: linear-gradient(180deg, #6fc24a, #3f8f2c);
  box-shadow: inset 0 6px 0 #ffffff26;
}
.grass-row { position: absolute; left: 0; right: 0; top: -14px; height: 22px; display: flex; }
.grass-row i {
  flex: 1 0 auto; width: 10px; height: 22px; background: var(--grass-dark);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  transform-origin: bottom center;
  animation: sway 3.4s ease-in-out infinite;
}
@keyframes sway { 0%,100% { transform: rotate(-6deg) scaleY(1); } 50% { transform: rotate(7deg) scaleY(1.08); } }

.field-canvas { position: fixed; inset: 0; z-index: 1; pointer-events: none; }

/* ═══════ หน้าโหลด ═══════ */
.loading {
  position: fixed; inset: 0; z-index: 999;
  background: radial-gradient(ellipse at center, #2c3f63 0%, #16223a 70%);
  display: grid; place-items: center;
  transition: opacity .6s ease, visibility .6s;
}
.loading.is-done { opacity: 0; visibility: hidden; }
.loading__inner { text-align: center; width: min(420px, 82vw); }
.loading__poring { display: grid; place-items: center; height: 110px; }
.loading__title {
  font-family: var(--font-pixel); font-size: 13px; color: var(--gold);
  letter-spacing: 2px; margin: 12px 0 14px; text-shadow: 0 3px 0 #00000080;
  animation: blink-soft 1.2s steps(2) infinite;
}
@keyframes blink-soft { 50% { opacity: .45; } }
.loading__bar {
  height: 20px; border: 3px solid #0d1526; border-radius: 4px;
  background: #0b1220; overflow: hidden;
  box-shadow: inset 0 2px 6px #000, 0 0 0 2px #6a90c8;
}
.loading__fill {
  height: 100%; width: 0%;
  background: repeating-linear-gradient(45deg, #ffd75e 0 10px, #ffb02e 10px 20px);
  box-shadow: 0 0 12px #ffd75e99; transition: width .25s ease;
}
.loading__tip { margin-top: 12px; color: #cfe0ff; font-size: 13px; min-height: 20px; }

/* ═══════ หน้าต่างสไตล์ RO ═══════ */
.ro-window {
  position: relative;
  background: var(--ro-bg);
  border: 2px solid var(--ro-frame);
  border-radius: 6px;
  box-shadow: var(--shadow-win), inset 0 0 0 2px #ffffffb0;
  overflow: hidden;
}
.ro-window__bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px;
  background: linear-gradient(180deg, var(--ro-bar-1), var(--ro-bar-2));
  border-bottom: 2px solid var(--ro-frame);
  box-shadow: inset 0 1px 0 #ffffff70, inset 0 -2px 4px #00000040;
}
.ro-window__title {
  font-family: var(--font-pixel); font-size: 9px; color: #fff;
  letter-spacing: .5px; text-shadow: 1px 1px 0 #00000090;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ro-window__btns { display: flex; gap: 4px; }
.ro-window__btns i {
  width: 11px; height: 11px; border-radius: 2px; background: linear-gradient(180deg, #f7e9c9, #c9ab7c);
  border: 1px solid #2c3c5c; box-shadow: inset 0 1px 0 #fff;
}
.ro-window__body { padding: 12px; }

/* ═══════ ส่วนหัว ═══════ */
.hero { position: relative; z-index: 2; text-align: center; padding: 26px 0 10px; }
.hero__badge {
  display: inline-block; font-family: var(--font-pixel); font-size: 8px; letter-spacing: 1px;
  color: #2f4d7e; background: linear-gradient(180deg, #fff5d6, #ffd98a);
  border: 2px solid #8a6b3a; border-radius: 999px; padding: 6px 14px;
  box-shadow: 0 3px 0 #00000030; margin-bottom: 14px;
  animation: badge-float 3s ease-in-out infinite;
}
@keyframes badge-float { 0%,100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-5px) rotate(1deg); } }

.logo { margin: 0 0 6px; line-height: 1; font-family: var(--font-pixel); }
.logo__text {
  position: relative; display: inline-block;
  font-size: clamp(24px, 6.2vw, 58px);
  background: linear-gradient(180deg, #fff6c9 0%, #ffd75e 42%, #e58f16 70%, #ffe9a8 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #6b3a12) drop-shadow(0 6px 10px #00000055);
  animation: logo-pop .9s cubic-bezier(.2,1.5,.4,1) both;
}
.logo__text::after { /* แสงกวาดผ่านตัวอักษร */
  content: attr(data-text); position: absolute; inset: 0;
  background: linear-gradient(100deg, #fff0 40%, #ffffffcc 50%, #fff0 60%);
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine-sweep 4.5s ease-in-out infinite;
}
@keyframes shine-sweep { 0%, 60% { background-position: 200% 0; } 100% { background-position: -100% 0; } }
@keyframes logo-pop { from { transform: scale(.4) translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.logo__dot {
  display: inline-block; font-size: clamp(12px, 2.4vw, 22px); color: #fff;
  text-shadow: 2px 2px 0 #2f4d7e, 0 0 12px #7ec8f2; margin-left: 4px;
  animation: logo-pop .9s .15s cubic-bezier(.2,1.5,.4,1) both;
}
.hero__sub {
  margin: 6px 0 20px; font-size: clamp(13px, 1.6vw, 17px); font-weight: 500; color: #12395c;
  text-shadow: 0 2px 0 #ffffffb0;
  animation: fade-up .8s .25s both;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.hero__status { width: min(640px, 94vw); margin: 0 auto; text-align: left; animation: fade-up .8s .35s both; }
.basic { display: flex; gap: 14px; align-items: center; }
.basic__avatar { display: grid; place-items: center; width: 76px; height: 76px; flex: 0 0 auto; }
.basic__info { flex: 1; min-width: 0; }
.basic__name { font-weight: 700; font-size: 16px; margin-bottom: 7px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.basic__job { font-family: var(--font-pixel); font-size: 8px; color: var(--ink-soft); }

/* แถบ HP/SP/EXP */
.bar { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.bar__label { font-family: var(--font-pixel); font-size: 8px; width: 26px; color: var(--ink-soft); }
.bar__track {
  position: relative; flex: 1; height: 15px;
  background: #4a3a2a; border: 2px solid #2c2016; border-radius: 3px; overflow: hidden;
  box-shadow: inset 0 2px 4px #00000080;
}
.bar__fill {
  height: 100%; width: 0;
  transition: width 1.1s cubic-bezier(.2,.9,.3,1);
  box-shadow: inset 0 1px 0 #ffffff80, inset 0 -4px 6px #00000040;
  position: relative;
}
.bar__fill::after { /* ประกายวิ่ง */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, #fff0 0%, #ffffff5c 50%, #fff0 100%);
  background-size: 60% 100%; background-repeat: no-repeat;
  animation: bar-shine 2.4s linear infinite;
}
@keyframes bar-shine { from { background-position: -60% 0; } to { background-position: 160% 0; } }
.bar--hp  .bar__fill { background: linear-gradient(180deg, var(--hp-lt), var(--hp)); }
.bar--sp  .bar__fill { background: linear-gradient(180deg, #8fc4ff, var(--sp)); }
.bar--exp .bar__fill { background: linear-gradient(180deg, #b6f58f, var(--exp)); }
.bar__text {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-pixel); font-size: 7px; color: #fff; text-shadow: 1px 1px 0 #000;
  letter-spacing: .5px;
}

.basic__stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.stat {
  text-align: center; padding: 8px 4px; border-radius: 5px;
  background: linear-gradient(180deg, #fffdf6, var(--ro-bg-alt));
  border: 2px solid var(--ro-frame-lt); box-shadow: 0 2px 0 #00000018;
}
.stat b { display: block; font-family: var(--font-pixel); font-size: 15px; line-height: 1.4; }
.stat span { font-size: 11px; color: var(--ink-soft); }
.stat--up b { color: #2f8c1f; } .stat--down b { color: var(--down); }
.stat--dev b { color: #c07a12; } .stat--total b { color: #2f4d7e; }

.hero__actions { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin: 16px 0 4px; animation: fade-up .8s .45s both; }
.ro-btn {
  /* ปุ่มมีข้อความไทย → ใช้ฟอนต์ไทย ไม่งั้นตัวเล็กจนอ่านไม่ออก */
  position: relative; font-family: var(--font-th); font-weight: 700; font-size: 13.5px; letter-spacing: 0;
  color: #3a2a1c; padding: 11px 16px; cursor: pointer;
  background: linear-gradient(180deg, #fff6d9 0%, #ffd98a 55%, #e8ac48 100%);
  border: 2px solid #7a5a2c; border-radius: 5px;
  box-shadow: 0 4px 0 #7a5a2c, 0 8px 14px #00000030, inset 0 1px 0 #ffffffcc;
  transition: transform .08s, box-shadow .08s, filter .2s;
}
.ro-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ro-btn:active { transform: translateY(4px); box-shadow: 0 0 0 #7a5a2c, inset 0 2px 6px #00000040; }
.ro-btn:disabled { filter: grayscale(.7); cursor: not-allowed; }
.ro-btn--alt { background: linear-gradient(180deg, #ffe4f1 0%, #ff9ac6 55%, #e05c96 100%); border-color: #93325f; box-shadow: 0 4px 0 #93325f, 0 8px 14px #00000030, inset 0 1px 0 #ffffffcc; }
.hero__clock { font-family: var(--font-th); font-weight: 600; font-size: 12.5px; color: #16416b; background: #ffffffa8; padding: 8px 10px; border-radius: 4px; border: 1px solid #ffffff; }

/* ═══════ ตัวกรอง ═══════ */
.filters {
  position: relative; z-index: 2; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  padding: 4px 0 6px; animation: fade-up .8s .55s both;
}
.chip {
  font-family: var(--font-th); font-weight: 600; font-size: 13px; color: #23405f;
  padding: 7px 15px; cursor: pointer;
  background: linear-gradient(180deg, #ffffff, #dfe9f5);
  border: 2px solid #7d93b3; border-radius: 999px;
  box-shadow: 0 3px 0 #7d93b360; transition: all .15s;
}
.chip:hover { transform: translateY(-2px); box-shadow: 0 5px 0 #7d93b360; }
.chip--on {
  color: #fff; background: linear-gradient(180deg, var(--ro-bar-1), var(--ro-bar-2));
  border-color: #1d3355; box-shadow: 0 3px 0 #1d3355, 0 0 14px #6a90c880;
}

/* ═══════ ตารางการ์ด ═══════ */
.grid {
  position: relative; z-index: 2;
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  margin: 18px 0 0;
}

.card { animation: card-in .55s cubic-bezier(.2,1.3,.4,1) both; transition: transform .18s ease, filter .18s; }
@keyframes card-in { from { opacity: 0; transform: translateY(26px) scale(.94); } to { opacity: 1; transform: none; } }
.card:hover { transform: translateY(-6px) scale(1.015); }
.card:hover .poring--hop { animation-duration: .6s; }
.card.is-hidden { display: none; }

.card__bar-extra { display: flex; gap: 5px; align-items: center; }
.card__lv { font-family: var(--font-pixel); font-size: 8px; color: #ffe9a8; text-shadow: 1px 1px 0 #00000090; }

.card__top { display: flex; gap: 12px; align-items: flex-start; }
.card__sprite { width: 82px; height: 82px; display: grid; place-items: center; flex: 0 0 auto; cursor: pointer; user-select: none; }
.card__head { flex: 1; min-width: 0; }
.card__name { font-weight: 700; font-size: 17px; line-height: 1.25; }
.card__nameth { font-size: 12px; color: var(--ink-soft); margin-bottom: 6px; }
.card__desc { font-size: 12.5px; line-height: 1.6; color: #4a382a; margin: 8px 0 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-pixel); font-size: 7.5px; letter-spacing: .5px;
  padding: 5px 8px; border-radius: 4px; border: 2px solid #0003;
  text-shadow: 1px 1px 0 #00000060; color: #fff;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.badge--up   { background: linear-gradient(180deg, #62c94a, #2f8c1f); animation: pulse-green 2s ease-in-out infinite; }
.badge--warn { background: linear-gradient(180deg, #ffc857, #d98a10); }
.badge--down { background: linear-gradient(180deg, #f2607a, #b32238); animation: pulse-red 1.1s ease-in-out infinite; }
.badge--dev  { background: linear-gradient(180deg, #a99b86, #6f6252); }
.badge--arch { background: linear-gradient(180deg, #8fa2bd, #4c5f79); }
.badge--unknown { background: linear-gradient(180deg, #9fb0c4, #5d7186); }
@keyframes pulse-green { 0%,100% { box-shadow: 0 0 0 0 #62c94a60; } 50% { box-shadow: 0 0 0 7px #62c94a00; } }
@keyframes pulse-red   { 0%,100% { box-shadow: 0 0 0 0 #f2607a80; } 50% { box-shadow: 0 0 0 8px #f2607a00; } }

.card__meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.ping {
  font-family: var(--font-pixel); font-size: 7.5px; line-height: 1.6; color: var(--ink-soft);
  background: #fff8; padding: 5px 7px; border-radius: 4px; border: 1px solid #0001;
  max-width: 100%; overflow-wrap: anywhere;
}
.ping--err { font-family: var(--font-th); font-size: 11px; font-weight: 500; color: #9c2b3c; background: #ffe9ec; border-color: #e3b6bd; }

.card__bars { margin: 10px 0 8px; }
.card__spark { display: flex; align-items: flex-end; gap: 2px; height: 26px; margin: 8px 0 10px; padding: 3px; background: #3a2a1c14; border-radius: 4px; }
.card__spark i {
  flex: 1; min-width: 2px; border-radius: 1px; background: #2f8c1f;
  transform-origin: bottom; animation: spark-in .5s ease both;
}
.card__spark i.is-empty { background: #b0a48e40; }
.card__spark i.is-bad { background: var(--down); }
.card__spark i.is-warn { background: var(--warn); }
@keyframes spark-in { from { transform: scaleY(.05); } to { transform: scaleY(1); } }

.tags { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.tag {
  font-size: 10.5px; font-weight: 500; padding: 3px 8px; border-radius: 999px;
  background: linear-gradient(180deg, #fff, #e8dcc2); border: 1px solid #c3ab84; color: #5a4630;
}

.card__foot { display: flex; gap: 8px; align-items: center; }
.card__link {
  flex: 1; text-align: center; text-decoration: none;
  font-family: var(--font-pixel); font-size: 8px; padding: 10px;
  color: #16324f; border-radius: 5px;
  background: linear-gradient(180deg, #ffffff, #cfe0f5);
  border: 2px solid #4a6b96; box-shadow: 0 3px 0 #4a6b96, inset 0 1px 0 #fff;
  transition: transform .1s, box-shadow .1s, filter .15s;
}
.card__link:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 4px 0 #4a6b96; }
.card__link:active { transform: translateY(3px); box-shadow: 0 0 0 #4a6b96; }
.card__link--off { pointer-events: none; filter: grayscale(1) opacity(.6); }

/* การ์ดที่ล่ม: สั่น + ซีด */
.card.is-down .ro-window { filter: saturate(.55); border-color: #7a5a5a; }
.card.is-down .ro-window__bar { background: linear-gradient(180deg, #9c5a68, #5c2634); }
.card.is-down { animation: card-in .55s cubic-bezier(.2,1.3,.4,1) both, card-shake 5s ease-in-out 1s infinite; }
@keyframes card-shake {
  0%, 88%, 100% { transform: translate(0, 0) rotate(0); }
  90% { transform: translate(-3px, 1px) rotate(-.4deg); }
  92% { transform: translate(3px, -1px) rotate(.4deg); }
  94% { transform: translate(-2px, 0) rotate(-.2deg); }
  96% { transform: translate(2px, 1px) rotate(.2deg); }
}
.card.is-mvp .ro-window__bar { background: linear-gradient(180deg, #e0b34a, #9c6a12); }
.card.is-mvp .ro-window { box-shadow: var(--shadow-win), inset 0 0 0 2px #ffffffb0, 0 0 22px #ffd75e70; }
.card.is-mvp .ro-window::before { /* มงกุฎ MVP */
  content: "★ MVP"; position: absolute; top: 0; right: 0; z-index: 3;
  font-family: var(--font-pixel); font-size: 7px; color: #4a3000;
  background: linear-gradient(180deg, #fff0b8, #ffcc3d);
  padding: 4px 7px; border-radius: 0 0 0 6px; border-left: 2px solid #8a6b1a; border-bottom: 2px solid #8a6b1a;
  animation: mvp-glow 1.8s ease-in-out infinite;
}
@keyframes mvp-glow { 0%,100% { box-shadow: 0 0 0 #ffd75e00; } 50% { box-shadow: 0 0 14px #ffd75e; } }
.card.is-dev .ro-window__bar { background: linear-gradient(180deg, #a08f74, #5f523f); }
.card.is-dev .card__spark { display: none; }   /* ยังไม่ deploy ก็ไม่มีประวัติให้วาด */
.card.is-archived .card__spark { display: none; }
.card.is-archived .ro-window { filter: saturate(.35); }
.card.is-archived .ro-window__bar { background: linear-gradient(180deg, #7d8fa8, #3f4d63); }

/* ═══════ กล่องแชต/ล็อก ═══════ */
.chatbox {
  position: fixed; left: 14px; bottom: 14px; z-index: 6;
  width: min(330px, 88vw);
  background: #0e1a2ce8; border-color: #24405f;
  box-shadow: 0 10px 30px #00000060, inset 0 0 0 2px #ffffff18;
  transition: transform .3s cubic-bezier(.3,1.2,.4,1);
}
.chatbox.is-min { transform: translateY(calc(100% - 34px)); }
.chatbox.has-new .ro-window__bar { animation: chat-new 1.4s ease-in-out infinite; }
@keyframes chat-new {
  0%, 100% { background: linear-gradient(180deg, #3d6091, #1d3355); }
  50%      { background: linear-gradient(180deg, #6a90c8, #35507e); }
}
.chatbox .ro-window__bar { background: linear-gradient(180deg, #3d6091, #1d3355); }
.chatbox__toggle {
  width: 22px; height: 18px; line-height: 1; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, #6a90c8, #2f4d7e); border: 1px solid #16283f; border-radius: 3px;
  font-family: var(--font-pixel); font-size: 8px;
}
.chatbox__body { height: 158px; overflow-y: auto; padding: 8px 10px; font-size: 12px; scrollbar-width: thin; }
.chatbox__body::-webkit-scrollbar { width: 6px; }
.chatbox__body::-webkit-scrollbar-thumb { background: #4a6b96; border-radius: 3px; }
.log { margin: 0 0 4px; line-height: 1.5; color: #cfe0ff; animation: log-in .3s ease both; word-break: break-word; }
@keyframes log-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.log b { color: #ffd75e; font-weight: 600; }
.log--ok b { color: #8ce86b; }
.log--bad { color: #ffb3c0; } .log--bad b { color: #ff6b85; }
.log--sys { color: #8fd8ff; }
.log time { color: #7d93b3; font-size: 10px; margin-right: 5px; }

/* ═══════ เอฟเฟกต์ลอย ═══════ */
.dmg {
  position: fixed; z-index: 50; pointer-events: none;
  font-family: var(--font-pixel); font-size: 15px; color: #fff;
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  animation: dmg-float .95s cubic-bezier(.2,.8,.4,1) forwards;
}
.dmg--crit { color: #ffd75e; font-size: 19px; }
.dmg--heal { color: #8ce86b; }
.dmg--miss { color: #cfd8e6; font-size: 12px; }
@keyframes dmg-float {
  0%   { transform: translate(-50%, 0) scale(.5); opacity: 0; }
  18%  { transform: translate(-50%, -26px) scale(1.25); opacity: 1; }
  40%  { transform: translate(-50%, -34px) scale(1); }
  100% { transform: translate(-50%, -78px) scale(.9); opacity: 0; }
}
.ring {
  position: fixed; z-index: 49; pointer-events: none; width: 20px; height: 20px;
  border: 3px solid #ffd75e; border-radius: 50%;
  animation: ring-burst .7s ease-out forwards;
}
@keyframes ring-burst {
  from { transform: translate(-50%, -50%) scale(.3); opacity: 1; }
  to   { transform: translate(-50%, -50%) scale(5); opacity: 0; }
}
.toast {
  position: fixed; left: 50%; top: 18px; z-index: 60; transform: translateX(-50%);
  font-family: var(--font-pixel); font-size: 9px; color: #fff8dc;
  background: linear-gradient(180deg, #3d6091, #1d3355);
  border: 2px solid #ffd75e; border-radius: 6px; padding: 10px 16px;
  box-shadow: 0 8px 20px #00000060;
  animation: toast-in .35s cubic-bezier(.2,1.4,.4,1), toast-out .4s 2.6s forwards;
}
@keyframes toast-in { from { transform: translate(-50%, -40px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
@keyframes toast-out { to { transform: translate(-50%, -30px); opacity: 0; } }

/* ═══════ ท้ายหน้า ═══════ */
.footer { position: relative; z-index: 2; text-align: center; padding: 24px 16px 120px; color: #1c3d5c; font-size: 12px; }
.footer__line { height: 3px; width: min(560px, 80vw); margin: 0 auto 16px; border-radius: 3px; background: linear-gradient(90deg, #ffffff00, #ffffffcc, #ffffff00); }
.footer__small { font-size: 10.5px; opacity: .7; margin-top: 6px; }

/* ═══════ จอเล็ก ═══════ */
@media (max-width: 640px) {
  .hero { padding-top: 26px; }
  .grid { grid-template-columns: 1fr; }
  .basic__stats { grid-template-columns: repeat(2, 1fr); }
  .chatbox { width: calc(100vw - 28px); }
  .footer { padding-bottom: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  .cloud, .sun, .grass-row i, .card, .badge--up, .badge--down, .hero__badge, .logo__text, .logo__text::after, .bar__fill::after { animation: none !important; }
  .card:hover { transform: none; }
}

/* ═══════════════════════════════════════════════════════════════
   เมนูด้านบน (ติดหนึบ) + โครงหน้าเป็นส่วน ๆ
   ═══════════════════════════════════════════════════════════════ */
body { padding-top: 62px; }        /* เว้นที่ให้เมนูที่ลอยอยู่ */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px clamp(10px, 3vw, 26px);
  background: linear-gradient(180deg, #4a6fa5f2, #24406bf5);
  border-bottom: 2px solid #16283f;
  box-shadow: inset 0 1px 0 #ffffff55, 0 4px 18px #0000003d;
  backdrop-filter: blur(6px);
  transition: padding .22s ease, background .22s ease, box-shadow .22s ease;
}
/* เลื่อนลงแล้วเมนูหดลงนิดหนึ่ง ให้รู้สึกว่าตามมาด้วย */
.nav.is-stuck {
  padding-top: 5px;
  padding-bottom: 5px;
  background: linear-gradient(180deg, #3c5d8ffa, #1b3357fd);
  box-shadow: inset 0 1px 0 #ffffff55, 0 6px 22px #00000059;
}

.nav__brand { display: flex; align-items: center; gap: 8px; text-decoration: none; flex: 0 0 auto; }
.nav__poring { display: block; width: 30px; height: 30px; }
.nav__name {
  font-family: var(--font-pixel); font-size: 12px; letter-spacing: 1px;
  background: linear-gradient(180deg, #fff6c9, #ffd75e 55%, #e58f16);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #00000070);
}
@media (max-width: 460px) { .nav__name { display: none; } }

.nav__links {
  display: flex; gap: 6px; flex: 1 1 auto; justify-content: center;
  overflow-x: auto; scrollbar-width: none;
}
.nav__links::-webkit-scrollbar { display: none; }
.navlink {
  position: relative;
  font-weight: 600; font-size: 14px; white-space: nowrap; text-decoration: none;
  color: #e8f1ff; padding: 8px 14px; border-radius: 6px;
  border: 2px solid transparent;
  transition: all .16s ease;
}
.navlink:hover { background: #ffffff26; border-color: #ffffff4d; transform: translateY(-1px); }
.navlink.is-on {
  color: #3a2a1c;
  background: linear-gradient(180deg, #fff6d9, #ffd98a 60%, #e8ac48);
  border-color: #7a5a2c;
  box-shadow: 0 3px 0 #6b4a1e, inset 0 1px 0 #ffffffcc;
}
/* จุด Poring เล็ก ๆ บอกหน้าที่อยู่ */
.navlink.is-on::before {
  content: ""; position: absolute; left: 50%; bottom: -9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffb3d6, #d92f74);
  border: 1.5px solid #40202f;
  transform: translateX(-50%);
  animation: navdot 1.1s ease-in-out infinite;
}
@keyframes navdot {
  0%, 100% { transform: translateX(-50%) translateY(0) scale(1, 1); }
  45%      { transform: translateX(-50%) translateY(-4px) scale(.9, 1.1); }
}

.nav__status {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  font-family: var(--font-pixel); font-size: 8px; color: #eaf3ff;
  background: #0f1f36a6; border: 1px solid #ffffff30; border-radius: 999px;
  padding: 7px 11px;
}
.nav__status i {
  width: 8px; height: 8px; border-radius: 50%; background: #62c94a;
  box-shadow: 0 0 8px #62c94a; animation: pulse-green 2s ease-in-out infinite;
}
.nav__status.is-bad i { background: #f2607a; box-shadow: 0 0 8px #f2607a; }
@media (max-width: 700px) { .nav__status { display: none; } }

/* ── ส่วนของหน้า ── */
.section {
  position: relative; z-index: 2;
  max-width: 1180px; margin: 0 auto;
  padding: 26px 16px 40px;
  scroll-margin-top: 74px;      /* กันหัวข้อโดนเมนูบัง เวลาเลื่อนจากลิงก์ */
}
.section--home { padding-top: 8px; }

.sec-title {
  text-align: center; margin: 6px 0 4px;
  font-family: var(--font-pixel); font-size: clamp(15px, 3.2vw, 24px);
}
.sec-title span {
  background: linear-gradient(180deg, #fff6c9, #ffd75e 50%, #e58f16);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 0 #6b3a12) drop-shadow(0 5px 8px #00000045);
}
.sec-sub { text-align: center; margin: 0 0 18px; font-size: 13.5px; color: #17415f; text-shadow: 0 1px 0 #ffffffb0; }

/* ── การ์ดแนะนำตัวหน้าแรก ── */
.intro {
  display: grid; gap: 16px; margin-top: 26px;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
}
.intro__card .ro-window__body { padding: 16px; }
.intro__icon { font-size: 30px; line-height: 1; margin-bottom: 6px; }
.intro__card h3 { margin: 0 0 8px; font-size: 17px; }
.intro__card p { margin: 0 0 10px; font-size: 13px; line-height: 1.75; color: #4a382a; }
.intro__list { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.85; color: #4a382a; }
.intro__list li { margin-bottom: 4px; }

.legend { display: grid; gap: 6px; margin-top: 10px; }
.legend__item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #4a382a; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid #0004; flex: 0 0 auto; }
.dot--up { background: #62c94a; } .dot--warn { background: #ffc857; }
.dot--down { background: #f2607a; } .dot--dev { background: #a99b86; }

/* ── ปุ่มชวนเลื่อนลง ── */
.scroll-hint {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: max-content; margin: 30px auto 0;
  text-decoration: none; color: #16416b; font-size: 12.5px; font-weight: 600;
  text-shadow: 0 1px 0 #ffffffb0;
  animation: hint-bob 1.8s ease-in-out infinite;
}
.scroll-hint i { font-style: normal; font-size: 15px; }
@keyframes hint-bob { 0%, 100% { transform: translateY(0); opacity: .8; } 50% { transform: translateY(6px); opacity: 1; } }

/* ── สกิล ── */
.skills { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.skill .ro-window__bar { background: linear-gradient(180deg, #6f9ec0, #2f5d7e); }
.skill .ro-window__body { padding: 14px; }
.skill__head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.skill__icon {
  width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center;
  font-size: 23px; border-radius: 8px;
  background: linear-gradient(180deg, #fffdf6, #e2d2b2);
  border: 2px solid #b79a72; box-shadow: 0 3px 0 #00000020, inset 0 1px 0 #fff;
  transition: transform .2s;
}
.skill:hover .skill__icon { transform: rotate(-8deg) scale(1.08); }
.skill h3 { margin: 2px 0 4px; font-size: 16px; }
.skill__desc { margin: 0; font-size: 12.5px; line-height: 1.65; color: #5a4630; }
.skill .tags { margin-top: 10px; margin-bottom: 0; }
.skill .bar__fill { transition: width 1.1s cubic-bezier(.2,.9,.3,1); }

/* ── ติดต่อ ── */
.contact { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.contact .ro-window__bar { background: linear-gradient(180deg, #7d9ec8, #35507e); }
.contact__list { list-style: none; margin: 0 0 10px; padding: 0; }
.contact__list li {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 10px 4px; border-bottom: 1px dashed #c3ab8480; font-size: 13.5px;
}
.contact__list li:last-child { border-bottom: 0; }
.contact__k { color: #5a4630; font-weight: 500; }
.contact__v { font-weight: 600; color: #2f4d7e; overflow-wrap: anywhere; text-align: right; }
.contact__note { font-size: 11.5px; color: #8a7a66; margin: 4px 0 0; }
.contact__poring { display: grid; place-items: center; margin-bottom: 8px; }
.contact__card h3 { margin: 0 0 8px; font-size: 16px; text-align: center; }

/* ── โผล่ตอนเลื่อนถึง ── */
.reveal {
  opacity: 0; transform: translateY(26px) scale(.97);
  transition: opacity .55s ease, transform .55s cubic-bezier(.2,1.2,.4,1);
}
.reveal.is-in { opacity: 1; transform: none; }

@media (max-width: 640px) {
  body { padding-top: 56px; }
  .navlink { font-size: 13px; padding: 7px 10px; }
  .nav__links { justify-content: flex-start; }
  .skills, .contact, .intro { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .navlink.is-on::before, .scroll-hint, .nav__status i { animation: none !important; }
  .reveal { opacity: 1; transform: none; transition: none; }
}
