/* เถ้าแก่ไทคูน — mobile-first, ไม่มี dependency */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #0f1420; --panel: #1a2233; --panel2: #212b42; --line: #2c3852;
  --text: #e8edf7; --muted: #8b97b0; --accent: #ffb020; --accent2: #4f8dff;
  --good: #3ecf72; --bad: #ff5d6c; --gold: #ffcf4d;
}
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: 'Segoe UI', 'Sukhumvit Set', 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 15px; line-height: 1.45; min-height: 100vh;
}
.hidden { display: none !important; }
.w-full { width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input {
  font: inherit; width: 100%; padding: 11px 14px; margin-bottom: 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; color: var(--text);
}
input:focus { outline: 2px solid var(--accent2); border-color: transparent; }

.btn { display: inline-block; padding: 10px 16px; border-radius: 10px; font-weight: 600; transition: opacity .15s; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent2); color: #fff; }
.btn.gold { background: linear-gradient(135deg, #f8b500, #ffcf4d); color: #4a3000; }
.btn.ghost { border: 1px solid var(--line); color: var(--muted); }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.btn.link { color: var(--accent2); padding: 8px; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }

/* ── auth ── */
.auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.auth-box h1 { font-size: 26px; margin-bottom: 6px; text-align: center; }
.tagline { color: var(--muted); text-align: center; margin-bottom: 20px; font-size: 14px; }
.note { color: var(--muted); font-size: 12px; text-align: center; margin-top: 14px; }
.error-msg { background: rgba(255,93,108,.12); border: 1px solid var(--bad); color: var(--bad); padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; }

/* ── layout เกม ── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.co span { font-weight: 700; }
.co small { display: block; color: var(--muted); font-size: 12px; }
.co small b { color: var(--accent); }
.gold-pill {
  display: flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 999px;
  background: linear-gradient(135deg, #3a2d00, #574400); border: 1px solid #8a6d00; color: var(--gold); font-weight: 700;
}
.gold-pill .plus { background: var(--gold); color: #4a3000; border-radius: 50%; width: 18px; height: 18px; line-height: 18px; text-align: center; font-size: 14px; }

.resbar {
  position: sticky;
  top: 53px;
  z-index: 19;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1c2536, #111827);
  border-bottom: 2px solid #cca43b;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
@media (min-width: 520px) {
  .resbar {
    grid-template-columns: repeat(4, 1fr);
  }
}
.res {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.res .ic {
  font-size: 20px;
  flex: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}
.res-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.res-val {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  font-weight: 700;
  color: #e8edf7;
}
.cap-lbl {
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 2px;
}
.res-info small {
  font-size: 9.5px;
  color: var(--good);
  margin-top: 1px;
  font-weight: 600;
}
.res-info .rate-staff-lbl {
  color: var(--muted);
}
.res-progress {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.res-progress i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #4f8dff, #82b1ff);
  width: 0%;
  transition: width 0.3s ease;
}
.res-progress.full i {
  background: linear-gradient(90deg, var(--bad), #ff8fa0);
}

main { padding: 14px 14px 84px; max-width: 760px; margin: 0 auto; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button { flex: 1; padding: 8px 0 9px; font-size: 20px; color: var(--muted); position: relative; }
.tabbar button span { display: block; font-size: 11px; margin-top: 1px; }
.tabbar button.active { color: var(--accent); }
.dot { position: absolute; top: 4px; margin-left: 2px; width: 8px; height: 8px; background: var(--bad); border-radius: 50%; display: inline-block; }

/* ── การ์ด/section ── */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: 15px; margin-bottom: 10px; }
.section-title { font-size: 13px; color: var(--muted); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .4px; }

/* ── คิวก่อสร้าง ── */
.queue-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.queue-item:last-child { border-bottom: 0; padding-bottom: 0; }
.queue-item .info { flex: 1; }
.queue-item .info b { font-size: 14px; }
.queue-item .timer { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; }
.progress { height: 5px; background: var(--panel2); border-radius: 3px; overflow: hidden; margin-top: 5px; }
.progress i { display: block; height: 100%; background: var(--accent2); border-radius: 3px; transition: width 1s linear; }

/* ── ตารางอาคาร ── */
.bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.bcard { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bcard .head { display: flex; align-items: center; gap: 8px; }
.bcard .head .icon { font-size: 26px; }
.bcard .head b { font-size: 13.5px; display: block; }
.bcard .head small { color: var(--muted); font-size: 11.5px; }
.bcard .prod { font-size: 12px; color: var(--good); min-height: 16px; }
.bcard .btn { margin-top: auto; font-size: 12.5px; padding: 8px; }
.bcard.locked { opacity: .55; }
.cost { font-size: 12px; color: var(--muted); }
.cost .no { color: var(--bad); }

/* ── modal ── */
#modal-root .overlay { position: fixed; inset: 0; background: rgba(5,8,15,.7); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
#modal-root .modal {
  width: 100%; max-width: 480px; max-height: 86vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px 18px 0 0; padding: 18px;
}
@media (min-width: 520px) { #modal-root .overlay { align-items: center; } #modal-root .modal { border-radius: 18px; } }
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.modal .row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; }
.modal .actions .btn { flex: 1; text-align: center; }

/* ── ตลาด/โรงงาน ── */
.prow { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.prow:last-child { border-bottom: 0; }
.prow .icon { font-size: 26px; }
.prow .info { flex: 1; min-width: 0; }
.prow .info b { font-size: 14px; }
.prow .info small { display: block; color: var(--muted); font-size: 12px; }
.pill { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); }
.pill.up { color: var(--good); } .pill.down { color: var(--bad); }
.qty-line { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.qty-line input { margin: 0; flex: 1; }

/* ── quests ── */
.quest { padding: 11px 0; border-bottom: 1px dashed var(--line); }
.quest:last-child { border-bottom: 0; }
.quest .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.quest b { font-size: 14px; }
.quest small { color: var(--muted); }
.tutorial-card { border: 1px solid var(--accent); background: linear-gradient(160deg, #2a2410, var(--panel)); }

/* ── leaderboard ── */
.lb-row { display: flex; align-items: center; gap: 10px; padding: 9px 6px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.lb-row .rank { width: 34px; text-align: center; font-weight: 700; color: var(--muted); }
.lb-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row .val { font-variant-numeric: tabular-nums; }
.lb-row.me { background: rgba(79,141,255,.12); border-radius: 8px; }
.lb-row .mv { font-size: 11px; width: 30px; text-align: right; }
.mv.up { color: var(--good); } .mv.down { color: var(--bad); }

/* ── gold store ── */
.pkg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pkg { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; position: relative; }
.pkg .amt { font-size: 20px; font-weight: 800; color: var(--gold); }
.pkg .price { color: var(--muted); font-size: 13px; margin: 4px 0 10px; }
.pkg .badge { position: absolute; top: -8px; right: 8px; background: var(--bad); color: #fff; font-size: 10.5px; padding: 2px 8px; border-radius: 999px; }
.bonus-banner { background: linear-gradient(135deg, #3a2d00, #574400); border: 1px solid #8a6d00; color: var(--gold); padding: 10px 14px; border-radius: 12px; text-align: center; font-weight: 700; margin-bottom: 12px; }

/* ── toast ── */
#toast-root { position: fixed; top: 14px; left: 0; right: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px;
  font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.45); animation: pop .2s ease-out;
}
.toast.err { border-color: var(--bad); color: var(--bad); }
.toast.ok { border-color: var(--good); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.muted { color: var(--muted); }
.center { text-align: center; }
.mt { margin-top: 12px; }

/* ── หน้า landing + ฉากตัวละคร ── */
.landing { width: 100%; max-width: 460px; margin: 0 auto; text-align: center; }
.hero {
  border-radius: 26px; overflow: hidden; line-height: 0;
  box-shadow: 0 18px 50px rgba(0,0,0,.5), 0 0 0 1px var(--line);
  animation: heroIn .6s ease-out;
}
.hero svg { width: 100%; height: auto; }
.hero-sm { max-width: 330px; margin: 0 auto; }
@keyframes heroIn { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.game-title {
  margin: 18px 0 6px; font-size: 34px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(160deg, #ffe9a3 20%, #f0a500 80%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 8px rgba(240,165,0,.25));
}
.landing .tagline { margin-bottom: 14px; }
.features { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 18px; }
.features span {
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
}
.landing .auth-box { text-align: left; }
.auth-screen { padding-top: 28px; padding-bottom: 40px; align-items: flex-start; }

/* animation ในฉาก SVG */
.h-cloud { animation: cloudDrift 16s ease-in-out infinite alternate; }
.h-cloud2 { animation-duration: 22s; animation-delay: -6s; }
@keyframes cloudDrift { from { transform: translateX(-14px); } to { transform: translateX(20px); } }
.h-smoke { animation: smokeUp 3.2s ease-in infinite; transform-origin: center; }
.h-smoke2 { animation-delay: -1.6s; }
@keyframes smokeUp { 0% { transform: translateY(6px); opacity: .75; } 100% { transform: translateY(-26px); opacity: 0; } }
.h-mascot { animation: mascotBob 3.4s ease-in-out infinite; transform-origin: 260px 350px; }
@keyframes mascotBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.h-coin-big { animation: coinPulse 2.2s ease-in-out infinite; transform-origin: 348px 182px; }
@keyframes coinPulse { 0%,100% { transform: scale(1) rotate(-4deg); } 50% { transform: scale(1.1) rotate(6deg); } }
.h-coin { animation: coinFloat 3s ease-in-out infinite; }
.h-c2 { animation-delay: -1s; } .h-c3 { animation-delay: -2s; }
@keyframes coinFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.h-spark path { animation: sparkle 2.4s ease-in-out infinite; }
.h-spark .h-spark2 { animation-delay: -.8s; } .h-spark .h-spark3 { animation-delay: -1.6s; }
@keyframes sparkle { 0%,100% { opacity: .15; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .h-cloud,.h-smoke,.h-mascot,.h-coin,.h-coin-big,.h-spark path,.hero { animation: none; }
}

/* ── แถบกิจกรรม (event) ── */
#event-banner {
  position: sticky; top: 105px; z-index: 18;
  margin: 0; padding: 8px 14px; text-align: center; font-size: 13.5px; font-weight: 600;
  background: linear-gradient(135deg, #3a2d00, #574400); border-bottom: 1px solid #8a6d00; color: var(--gold);
}
#event-banner .timer { font-variant-numeric: tabular-nums; }
#event-banner small { display: block; font-weight: 400; color: #d9c78a; font-size: 11.5px; }

/* ═══════════ Game Look v2 — ธีมเว็บเกม tycoon ═══════════ */

body {
  background:
    radial-gradient(1000px 520px at 85% -5%, rgba(52,78,138,.55) 0%, rgba(15,20,32,0) 60%),
    radial-gradient(900px 520px at -10% 110%, rgba(38,58,104,.5) 0%, rgba(15,20,32,0) 55%),
    var(--bg);
  background-attachment: fixed;
}

/* topbar + gold */
.topbar {
  background: linear-gradient(180deg, #223050, #1a2233);
  box-shadow: 0 2px 14px rgba(0,0,0,.35);
}
.gold-pill { box-shadow: 0 0 14px rgba(255,207,77,.25), inset 0 1px 0 rgba(255,255,255,.15); }
.resbar { background: linear-gradient(180deg, #1d2740, #1a2233); }

/* ปุ่มแบบเกม: gradient + ขอบไฮไลต์ + เงา */
.btn.primary {
  background: linear-gradient(180deg, #5a95ff, #3f78e8);
  box-shadow: 0 4px 12px rgba(79,141,255,.35), inset 0 1px 0 rgba(255,255,255,.3);
  text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.btn.gold {
  background: linear-gradient(180deg, #ffd75e, #f0a500);
  box-shadow: 0 4px 14px rgba(240,165,0,.4), inset 0 1px 0 rgba(255,255,255,.5);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
}
.btn:not(:disabled):active { transform: scale(.96); }
.btn.primary:not(:disabled):hover, .btn.gold:not(:disabled):hover { filter: brightness(1.07); }

/* การ์ด: ไล่เฉด + ไฮไลต์ขอบบน */
.card, .bcard, .pkg, .auth-box {
  background: linear-gradient(180deg, #1e2947, #182136);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 4px 14px rgba(0,0,0,.25);
}

/* การ์ดอาคารแบบใหม่: ภาพตึกใหญ่กลางการ์ด */
.bgrid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.bcard { position: relative; text-align: center; gap: 4px; padding: 14px 10px 12px; transition: transform .15s, box-shadow .15s; }
.bcard:not(.locked):hover { transform: translateY(-3px); box-shadow: 0 10px 22px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08); }
.bicon { width: 64px; height: 64px; margin: 0 auto; filter: drop-shadow(0 5px 8px rgba(0,0,0,.35)); }
.bcard .binfo b { font-size: 13.5px; display: block; }
.lv-chip {
  display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 999px;
  background: linear-gradient(180deg, #ffd75e, #f0a500); color: #4a3000;
}
.lv-chip.lv0 { background: var(--panel2); color: var(--muted); font-weight: 500; }
.bcard .prod { min-height: 16px; }
.bcard.busy { outline: 1px solid rgba(255,176,32,.5); }
.busy-tag {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: 10.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--accent); color: #3a2800; box-shadow: 0 2px 8px rgba(0,0,0,.4);
}

/* หัว modal อาคาร */
.modal-bhead { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.modal-bhead .bicon { width: 58px; height: 58px; flex: none; margin: 0; }

/* แถบ progress วิ่งแบบเกม */
.progress { height: 7px; border-radius: 4px; }
.progress i { position: relative; overflow: hidden; background: linear-gradient(90deg, #4f8dff, #7fb0ff); }
.progress i::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.22) 0 7px, transparent 7px 14px);
  animation: barMove .8s linear infinite;
}
@keyframes barMove { to { transform: translateX(20px); } }

/* tabbar เรืองแสงแท็บที่เลือก */
.tabbar { background: linear-gradient(0deg, #1a2233, #1d2740); box-shadow: 0 -2px 14px rgba(0,0,0,.35); }
.tabbar button { transition: color .15s, transform .1s; }
.tabbar button:active { transform: scale(.94); }
.tabbar button.active { color: var(--gold); text-shadow: 0 0 12px rgba(255,207,77,.6); }
.tabbar button.active::before {
  content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; border-radius: 0 0 3px 3px;
  background: linear-gradient(90deg, #ffd75e, #f0a500); box-shadow: 0 2px 8px rgba(255,207,77,.5);
}

@media (prefers-reduced-motion: reduce) { .progress i::after { animation: none; } }

/* ── Visitor banner ── */
.visitor-banner {
  background: linear-gradient(90deg, #ff5d6c, #e04a57);
  color: #fff;
  padding: 8px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  position: sticky;
  top: 53px;
  z-index: 21;
}
.visitor-banner strong { color: #ffe27a; }

/* ── Toggle controls bar ── */
.view-toggle-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}
.view-toggle-bar .btn-toggle {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.view-toggle-bar .btn-toggle.active {
  background: var(--panel2);
  color: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255,207,77,0.15);
}

/* ── Industrial map grid (Circular Strategy Map) ── */
.industrial-map {
  position: relative;
  background: #1c2e21 url('../img/map_bg.png') no-repeat center center;
  background-size: cover;
  border: 2px solid #cca43b; /* Gold border */
  border-radius: 50%; /* Make map container round like the image */
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1; /* 1:1 circle */
  margin: 0 auto 16px;
  overflow: hidden;
  box-shadow: inset 0 0 35px rgba(0,0,0,0.8), 0 8px 24px rgba(0,0,0,0.6);
}

.map-bg-svg {
  display: none;
}

/* Visual plots on the map (Concentric strategy slots) */
.map-plot {
  position: absolute;
  width: 16%;
  height: 16%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transform: translate(-50%, -50%); /* Centering relative to coordinates */
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s;
}
.map-plot:hover {
  transform: translate(-50%, -50%) scale(1.2) translateY(-6px);
  z-index: 5;
}
.map-plot.locked {
  opacity: 0.45;
}
.map-plot .building-img {
  width: 100%;
  height: 80%;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(0,0,0,0.6));
  transition: transform 0.15s;
}
.map-plot .building-label {
  background: rgba(11, 16, 26, 0.95);
  border: 1px solid #cca43b; /* Gold border label */
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 8.5px;
  font-weight: 800;
  white-space: nowrap;
  color: #f7ebd5;
  margin-top: 2px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.map-plot .lv-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: linear-gradient(180deg, #ffd75e, #f0a500);
  color: #4a3000;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 8px;
  font-weight: 900;
  line-height: 16px;
  text-anchor: middle;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.map-plot.locked .lv-badge {
  background: #2b3345;
  color: var(--muted);
}

/* Animations */
.map-plot.building-upgrade::after {
  content: '🔨';
  position: absolute;
  font-size: 20px;
  top: -15px;
  left: 20%;
  animation: hammerSwing 0.8s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
  z-index: 4;
}
@keyframes hammerSwing {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-35deg) scale(1.15); }
}

.map-plot.factory-active .building-svg {
  animation: factoryShake 0.3s ease-in-out infinite alternate;
}
@keyframes factoryShake {
  from { transform: rotate(-1deg); }
  to { transform: rotate(1deg); }
}

.coin-particle {
  position: absolute;
  font-size: 13px;
  color: #ffe27a;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  pointer-events: none;
  animation: floatCoinUp 1.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
  z-index: 10;
}
@keyframes floatCoinUp {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(-35px) scale(1.25); opacity: 0; }
}

.map-plot.rnd-active::before {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  background: radial-gradient(circle, rgba(255,207,77,0.4) 0%, transparent 70%);
  animation: glowPulse 1.8s infinite ease-in-out;
  pointer-events: none;
  top: 10%;
  z-index: 1;
}
@keyframes glowPulse {
  0%, 100% { transform: scale(0.75); opacity: 0.3; }
  50% { transform: scale(1.2); opacity: 0.85; }
}

.delivery-truck {
  position: absolute;
  font-size: 16px;
  z-index: 3;
  pointer-events: none;
  /* จัดกึ่งกลาง emoji ให้อยู่บนเส้นถนนพอดี (transform ใช้กับทิศรถ ห้ามใช้ translate) */
  margin-left: -10px;
  margin-top: -11px;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,.45));
  transition: left 2.2s linear, top 2.2s linear, transform 0.25s ease-out;
}
.pedestrian {
  position: absolute;
  font-size: 8px;
  z-index: 3;
  pointer-events: none;
  margin-left: -4px;
  margin-top: -5px;
  transition: left 3s linear, top 3s linear;
  opacity: 0.65;
}

/* ── MMO Chat Screen ── */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 220px);
  min-height: 380px;
  background: linear-gradient(180deg, #1e2947, #182136);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 4px 14px rgba(0,0,0,.25);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  animation: messageIn 0.2s ease-out;
  position: relative;
}
.chat-msg.me {
  align-self: flex-end;
  background: linear-gradient(135deg, #1d335c, #2c4472);
  border: 1px solid #3d588f;
  border-bottom-right-radius: 2px;
}
.chat-msg.other {
  align-self: flex-start;
  background: #212b42;
  border: 1px solid var(--line);
  border-bottom-left-radius: 2px;
}
.chat-msg .author {
  font-weight: 700;
  font-size: 11px;
  color: var(--accent);
  margin-bottom: 2px;
}
.chat-msg.me .author {
  color: #7fb0ff;
}
.chat-msg .text {
  word-break: break-word;
  line-height: 1.4;
}
.chat-msg .time {
  align-self: flex-end;
  font-size: 9px;
  color: var(--muted);
  margin-top: 3px;
}
.chat-input-bar {
  display: flex;
  padding: 8px 10px;
  background: var(--panel2);
  border-top: 1px solid var(--line);
  gap: 8px;
  align-items: center;
}
.chat-input-bar input {
  margin-bottom: 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.chat-input-bar button {
  flex: none;
  width: 60px;
}
@keyframes messageIn {
  from { transform: translateY(6px); opacity: 0; }
  to { transform: none; opacity: 1; }
}


/* ═══════════ Game Look v3 — Epic game-site theme (แบบเว็บเกม MMO) ═══════════ */

/* พื้นหลังทั้งเว็บ: ภาพแผนที่เมืองของเกม มืดลงให้อ่านง่าย */
body {
  background:
    linear-gradient(180deg, rgba(11,15,26,.88) 0%, rgba(11,15,26,.94) 60%, #0b0f1a 100%),
    url('../img/map_bg.png') center -60px / 1100px auto no-repeat,
    #0b0f1a;
}

/* หน้า landing เห็นภาพเกมชัดกว่าหน้าเล่น (แบบหน้าแรก Travian) */
.auth-screen {
  background:
    radial-gradient(ellipse 90% 46% at 50% 0%, rgba(240,165,0,.16), transparent 60%),
    linear-gradient(180deg, rgba(11,15,26,.42) 0%, rgba(11,15,26,.78) 46%, rgba(11,15,26,.96) 78%),
    url('../img/map_bg.png') center top / cover no-repeat;
}

/* hero วังสำนักงานใหญ่ ลอยบนแสงทอง */
.hero-epic {
  position: relative;
  line-height: 0;
  animation: heroIn .6s ease-out;
}
.hero-epic::before {
  content: '';
  position: absolute; inset: 8% 12% 0 12%;
  background: radial-gradient(ellipse at 50% 62%, rgba(255,207,77,.32), rgba(255,207,77,0) 68%);
  pointer-events: none;
}
.hero-palace {
  width: min(72%, 300px); height: auto;
  filter: drop-shadow(0 24px 34px rgba(0,0,0,.7)) drop-shadow(0 0 26px rgba(255,207,77,.18));
  animation: palaceFloat 5.5s ease-in-out infinite;
}
.hero-epic-sm .hero-palace { width: min(52%, 220px); }
@keyframes palaceFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }

.game-title { font-size: 40px; margin-top: 6px; }
.title-orn {
  color: #cca43b; font-size: 12px; letter-spacing: 3px; margin: 2px 0 8px;
  text-shadow: 0 0 12px rgba(255,207,77,.35);
}

/* ปุ่มเล่นตอนนี้ เขียว glossy แบบปุ่มเกม */
.btn.play {
  display: block;
  padding: 14px 18px;
  font-size: 17.5px; font-weight: 800; letter-spacing: .3px;
  border-radius: 14px;
  color: #fff; text-shadow: 0 2px 3px rgba(0,0,0,.45);
  background: linear-gradient(180deg, #86e05c 0%, #4db742 48%, #379530 52%, #2f8329 100%);
  border: 1px solid #256b21;
  box-shadow: 0 6px 20px rgba(64,175,53,.4), inset 0 2px 0 rgba(255,255,255,.45), inset 0 -3px 0 rgba(0,0,0,.28);
  transition: filter .15s, transform .1s;
}
.btn.play:not(:disabled):hover { filter: brightness(1.09); }
#btn-show-register.play { margin-top: 4px; }
#form-login .btn.primary { padding: 12px 16px; font-size: 15.5px; }

/* กล่อง login กรอบทอง + มุมประดับแบบเว็บเกม */
.landing .auth-box {
  border: 1px solid rgba(204,164,59,.55);
  box-shadow:
    inset 0 0 0 1px rgba(204,164,59,.16),
    inset 0 1px 0 rgba(255,255,255,.07),
    0 16px 44px rgba(0,0,0,.55);
  position: relative;
  background: linear-gradient(180deg, rgba(30,41,71,.96), rgba(21,28,48,.96));
}
.landing .auth-box::before,
.landing .auth-box::after {
  content: ''; position: absolute; width: 24px; height: 24px;
  border: 2px solid #cca43b; pointer-events: none;
}
.landing .auth-box::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; border-top-left-radius: 16px; }
.landing .auth-box::after { bottom: -2px; right: -2px; border-left: 0; border-top: 0; border-bottom-right-radius: 16px; }

.features span {
  border-color: rgba(204,164,59,.45);
  background: rgba(46,36,6,.55);
  color: #e9d9a6;
}

/* เส้นทองคาด topbar/tabbar ให้เข้าธีมกรอบเกม */
.topbar { border-bottom: 1px solid rgba(204,164,59,.5); }
.tabbar { border-top: 1px solid rgba(204,164,59,.42); }

@media (prefers-reduced-motion: reduce) { .hero-palace { animation: none; } }

/* ── แผนที่เมือง v3: ผังสี่เหลี่ยม ที่ดินเปล่า + ถนน (แทนวงกลม map_bg เดิม) ── */
.industrial-map {
  background: #527e3a;              /* กันแวบก่อน SVG พื้นเมืองวาด */
  border-radius: 18px;
  aspect-ratio: 4 / 3;
  max-width: 640px;
  border: 2px solid #cca43b;
  box-shadow: inset 0 0 34px rgba(0,0,0,.38), 0 8px 24px rgba(0,0,0,.55);
}
.industrial-map .map-terrain {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}

/* ── แปลงว่าง (ยังไม่สร้าง): หมุดเล็ก ๆ กลมกลืนกับทุ่ง — เมืองเปิดมาดูโล่ง ── */
.map-plot.empty {
  width: 9.5%;
  height: 9.5%;
  opacity: .92;
}
.map-plot.empty .building-img { opacity: .85; }
.map-plot.empty .building-label { display: none; }           /* ป้ายชื่อโชว์เมื่อชี้ (แตะ = เปิดรายละเอียด) */
.map-plot.empty:hover .building-label { display: block; }
.map-plot.empty .lv-badge {
  width: 14px; height: 14px; line-height: 14px; font-size: 8px;
  top: -2px; right: -2px;
}
