/* ===== Xuyên Không – giao diện (phong cách 2.5D hoạt hình) ===== */
:root {
  --sky1: #ff9f5a; --sky2: #ffe3b3;
  --ground1: #8b6b43; --ground2: #6a4f2e;
  --plot: #7a5a33; --plot-border: #4f3820;
  --accent: #d9822b;
  --wood1: #6b4526; --wood2: #4a2e17; --wood-edge: #2e1c0e;
  --paper: #fff8ea; --paper2: #fbebcf; --ink: #3b2a18; --muted: #8a7458;
  --ok: #2e9e4f; --no: #c0392b; --line: #efdcb6; --gold: #ffcf4a;
  --radius: 16px;
  --title: 'Baloo 2', 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: var(--wood2); color: var(--ink); overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; }
svg { display: block; }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- Thanh trên (gỗ) ---------- */
#topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 8px 16px; color: #fff3dc; position: relative; z-index: 3;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 2px, transparent 2px 34px),
    linear-gradient(180deg, var(--wood1), var(--wood2));
  border-bottom: 4px solid var(--wood-edge);
  box-shadow: 0 4px 0 rgba(0,0,0,.18);
}
.brand { display: flex; align-items: center; gap: 6px; font-family: var(--title); font-weight: 800; font-size: 22px; color: var(--gold); text-shadow: 0 2px 0 var(--wood-edge); }
.brand span { letter-spacing: .5px; }
.era-box { padding-left: 14px; border-left: 2px solid rgba(255,255,255,.15); }
#era-name { font-family: var(--title); font-weight: 800; font-size: 18px; line-height: 1.1; }
#era-year { font-size: 12.5px; opacity: .85; }
.stats { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.stat {
  background: rgba(0,0,0,.28); padding: 5px 14px; border-radius: 99px; font-size: 15px; white-space: nowrap;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.12);
}
.stat b { font-weight: 900; color: #fff; }
.stat.level { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.xpbar { width: 90px; height: 10px; background: rgba(0,0,0,.35); border-radius: 9px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(180deg, #b6f27a, #5cc23a); transition: width .4s; }
.icon-btn {
  background: linear-gradient(180deg, #8a5a33, #6b4526); border: 0; border-radius: 12px; font-size: 18px; padding: 6px 9px;
  cursor: pointer; color: inherit; box-shadow: 0 3px 0 var(--wood-edge);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--wood-edge); }
.modal .icon-btn { background: var(--paper2); box-shadow: 0 3px 0 var(--line); }
#goal {
  position: relative; z-index: 2; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 80%, #000));
  color: #fff; font-weight: 800; padding: 6px 16px; font-size: 14px; text-shadow: 0 1px 0 rgba(0,0,0,.3);
  box-shadow: 0 3px 0 rgba(0,0,0,.15);
}

/* ---------- Bố cục ---------- */
#main { flex: 1; display: flex; min-height: 0; }
#world { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
#panel {
  width: 410px; background: var(--paper); display: flex; flex-direction: column; min-height: 0;
  border-left: 6px solid var(--wood1); box-shadow: -4px 0 0 var(--wood-edge);
}

/* ---------- Khung cảnh ---------- */
#scene {
  position: relative; height: 270px; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(180deg, var(--sky1), var(--sky2));
  transition: background 1s;
}
#scene-bg { position: absolute; inset: 0; }
.scene-svg { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; }
/* Bản đồ thành phố: cuộn ngang */
#town-scroll { position: absolute; inset: 0; overflow-x: auto; overflow-y: hidden; cursor: grab; scrollbar-width: thin; scrollbar-color: rgba(0,0,0,.35) transparent; }
#town-scroll.dragging { cursor: grabbing; }
#town-canvas { position: relative; height: 100%; min-width: 100%; }
#decor { position: absolute; left: 0; right: 0; bottom: 118px; height: 150px; transform: scale(.7); transform-origin: 50% 100%; }
#lots { position: absolute; inset: 0; }
.lot {
  position: absolute; width: 124px; height: 200px; padding: 0; border: 0; background: none; cursor: pointer;
  transform: translateX(-50%) scale(var(--s)); transform-origin: 50% 100%; pointer-events: none;
}
.lot > * { pointer-events: auto; }
.lot-pad { position: absolute; left: 12px; right: 12px; bottom: 0; height: 24px; border-radius: 50%; background: rgba(0,0,0,.2); }
.lot.empty .lot-pad { background: rgba(255,255,255,.16); border: 2px dashed rgba(255,255,255,.6); height: 30px; }
.lot.empty:hover .lot-pad { background: rgba(255,255,255,.35); }
.lot-plus { position: absolute; left: 0; right: 0; bottom: 4px; text-align: center; color: rgba(255,255,255,.85); font-weight: 900; font-size: 18px; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.lot-art { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); filter: drop-shadow(0 4px 0 rgba(0,0,0,.22)); transition: transform .15s; }
.lot-art svg, .lot-art img { width: 100%; height: auto; overflow: visible; }
.lot:hover .lot-art { transform: translateX(-50%) translateY(-5px); }
.lot.wonder .lot-art { filter: drop-shadow(0 0 10px rgba(255,220,120,.85)) drop-shadow(0 4px 0 rgba(0,0,0,.2)); }
.lot-tag { position: absolute; left: 0; right: 0; bottom: -6px; text-align: center; font-size: 11px; color: #ffcf4a; letter-spacing: -1px; text-shadow: 0 1px 0 #3b2a18, 0 0 3px #3b2a18; }
.lot-sign { position: absolute; left: 6px; bottom: 12px; width: 30px; height: 30px; border-radius: 50%; background: #fffaf0; border: 3px solid var(--wood1); display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 2px 0 rgba(0,0,0,.25); }
.lot-ready { position: absolute; right: 2px; bottom: 44px; background: #ffcf4a; border: 2px solid var(--wood1); border-radius: 99px; padding: 0 6px; font-size: 12px; font-weight: 900; animation: pulseBadge 1.4s ease-in-out infinite; }
.lot-plaque { position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%); background: linear-gradient(180deg, #ffe08a, #e0a526); border: 2px solid var(--wood1); border-radius: 8px; padding: 0 6px; font-size: 13px; }
.spin-slow { transform-origin: 60px 62px; animation: spin 6s linear infinite; }
/* Bảng chỉ số trên bản đồ */
#town-hud { position: absolute; top: 8px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 6; }
#town-hud > * { pointer-events: auto; }
.hud-left { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.hud-pill { background: rgba(35,22,10,.62); color: #fff; border-radius: 99px; padding: 4px 11px; font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.hud-pill b { font-weight: 900; }
.hud-tax { border: 0; border-radius: 99px; padding: 5px 12px; font-weight: 900; font-size: 13px; cursor: pointer; color: #5a3a00; background: linear-gradient(180deg, #ffe58a, #f5b400); box-shadow: 0 3px 0 #a87400; }
.hud-tax:disabled { filter: grayscale(.7); opacity: .7; cursor: default; }
.hud-tax:not(:disabled) { animation: pulse 1.6s ease-in-out infinite; }
.map-toggle { display: flex; background: rgba(35,22,10,.62); border-radius: 99px; padding: 3px; gap: 2px; }
.map-toggle button { border: 0; background: transparent; color: #fff; font-weight: 800; font-size: 12px; padding: 4px 10px; border-radius: 99px; cursor: pointer; }
.map-toggle button.on { background: #fff; color: var(--ink); }
.deco { position: absolute; line-height: 1; filter: drop-shadow(0 4px 2px rgba(0,0,0,.2)); transform-origin: bottom center; }
.deco.svg svg { width: 100%; height: auto; }
.deco.new { animation: pop .8s ease-out; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
.flame { transform-origin: 50% 90%; animation: flicker .6s ease-in-out infinite alternate; }
@keyframes flicker { from { transform: scale(1, 1); } to { transform: scale(.92, 1.08); } }
.puff { animation: puff 3s ease-in-out infinite; }
@keyframes puff { 0% { transform: translate(0, 6px); opacity: .6; } 50% { opacity: 1; } 100% { transform: translate(8px, -8px); opacity: .5; } }
#clouds { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.cloud { position: absolute; font-size: 44px; opacity: .9; animation: drift linear infinite; filter: drop-shadow(0 3px 0 rgba(0,0,0,.08)); }
.cloud.c1 { top: 10px; animation-duration: 60s; }
.cloud.c2 { top: 44px; font-size: 34px; animation-duration: 85s; animation-delay: -30s; }
.cloud.c3 { top: 20px; font-size: 28px; animation-duration: 110s; animation-delay: -70s; }
.cloud.c4 { top: 60px; font-size: 30px; animation-duration: 95s; animation-delay: -50s; }
@keyframes drift { from { left: -5%; } to { left: 102%; } }
.star { position: absolute; color: #fff; font-size: 12px; opacity: .8; animation: twinkle 2s ease-in-out infinite alternate; }
@keyframes twinkle { from { opacity: .2; } to { opacity: 1; } }

/* ---------- Mặt đất & ruộng ---------- */
#ground {
  flex: 1; overflow-y: auto; padding: 22px 18px 28px; position: relative;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.06) 0 2px, transparent 3px) 0 0 / 28px 28px,
    linear-gradient(180deg, var(--ground1), var(--ground2));
}
/* Viền cỏ răng cưa giữa khung cảnh và mặt đất */
#ground::before {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 14px;
  background: radial-gradient(circle at 10px -2px, color-mix(in srgb, var(--ground1) 55%, #6fbf3f) 11px, transparent 12px) 0 0 / 20px 14px;
  pointer-events: none;
}
#field-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tbtn {
  border: 0; border-radius: 99px; padding: 7px 14px; font-weight: 800; font-size: 13px; cursor: pointer;
  background: linear-gradient(180deg, #fffdf6, #f3e3c3); color: var(--ink); box-shadow: 0 3px 0 rgba(0,0,0,.3);
}
.tbtn b { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; margin-left: 2px; }
.tbtn:disabled { opacity: .5; cursor: default; }
.tbtn:disabled b { background: #a89478; }
.tbtn:not(:disabled):hover { transform: translateY(-1px); }
.tbtn:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }

#field { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 18px 12px; max-width: 980px; padding-top: 18px; }
.plot {
  position: relative; aspect-ratio: 100 / 92; border: 0; padding: 0; background: none; cursor: pointer;
  transition: transform .12s;
}
.plot:disabled { cursor: default; }
.plot .tile { position: absolute; inset: 0; filter: drop-shadow(0 5px 0 rgba(0,0,0,.22)); }
.plot .tile svg, .plot .tile img { width: 100%; height: 100%; }
.plot:not(:disabled):hover { transform: translateY(-3px); }
.plot:not(:disabled):hover .tile { filter: drop-shadow(0 8px 0 rgba(0,0,0,.2)) brightness(1.06); }
.plot .plus { position: absolute; left: 0; right: 0; top: 30%; text-align: center; color: rgba(255,255,255,.35); font-size: 26px; font-weight: 900; }
.plot.empty:hover .plus { color: rgba(255,255,255,.9); }
.sprite { position: absolute; left: 12%; width: 76%; bottom: 30%; pointer-events: none; }
.sprite svg, .sprite img { width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 3px 0 rgba(0,0,0,.18)); }
.sprite .fruit { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); font-size: 34px; line-height: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,.35)); }
.sprite .fruit.small { font-size: 20px; top: 34%; opacity: .75; }
.sprite.ripe { animation: bounce 1.4s ease-in-out infinite; }
.plot.ready .tile::after { content: ''; }
.plot.ready::before {
  content: ''; position: absolute; left: 14%; right: 14%; top: 18%; height: 40%; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255,236,120,.75), transparent); animation: glow 1.4s ease-in-out infinite alternate;
}
@keyframes glow { from { opacity: .45; } to { opacity: 1; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.badge { position: absolute; font-size: 20px; line-height: 1; z-index: 2; filter: drop-shadow(0 2px 1px rgba(0,0,0,.4)); }
.badge.bug { top: 6%; left: 4%; animation: wiggle .5s ease-in-out infinite alternate; }
.badge.drop { top: 6%; right: 4%; animation: bob 1.6s ease-in-out infinite; }
.badge.hand { bottom: 20%; right: 6%; font-size: 18px; }
@keyframes wiggle { from { transform: rotate(-15deg); } to { transform: rotate(15deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.plotbar { position: absolute; left: 16%; right: 16%; bottom: 16%; height: 7px; z-index: 2; box-shadow: 0 0 0 2px rgba(59,42,24,.6); }
.plot .timer {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%); z-index: 2; font-size: 11px; font-weight: 900;
  color: #fff; background: rgba(40,25,10,.72); padding: 1px 7px; border-radius: 99px; pointer-events: none; white-space: nowrap;
}

/* ---------- Thanh tiến độ ---------- */
.bar { height: 8px; background: rgba(0,0,0,.3); border-radius: 9px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(180deg, #b6f27a, #5cc23a); transition: width .5s linear; }
.card .bar { background: #eadbc0; margin-top: 8px; }

/* ---------- Tab ---------- */
#tabs { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 6px 6px 0; background: var(--paper2); border-bottom: 3px solid var(--line); }
.tab {
  position: relative; border: 0; background: transparent; padding: 7px 2px 6px; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 1px; border-radius: 12px 12px 0 0;
}
.tab:hover { background: rgba(255,255,255,.5); }
.tab .ti { font-size: 21px; transition: transform .15s; }
.tab:hover .ti { transform: scale(1.12); }
.tab .tn { font-size: 9.5px; font-weight: 800; white-space: nowrap; }
.tab.on { color: var(--ink); background: var(--paper); box-shadow: inset 0 3px 0 var(--accent); }
.tab .tb {
  position: absolute; top: 2px; right: 5px; background: var(--no); color: #fff; font-size: 10px; font-weight: 900; border-radius: 99px;
  min-width: 18px; padding: 1px 5px; box-shadow: 0 2px 0 rgba(0,0,0,.25); animation: pulseBadge 1.6s ease-in-out infinite;
}
@keyframes pulseBadge { 50% { transform: scale(1.12); } }
#panel-body { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 14px; }
#panel-body h3, .modal h3 { margin: 0 0 4px; font-family: var(--title); font-weight: 800; font-size: 21px; }
.sub { margin: 0 0 12px; color: var(--muted); font-size: 13px; }

/* ---------- Thẻ ---------- */
.card {
  background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 11px 12px; margin-bottom: 11px;
  box-shadow: 0 3px 0 var(--line);
}
.card.locked { opacity: .55; filter: grayscale(.4); }
.card.done { border-color: #ffd54f; background: linear-gradient(180deg, #fffdf0, #fff6d0); box-shadow: 0 3px 0 #f3d36a; }
.card.busy { border-color: #b3e5fc; box-shadow: 0 3px 0 #b3e5fc; }
.card-head { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.big-ic { font-size: 30px; line-height: 1; width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--paper2); border-radius: 12px; }
.avatar { font-size: 34px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: var(--paper2); border-radius: 50%; flex-shrink: 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.small { font-size: 11.5px; }
.right { text-align: right; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.row.end { justify-content: flex-end; }
.eratag { font-size: 13px; opacity: .8; }
.tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; }
.tag.ok { background: #e3f6e8; color: var(--ok); }
.tag.future { background: #efe3ff; color: #7b3fe4; }
.ok-text { color: var(--ok); font-weight: 800; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 800; padding: 3px 9px; border-radius: 99px; margin: 2px 2px 2px 0; background: #f4ecdc; white-space: nowrap; }
.chip.ok { background: #e3f6e8; color: var(--ok); }
.chip.no { background: #fde8e6; color: var(--no); }
.chip.out { background: #fff3cf; color: #8a5a00; }

/* Nút kiểu game: nổi khối, nhấn lún xuống */
.btn {
  border: 0; border-radius: 12px; padding: 8px 13px; font-weight: 800; font-size: 13px; cursor: pointer; white-space: nowrap;
  background: linear-gradient(180deg, #fbf1dc, #ecdcbc); color: var(--ink); box-shadow: 0 3px 0 #cdb58a;
  transition: transform .08s, filter .15s;
}
.btn:disabled { opacity: .45; cursor: default; filter: grayscale(.5); }
.btn:not(:disabled):hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(2px); box-shadow: 0 1px 0 #cdb58a; }
.btn.primary {
  background: linear-gradient(180deg, #7ed957, #45a82e); color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.25);
  box-shadow: 0 3px 0 #2f7a1f;
}
.btn.primary:not(:disabled):active { box-shadow: 0 1px 0 #2f7a1f; }
.btn.danger { background: linear-gradient(180deg, #ef6b5b, #c0392b); color: #fff; box-shadow: 0 3px 0 #8a2419; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.big { padding: 12px 18px; font-size: 15px; width: 100%; margin-top: 8px; white-space: normal; }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.15); } }

/* Biểu tượng SVG (vật phẩm, nhân vật, xưởng) */
.ico { display: inline-block; width: 1.45em; height: 1.45em; vertical-align: -.38em; line-height: 0; }
.ico svg { width: 100%; height: 100%; overflow: visible; }
.chip .ico { width: 20px; height: 20px; vertical-align: -5px; }
.big-ic .ico { width: 36px; height: 36px; vertical-align: 0; }
.avatar .ico, .order-head .who .ico { width: 100%; height: 100%; vertical-align: 0; }
.avatar, .order-head .who { overflow: hidden; }
.modal-head h3 .ico { width: 34px; height: 34px; vertical-align: -10px; background: var(--paper2); border-radius: 50%; }
.bld-ic { position: relative; padding: 4px 3px 2px; }
.bld-ic svg { width: 100%; height: auto; }
.mini-sign { position: absolute; right: -6px; bottom: -6px; width: 22px; height: 22px; border-radius: 50%; background: #fffaf0; border: 2px solid var(--wood1); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.toast .ico { width: 20px; height: 20px; vertical-align: -5px; }
.floater .ico { width: 24px; height: 24px; vertical-align: -6px; filter: drop-shadow(0 2px 0 #3b2a18); }

/* Đơn hàng */
.order.empty { color: var(--muted); text-align: center; border-style: dashed; box-shadow: none; background: transparent; }
.order.can { border-color: #8bd46e; box-shadow: 0 3px 0 #8bd46e; }
.order-head { display: flex; gap: 10px; align-items: center; }
.order-head .who { font-size: 30px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: var(--paper2); border-radius: 50%; flex-shrink: 0; }
.reward { font-size: 13px; margin-top: 6px; }
.warn-line { margin-top: 6px; font-size: 12px; font-weight: 800; color: #b26a00; background: #fff4e0; border-radius: 8px; padding: 4px 8px; }
/* Kho */
.inv-row { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed var(--line); }
/* Xưởng */
.recipes { margin-top: 6px; }
.recipe { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); }
.queue { margin-top: 6px; display: grid; gap: 4px; }
.qjob { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 8px; border-radius: 10px; background: #f6f0e3; }
.qjob.done { background: #fffbe6; }
.qjob .bar { margin-top: 0; }
.qjob .timer { font-weight: 800; }
.loot { margin-top: 6px; font-size: 12px; color: var(--muted); }
.unlocks { margin: 6px 0 0 54px; }
.tech.done { opacity: .7; }
/* Kỳ quan */
.timeline { display: flex; align-items: center; margin: 10px 0 20px; }
.tl { display: flex; flex-direction: column; align-items: center; width: 30px; flex-shrink: 0; position: relative; }
.tl span { font-size: 17px; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #eee; border: 2px solid #ddd; }
.tl small { display: none; }
.tl.now small { display: block; position: absolute; top: 33px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--muted); white-space: nowrap; }
.tl.past span { background: #e3f6e8; border-color: #9ad6a8; }
.tl.now span { background: var(--gold); border-color: #e0a526; box-shadow: 0 0 0 3px #fff3c2; }
.tl.future { opacity: .5; }
.tl-line { flex: 1; min-width: 4px; height: 4px; background: var(--line); border-radius: 4px; }
.wonder { text-align: center; }
.wonder-ic { font-size: 64px; filter: drop-shadow(0 4px 0 rgba(0,0,0,.15)); }
.wonder h4 { margin: 4px 0; font-size: 22px; font-family: var(--title); }

/* Chơi online */
.card.online { border-color: #b388ff; box-shadow: 0 3px 0 #d6c2ff; }
.card.online.off { border-color: var(--line); box-shadow: 0 3px 0 var(--line); }
.rp-list { margin-top: 8px; }
.rp-row { display: flex; align-items: center; gap: 8px; padding: 6px 2px; border-top: 1px dashed var(--line); }
.rp-era { font-size: 22px; width: 32px; text-align: center; }
.inbox { margin-top: 8px; background: #f6f0ff; border-radius: 10px; padding: 6px 10px; }
.warn-text { color: #b23a2b; font-weight: 800; }
.lb-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.lb-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 10px; }
.lb-row:nth-child(odd) { background: #fff; }
.lb-row.me { background: #fff3cf; box-shadow: inset 0 0 0 2px var(--gold); }
.lb-rank { width: 34px; text-align: center; font-weight: 900; font-size: 16px; }
.lb-val { font-weight: 800; font-size: 13px; white-space: nowrap; }
.text-in { width: 100%; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); font: inherit; font-weight: 700; margin: 6px 0; background: #fff; }
.text-in:focus { outline: none; border-color: var(--accent); }
.lbl { display: block; font-weight: 800; font-size: 13px; margin-top: 6px; }
code { background: var(--paper2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

/* Kinh tế */
.econ-actions { display: grid; gap: 8px; margin: 4px 0 16px; }
h3.mt { margin-top: 8px !important; }
.growth { display: grid; gap: 6px; }
.grow-row { display: grid; grid-template-columns: 30px 1fr; gap: 2px 8px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 6px 8px; }
.grow-row.now { border-color: var(--gold); background: #fffbe6; }
.grow-era { font-size: 20px; grid-row: span 2; text-align: center; }
.grow-bar { position: relative; height: 20px; background: #f4ecdc; border-radius: 99px; overflow: hidden; }
.grow-bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, #7ed957, #45a82e); border-radius: 99px; }
.grow-bar span { position: relative; font-size: 11.5px; font-weight: 900; padding-left: 8px; line-height: 20px; color: var(--ink); text-shadow: 0 0 3px #fff; }
.grow-meta { font-size: 11px; color: var(--muted); font-weight: 700; }
.lot-preview { display: flex; justify-content: center; align-items: flex-end; height: 150px; margin: 4px 0 8px; background: linear-gradient(180deg, var(--sky2, #eaf6ff), #fff); border-radius: 14px; border: 2px solid var(--line); padding-bottom: 8px; }
.lot-preview span { display: block; max-height: 140px; }
.lot-preview svg, .lot-preview img { width: 100%; height: auto; max-height: 140px; }

/* ---------- Modal ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(30,15,0,.6); z-index: 50; backdrop-filter: blur(2px); }
.modal {
  position: fixed; z-index: 51; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(540px, calc(100vw - 24px)); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--paper); border-radius: 22px; padding: 16px 18px; border: 4px solid var(--wood1);
  box-shadow: 0 6px 0 var(--wood-edge), 0 24px 60px rgba(0,0,0,.5);
  animation: modalIn .2s ease-out;
}
.modal.wide { width: min(800px, calc(100vw - 24px)); }
@keyframes modalIn { from { transform: translate(-50%, -46%); opacity: 0; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h3 { margin: 0; }
.seed { display: flex; align-items: center; gap: 8px; padding: 8px 4px; border-bottom: 1px dashed var(--line); }
.seed.locked { opacity: .5; }
.seed-art { width: 48px; height: 48px; position: relative; flex-shrink: 0; background: var(--paper2); border-radius: 12px; padding: 2px 4px 0; }
.seed-art svg { width: 100%; height: auto; }
.seed-art .fruit { position: absolute; left: 50%; top: 20%; transform: translateX(-50%); font-size: 20px; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.statgrid div { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.menu-btns { display: grid; gap: 8px; margin: 12px 0; }
.audio-set { display: grid; gap: 6px; background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.audio-set label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-weight: 800; font-size: 13px; }
.audio-set input { flex: 1; max-width: 220px; accent-color: var(--accent); }
.help ol { padding-left: 20px; } .help li { margin-bottom: 6px; }
textarea.code { width: 100%; height: 140px; font-family: monospace; font-size: 11px; border-radius: 10px; border: 2px solid var(--line); padding: 8px; word-break: break-all; }
/* Vườn hàng xóm */
.nscene { border-radius: 16px; overflow: hidden; border: 3px solid var(--wood1); }
.nsky { position: relative; height: 130px; background: linear-gradient(180deg, var(--sky1), var(--sky2)); overflow: hidden; }
.ndecor { position: absolute; inset: 0 0 4px; }
.nsky .deco { transform: scale(.7); animation: none; }
.nground { padding: 20px 14px 16px; background: linear-gradient(180deg, var(--ground1), var(--ground2)); }
.nfield { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 16px 10px; padding-top: 12px; }
.victory { text-align: center; }
.victory h2 { font-family: var(--title); }
.vic-ic { font-size: 64px; }

/* ---------- Toast & chữ bay ---------- */
#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast { background: #3b2a18; color: #fff; padding: 9px 16px; border-radius: 14px; font-weight: 700; font-size: 14px; box-shadow: 0 4px 0 rgba(0,0,0,.25), 0 8px 20px rgba(0,0,0,.3); animation: toastIn .25s ease-out; transition: opacity .4s, transform .4s; max-width: 90vw; text-align: center; }
.toast.good { background: #2e7d32; } .toast.warn { background: #b23a2b; } .toast.level { background: linear-gradient(90deg, #7b3fe4, #d9822b); }
.toast.out { opacity: 0; transform: translateY(10px); }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } }
.floater { position: fixed; z-index: 95; transform: translateX(-50%); font-weight: 900; font-size: 17px; color: #fff; text-shadow: 0 2px 0 #3b2a18, 0 0 6px rgba(0,0,0,.4); pointer-events: none; animation: floatUp 1.3s ease-out forwards; white-space: nowrap; }
@keyframes floatUp { to { transform: translate(-50%, -60px); opacity: 0; } }

/* ---------- Hiệu ứng xuyên không ---------- */
#warp { position: fixed; inset: 0; z-index: 100; display: none; background: radial-gradient(circle, #3a1f7a, #0b0033 70%); color: #fff; overflow-y: auto; }
#warp.on { display: flex; align-items: center; justify-content: center; }
.warp-inner { text-align: center; padding: 24px; max-width: 620px; }
.vortex { font-size: 120px; animation: spin 1.2s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.warp-title { font-family: var(--title); font-weight: 800; letter-spacing: 8px; font-size: 22px; opacity: .8; }
.warp-year { font-family: var(--title); font-weight: 800; font-size: 48px; margin: 6px 0 16px; text-shadow: 0 0 20px #b388ff; }
.warp-era.hidden { display: none; }
.warp-era { animation: modalIn2 .6s ease-out; }
@keyframes modalIn2 { from { opacity: 0; transform: translateY(20px); } }
.warp-ic { font-size: 56px; }
.warp-era h2 { margin: 4px 0; font-size: 30px; font-family: var(--title); }
.warp-years { opacity: .7; margin: 0 0 10px; }
.warp-story { line-height: 1.6; font-size: 16px; }

/* ---------- Điện thoại / máy tính bảng ---------- */
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; }
  #main { flex-direction: column; }
  #panel { width: 100%; border-left: 0; box-shadow: none; border-top: 6px solid var(--wood1); }
  #panel-body { overflow: visible; }
  #scene { height: 230px; }
  .lot { transform: translateX(-50%) scale(calc(var(--s) * .85)); }
  .hud-pill { font-size: 11.5px; padding: 3px 8px; }
  #ground { overflow: visible; }
  #field { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 14px 8px; }
  #topbar { padding: 8px 12px; gap: 8px; }
  .brand span { display: none; }
  .era-box { padding-left: 8px; }
  .stats { margin-left: 0; }
  .xpbar { width: 50px; }
  .tab .tn { font-size: 9px; }
  .sprite .fruit { font-size: 26px; }
}
