:root {
  --bg: #8fcf6a;
  --panel: #fffaf2;
  --panel-2: #fff1df;
  --ink: #4a3b5c;
  --muted: #8a7c99;
  --line: #f0d9c2;
  --pri: #ff8fab;
  --pri-d: #e5678a;
  --blue: #6ec6ff;
  --gold: #ffb703;
  --gem: #c77dff;
  --ok: #52b788;
  --bad: #e63946;
  --radius: 16px;
  --shadow: 0 6px 0 rgba(90, 60, 110, 0.18), 0 10px 24px rgba(60, 40, 80, 0.2);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); font-family: 'Baloo 2', 'Segoe UI', system-ui, sans-serif; color: var(--ink); user-select: none; }
#app { position: fixed; inset: 0; }
#game3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; background: #f6f7f9; color: #2f3442; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }

/* ---------- HUD ---------- */
.hud-top { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none !important; }
.hud-top > * { pointer-events: auto; }
.hud-left { display: flex; align-items: center; gap: 8px; background: rgba(255,250,242,0.95); padding: 6px 12px 6px 6px; border-radius: 40px; box-shadow: var(--shadow); }
.lvl-badge { width: 44px; height: 44px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd166, #f77f00); display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; border: 3px solid #fff; text-shadow: 0 2px 0 rgba(0,0,0,0.2); }
.hud-col { display: flex; flex-direction: column; gap: 2px; min-width: 150px; }
.exp-bar { position: relative; height: 16px; background: #e8dff5; border-radius: 10px; overflow: hidden; }
.exp-bar > div { height: 100%; background: linear-gradient(90deg, #4cc9f0, #4895ef); border-radius: 10px; transition: width .3s; }
.exp-bar span { position: absolute; inset: 0; font-size: 11px; font-weight: 700; display: grid; place-items: center; color: #2b2d42; }
.hud-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.stars { color: #ffb703; letter-spacing: 1px; text-shadow: 0 1px 0 #c77700; }
.stars .empty { color: #ddd2e6; text-shadow: none; }
.stars .half { background: linear-gradient(90deg, #ffb703 50%, #ddd2e6 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stars.small { font-size: 12px; }
.hud-right { display: flex; gap: 6px; align-items: center; }
.pill { background: rgba(255,250,242,0.95); padding: 6px 14px; border-radius: 30px; font-weight: 800; font-size: 16px; box-shadow: var(--shadow); white-space: nowrap; }
.pill.gold span { color: #c77700; } .pill.gem span { color: #9d4edd; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; border: 3px solid #fff; background: #fffaf2; box-shadow: var(--shadow); font-size: 18px; display: grid; place-items: center; transition: transform .1s; }
.icon-btn:active { transform: scale(0.9); }
.event-banner { align-self: center; background: linear-gradient(90deg, #ff8fab, #ffb703); color: #fff; padding: 6px 16px; border-radius: 30px; font-size: 14px; box-shadow: var(--shadow); animation: pulse 1.5s infinite; text-shadow: 0 1px 0 rgba(0,0,0,0.2); }
.event-banner span { background: rgba(255,255,255,0.3); padding: 0 8px; border-radius: 10px; margin-left: 6px; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.side-tools { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 8px; }

/* ---------- Bottom bar ---------- */
.bottom-bar { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; background: rgba(255,250,242,0.96); padding: 8px; border-radius: 24px; box-shadow: var(--shadow); max-width: calc(100% - 16px); overflow-x: auto; }
.bar-btn { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 6px 8px; border: none; border-radius: 16px; background: linear-gradient(180deg, #fff, #ffeedd); box-shadow: 0 3px 0 #f0d0b0; transition: transform .1s; }
.bar-btn:hover { transform: translateY(-3px); }
.bar-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #f0d0b0; }
.bar-ic { font-size: 26px; line-height: 1.1; }
.bar-name { font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge { position: absolute; top: -4px; right: -2px; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 800; padding: 0 6px; border: 2px solid #fff; }

/* ---------- Buttons ---------- */
.btn { border: none; border-radius: 12px; padding: 7px 12px; font-weight: 700; font-size: 13px; background: #f3e8ff; box-shadow: 0 3px 0 #d8c4ee; transition: transform .08s; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #d8c4ee; }
.btn.primary { background: var(--pri); color: #fff; box-shadow: 0 3px 0 var(--pri-d); }
.btn.danger { background: #ffd6d6; color: #b42330; box-shadow: 0 3px 0 #f2a8a8; }
.btn.gem { background: #e9d5ff; color: #6b21a8; box-shadow: 0 3px 0 #c9a5f0; }
.btn.on { background: #c7f0d8; color: #1b7344; box-shadow: 0 3px 0 #92d6ad; }
.btn.exit { background: var(--ok); color: #fff; box-shadow: 0 3px 0 #2d8a5f; }
.btn.small { padding: 2px 7px; font-size: 11px; }
.btn.wide { width: 100%; margin-top: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.btn-row.center { justify-content: center; }
.btn-col { display: flex; flex-direction: column; gap: 5px; }
.close-btn { border: none; background: #ffd6e0; width: 34px; height: 34px; border-radius: 50%; font-size: 16px; font-weight: 800; color: #c9184a; }
.close-btn.small { position: absolute; right: 8px; top: 8px; width: 26px; height: 26px; font-size: 12px; }

/* ---------- Panels ---------- */
.panel-wrap { position: absolute; inset: 0; background: rgba(60, 40, 80, 0.35); display: grid; place-items: center; padding: 12px; z-index: 10; }
#modal-wrap { z-index: 20; }
.panel { width: min(860px, 100%); max-height: min(88vh, 760px); display: flex; flex-direction: column; background: var(--panel); border-radius: 24px; border: 4px solid #fff; box-shadow: var(--shadow); animation: popIn .25s cubic-bezier(.2,1.6,.4,1); overflow: hidden; }
.panel.modal { width: min(480px, 100%); padding: 18px; overflow-y: auto; text-align: center; }
@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: linear-gradient(90deg, #ffc8dd, #bde0fe); }
.panel-head h2 { margin: 0; font-size: 22px; color: #5a3d7a; }
.panel-body { padding: 12px 16px 18px; overflow-y: auto; }
.panel-body h4 { margin: 14px 0 6px; }
.panel-info { background: var(--panel-2); border: 2px dashed var(--line); border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 6px; }
.tab { border: none; border-radius: 12px; padding: 6px 12px; font-weight: 700; background: #f3e8ff; white-space: nowrap; }
.tab.active { background: var(--pri); color: #fff; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; justify-content: center; }
.chip { display: inline-block; background: #f3e8ff; border-radius: 10px; padding: 3px 9px; margin: 3px; font-size: 13px; font-weight: 600; }
.chip.ok { background: #c7f0d8; }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 4px 0; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--pri); }
.mini-bar { flex: 1; height: 9px; background: #ece3f5; border-radius: 6px; overflow: hidden; min-width: 60px; }
.mini-bar > div { height: 100%; border-radius: 6px; transition: width .3s; }
.stat-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; margin: 3px 0; }
.stat-row > span:first-child { width: 130px; white-space: nowrap; }
.stat-row b { width: 22px; text-align: right; }
.big-ic { font-size: 34px; line-height: 1; }
.hint { font-size: 12.5px; color: #c9184a; font-weight: 600; margin-top: 4px; }

/* staff cards */
.staff-card { background: #fff; border-radius: 16px; padding: 10px; border: 3px solid var(--rar, #ddd); position: relative; }
.info-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.info-head canvas { border-radius: 14px; background: linear-gradient(180deg, #e0f2ff, #ffe5ef); flex-shrink: 0; }
.info-head h3 { margin: 0; font-size: 17px; }
.rarity { color: #fff; font-size: 10px; padding: 1px 7px; border-radius: 8px; vertical-align: middle; }

/* cooking */
.stoves { display: flex; gap: 8px; flex-wrap: wrap; }
.stove { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 6px 10px; display: flex; flex-direction: column; font-weight: 700; font-size: 13px; }
.stove.sel { border-color: var(--pri); background: #fff0f5; }
.stove small { color: var(--muted); font-weight: 600; }
.manual-box { margin-top: 10px; display: flex; align-items: center; gap: 10px; background: #fff3bf; padding: 8px 12px; border-radius: 14px; }
.recipe-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; }
.recipe-card, .recipe-book, .ing-card, .mission { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px 10px; border: 2px solid var(--line); }
.r-ic { font-size: 30px; }
.r-ic.big { font-size: 40px; }
.r-body { flex: 1; min-width: 0; }
.ings { display: flex; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.ings span small { font-size: 10px; color: var(--muted); }
.ings .miss { color: var(--bad); }
.locked { opacity: 0.6; filter: grayscale(0.5); }
.need { margin: 8px 0; }
.tray { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin: 10px 0; }
.ing { border: 3px solid #fff; background: #fff0e0; border-radius: 16px; padding: 8px 4px; font-size: 30px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 3px 0 #f0d0b0; }
.ing small { font-size: 11px; font-weight: 700; }
.ing.picked { background: #c7f0d8; border-color: #52b788; }
.ing.shake { animation: shake .35s; background: #ffd6d6; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* shop / missions / collection */
.ings-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.ing-card > div:nth-child(2) { flex: 1; }
.deal { background: #fff; border-radius: 16px; padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; border: 2px solid var(--line); }
.sale { color: var(--bad); font-weight: 800; }
.mission { margin-bottom: 8px; }
.mission.done { border-color: var(--ok); background: #f0fff5; }
.mission.claimed { opacity: 0.6; }
.mission .reward { font-weight: 700; font-size: 13px; white-space: nowrap; }
.col-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.col-item { background: #fff; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; border: 2px solid var(--line); }
.col-item small { color: var(--muted); }
.wardrobe { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.preview canvas { background: linear-gradient(180deg, #e0f2ff, #ffe5ef); border-radius: 20px; display: block; margin: 0 auto; }
.look-grid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
.look { position: relative; border: 2px solid var(--line); border-radius: 14px; background: linear-gradient(180deg, #e0f2ff, #ffe5ef); padding: 2px; }
.look canvas { display: block; }
.look .btn { position: absolute; top: 2px; right: 2px; }
.look.sel { border-color: var(--pri); box-shadow: 0 0 0 2px var(--pri); }
div.look { cursor: pointer; }
.wardrobe2 { display: flex; gap: 14px; align-items: flex-start; }
.w-left { flex: 0 0 200px; display: flex; flex-direction: column; align-items: center; gap: 8px; position: sticky; top: 0; }
.w-right { flex: 1; min-width: 0; }
.w-right h4 { margin: 8px 0 4px; }
.w-due { font-size: 13px; color: var(--bad); font-weight: 700; text-align: center; }
.w-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.w-item { border: 2px solid var(--line); border-radius: 14px; background: #fff; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: inherit; color: inherit; cursor: pointer; }
.w-item.sel { border-color: var(--pri); background: #fff0f5; box-shadow: 0 0 0 2px var(--pri); }
.w-ic { font-size: 26px; line-height: 1.1; }
.w-name { font-weight: 700; font-size: 13px; text-align: center; }
.w-cost { font-size: 12px; color: var(--muted); }
.w-item.owned .w-cost { color: var(--ok); font-weight: 700; }
.w-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.w-chip { border: 2px solid var(--line); border-radius: 999px; background: #fff; padding: 4px 10px; font-family: inherit; font-weight: 700; color: inherit; cursor: pointer; }
.w-chip.sel { background: var(--pri); border-color: var(--pri); color: #fff; }
.w-swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.w-sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.w-sw.sel { box-shadow: 0 0 0 3px var(--pri); }
@media (max-width: 640px) {
  .wardrobe2 { flex-direction: column; align-items: stretch; }
  .w-left { position: static; flex: none; }
}
.help { font-size: 14px; padding-left: 20px; }
.levelup .burst { font-size: 64px; animation: popIn .5s; }
.levelup h2 { margin: 4px 0; color: #f77f00; font-size: 28px; }
.big-gold { font-size: 32px; font-weight: 800; color: #c77700; margin: 10px 0; }
.unlock-list { margin: 10px 0; }

/* ---------- Info popup ---------- */
.popup { position: absolute; right: 64px; top: 76px; width: 320px; max-width: calc(100% - 16px); background: var(--panel); border: 3px solid #fff; border-radius: 20px; padding: 12px; box-shadow: var(--shadow); animation: popIn .2s; z-index: 5; max-height: calc(100% - 180px); overflow-y: auto; }
.popup .staff-card { border: none; padding: 0; }
.popup .btn { margin-top: 6px; }

/* ---------- Build bar ---------- */
.build-bar { position: absolute; bottom: 8px; left: 8px; right: 8px; background: rgba(255,250,242,0.97); border-radius: 22px; padding: 8px 10px; box-shadow: var(--shadow); max-width: 1100px; margin: 0 auto; }
.b-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.b-top .tabs { flex: 1; margin-bottom: 0; }
.b-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 4px 0 6px; }
.b-hint { font-size: 13px; flex: 1; min-width: 200px; }
.b-hint em { color: var(--bad); font-style: normal; font-weight: 700; }
.b-list-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: #8a6a4a; margin: 0 2px 2px; }
.b-list-head .btn { padding: 3px 12px; font-size: 12.5px; }
.b-items { --row: 140px; display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); grid-auto-rows: var(--row); gap: 8px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; max-height: calc(var(--row) + 10px); padding: 4px 2px 6px; scroll-snap-type: y mandatory; scroll-padding-top: 4px; transition: max-height .25s ease; }
.expanded .b-items { max-height: min(58vh, calc(var(--row) * 4 + 50px)); }
.b-items > .b-expand { grid-column: 1 / -1; }
.b-item { position: relative; scroll-snap-align: start; border: 3px solid #fff; border-radius: 16px; background: #fff3e6; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 3px 0 #f0d0b0; }
.b-item.sel { border-color: var(--pri); background: #ffe5ef; }
.b-ic.b-model { width: 72px; height: 72px; background: radial-gradient(circle at 50% 60%, #fffaf2 0%, #ffe9d2 75%); }
.b-ic.b-model img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.b-ic { font-size: 30px; width: 46px; height: 46px; display: grid; place-items: center; border-radius: 12px; }
.b-name { font-size: 11.5px; font-weight: 700; text-align: center; line-height: 1.15; min-height: 26px; }
.b-cost { font-size: 11.5px; font-weight: 800; color: #c77700; }
.b-tag { position: absolute; top: 3px; left: 5px; font-size: 10px; }
.b-play { position: absolute; top: 22px; right: 4px; display: flex; flex-direction: column; align-items: center; padding: 2px 3px; border-radius: 8px; background: linear-gradient(160deg, #9d4edd, #f15bb5); color: #fff; font-size: 12px; line-height: 1.05; box-shadow: 0 2px 0 #6a2c9a; }
.b-play b { font-size: 9.5px; font-weight: 800; }
.b-owned { position: absolute; top: 3px; right: 5px; font-size: 10px; background: #fff; border-radius: 6px; padding: 0 4px; }
.b-size { position: absolute; top: 58px; right: 8px; font-size: 10px; font-weight: 800; background: var(--blue); color: #fff; border-radius: 6px; padding: 0 4px; }
.b-expand { padding: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }

/* ---------- Toasts ---------- */
.toasts { position: absolute; top: 70px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none !important; z-index: 30; width: max-content; max-width: 92vw; }
.toast { background: #fff; padding: 8px 16px; border-radius: 20px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); animation: toastIn .3s cubic-bezier(.2,1.6,.4,1); transition: opacity .4s, transform .4s; text-align: center; }
.toast.success { background: #d8f3dc; color: #1b4332; }
.toast.error { background: #ffe0e3; color: #a4161a; }
.toast.special { background: linear-gradient(90deg, #ffc8dd, #bde0fe); color: #4a2a6a; }
.toast.reward { background: #fff3bf; color: #7a4f01; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { transform: translateY(-20px) scale(0.8); opacity: 0; } }

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
  .hud-col { min-width: 100px; }
  .lvl-badge { width: 36px; height: 36px; font-size: 16px; }
  .pill { padding: 4px 10px; font-size: 13px; }
  .icon-btn { width: 36px; height: 36px; font-size: 15px; }
  .hud-top { flex-wrap: wrap; }
  .event-banner { order: 3; width: 100%; text-align: center; font-size: 12px; }
  .bar-btn { min-width: 58px; padding: 4px; }
  .bar-ic { font-size: 22px; }
  .bar-name { font-size: 10px; }
  .side-tools { top: auto; bottom: 96px; transform: none; right: 8px; }
  .popup { right: 8px; left: 8px; width: auto; top: auto; bottom: 92px; max-height: 50%; }
  .panel { max-height: 92vh; border-radius: 18px; }
  .recipe-list { grid-template-columns: 1fr; }
  .stat-row > span:first-child { width: 110px; }
  .b-items { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
}
.w-item { position: relative; }
.w-thumb { width: 76px; height: 76px; border-radius: 10px; background: linear-gradient(180deg, #fdf3f8, #eef3ff); }
.w-badge { position: absolute; top: 4px; left: 6px; font-size: 15px; line-height: 1; }

/* ---------- Third-person tour ---------- */
#ui.touring .bottom-bar, #ui.touring .side-tools, #ui.touring .build-bar, #ui.touring .popup { display: none !important; }
#ui > .tour-ui { position: absolute; inset: 0; pointer-events: none; }
.tour-ui > * { pointer-events: auto; }
.tour-top { position: absolute; top: 64px; right: 10px; display: flex; gap: 8px; }
.tour-stick { position: absolute; left: 28px; bottom: 28px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,0.28); border: 3px solid rgba(255,255,255,0.7); box-shadow: var(--shadow); touch-action: none; display: grid; place-items: center; }
.tour-knob { width: 58px; height: 58px; border-radius: 50%; background: rgba(255,250,242,0.95); box-shadow: 0 3px 8px rgba(0,0,0,0.25); pointer-events: none; }
.tour-jump { position: absolute; right: 32px; bottom: 36px; width: 76px; height: 76px; border-radius: 50%; border: 3px solid #fff; background: rgba(255,214,10,0.92); font-size: 32px; font-weight: 800; color: #5a3d00; box-shadow: var(--shadow); touch-action: none; }
.tour-jump:active { transform: scale(0.92); }
.tour-hint { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); padding: 4px 12px; border-radius: 12px; background: rgba(40,30,60,0.55); color: #fff; font-size: 12px; white-space: nowrap; pointer-events: none !important; }
@media (max-width: 700px), (pointer: coarse) { .tour-hint { display: none; } .tour-top { top: 92px; } }
/* outdoor build bar inside the tour (joystick / jump / hint make room for it) */
.tour-build { position: absolute; bottom: 8px; left: 8px; right: 8px; background: rgba(255,250,242,0.97); border-radius: 22px; padding: 8px 10px; box-shadow: var(--shadow); max-width: 1100px; margin: 0 auto; }
.tour-ui.building .tour-stick, .tour-ui.building .tour-jump, .tour-ui.building .tour-hint, .tour-ui.building .tour-act { display: none; }
.tour-act { position: absolute; bottom: 126px; right: 20px; max-width: min(340px, calc(100% - 200px)); padding: 10px 18px; border-radius: 999px; border: 3px solid #fff; background: rgba(255,214,10,0.95); color: #5a3d00; font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: var(--shadow); touch-action: none; }
.tour-act b { display: inline-block; min-width: 22px; margin-right: 4px; padding: 0 5px; border-radius: 6px; background: #5a3d00; color: #fff; font-size: 13px; }
.tour-act:active { transform: scale(0.95); }
.tour-act.busy { background: linear-gradient(90deg, rgba(140,233,154,0.97) calc(var(--p, 0) * 100%), rgba(255,250,242,0.95) 0); color: #2b5a33; }
.skill-row { display: grid; grid-template-columns: 1fr auto auto; gap: 2px 10px; align-items: center; margin: 8px 0; }
.skill-row .skill-name { font-weight: 700; }
.skill-row .skill-bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: rgba(90,74,138,0.15); overflow: hidden; }
.skill-row .skill-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffd166, #06d6a0); }
.skill-row .muted { grid-column: 1 / -1; font-size: 12px; }
@media (max-width: 700px), (pointer: coarse) { .tour-act { right: 16px; max-width: calc(100% - 190px); font-size: 13px; padding: 8px 14px; } .tour-act b { display: none; } }

/* ---------- Auth (login / register) ---------- */
/* white, neutral look (fits everyone); a random chibi cast stands around the card */
#auth { --a-ink: #2f3442; --a-mute: #6b7180; --a-line: #e4e7ed; position: absolute; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; overflow-y: auto; color: var(--a-ink);
  background: radial-gradient(circle, rgba(47,52,66,0.07) 1px, transparent 1.5px) 0 0 / 22px 22px, radial-gradient(ellipse at 50% 40%, #ffffff 0%, #f6f7f9 60%, #eceef2 100%); }
.auth-stage { position: absolute; inset: 0; overflow: hidden; }
.auth-chibi { position: absolute; width: calc(150px * var(--s)); height: calc(183px * var(--s)); padding: 0; border: none; background: none; transform: translate(-50%, -50%); cursor: pointer; animation: chibiBob 3.2s ease-in-out var(--d) infinite; }
.auth-chibi::before { content: ''; position: absolute; left: 22%; right: 22%; bottom: 2%; height: 9%; border-radius: 50%; background: radial-gradient(rgba(47,52,66,0.18), transparent 70%); }
.auth-chibi canvas { position: relative; width: 100%; height: 100%; transition: transform .2s; }
.auth-chibi:hover canvas { transform: scale(1.06) rotate(-2deg); }
.auth-chibi.pop canvas { animation: chibiPop .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes chibiBob { 50% { transform: translate(-50%, calc(-50% - 7px)); } }
@keyframes chibiPop { from { transform: scale(0.4) rotate(-12deg); opacity: 0; } }
.auth-wrap { position: relative; z-index: 1; width: min(380px, 100%); }
.auth-card { width: 100%; max-height: none; padding: 22px 24px 16px; gap: 10px; text-align: center; background: rgba(255,255,255,0.92); backdrop-filter: blur(6px); border: 1px solid var(--a-line); border-radius: 24px; box-shadow: 0 18px 40px rgba(47,52,66,0.12), 0 2px 0 #e9ebf0; color: var(--a-ink); }
.auth-card h2 { margin: 0; font-size: 26px; color: var(--a-ink); }
.auth-sub { margin: -6px 0 2px; font-size: 13px; color: var(--a-mute); }
.auth-logo { font-size: 44px; line-height: 1; }
.auth-tabs { display: flex; gap: 6px; justify-content: center; padding: 4px; border-radius: 14px; background: #f1f2f5; }
.auth-tabs .btn { flex: 1; font-size: 15px; padding: 7px; background: transparent; color: var(--a-mute); box-shadow: none; }
.auth-tabs .btn.on { background: #fff; color: var(--a-ink); box-shadow: 0 2px 6px rgba(47,52,66,0.12); }
.auth-card label { display: flex; flex-direction: column; gap: 3px; text-align: left; font-weight: 700; font-size: 14px; }
.auth-card input { font: inherit; font-weight: 500; padding: 9px 12px; border: 1.5px solid var(--a-line); border-radius: 12px; background: #f8f9fb; color: var(--a-ink); user-select: text; transition: border-color .15s, background .15s; }
.auth-card input:focus { outline: none; border-color: var(--a-ink); background: #fff; }
.auth-card .btn.primary { background: var(--a-ink); color: #fff; box-shadow: 0 3px 0 #161922; }
.auth-card .btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 #161922; }
.auth-card .btn.wide { font-size: 16px; padding: 10px; }
.auth-error { margin: 0; min-height: 1.2em; color: #d6334a; font-weight: 700; font-size: 14px; }
.auth-card .muted { margin: 0; font-size: 12px; color: var(--a-mute); }
.auth-dice { align-self: center; margin-top: 2px; padding: 4px 12px; border: none; border-radius: 999px; background: none; color: var(--a-mute); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.auth-dice:hover { background: #f1f2f5; color: var(--a-ink); }
@media (max-width: 759px) { #auth { padding: 150px 16px 130px; } }

/* ---------- Friends & realtime chat ---------- */
.friend-search { display: flex; gap: 6px; margin: 6px 0; }
.friend-search input { flex: 1; min-width: 0; font: inherit; padding: 6px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); user-select: text; }
.friend-search input:focus { outline: none; border-color: var(--pri); }
.friend-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0 10px; }
.friend-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--panel-2); border-radius: 14px; }
.friend-row .btn-row { margin: 0; flex-wrap: nowrap; }
.friend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.friend-dot { width: 10px; height: 10px; border-radius: 50%; background: #cfc3dc; flex: none; }
.friend-dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(82,183,136,0.25); }
.friend-online { color: var(--ok); font-weight: 700; font-size: 12px; }

#ui > .chat-box { position: absolute; left: 10px; bottom: 92px; width: min(320px, calc(100% - 20px)); display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 16px; background: rgba(40,30,60,0.55); color: #fff; font-size: 13px; z-index: 5; }
#ui > .chat-box.touring { bottom: 180px; }
.chat-head { display: flex; align-items: center; gap: 6px; }
.chat-who { flex: 1; min-width: 0; font-size: 12px; font-weight: 700; opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-toggle { flex: none; display: flex; align-items: center; gap: 4px; border: none; background: rgba(255,255,255,0.15); color: #fff; border-radius: 8px; padding: 1px 8px; font-size: 14px; line-height: 1.4; cursor: pointer; }
.chat-toggle:active { transform: scale(0.9); }
.chat-unread { min-width: 16px; padding: 0 4px; border-radius: 8px; background: #ff5d73; font-size: 11px; font-weight: 800; text-align: center; }
.chat-body { display: flex; flex-direction: column; gap: 4px; }
#ui > .chat-box.collapsed { width: auto; max-width: min(320px, calc(100% - 20px)); padding: 4px 8px; }
#ui > .chat-box.collapsed .chat-body { display: none; }
.chat-log { max-height: 120px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; user-select: text; }
.chat-log:empty { display: none; }
.chat-line { line-height: 1.3; word-break: break-word; }
.chat-line b { color: #ffd166; }
.chat-line.mine b { color: #7dffb0; }
.chat-line.sys { opacity: 0.7; font-style: italic; }
.chat-emotes { display: flex; gap: 2px; flex-wrap: wrap; }
.chat-emote { border: none; background: rgba(255,255,255,0.15); border-radius: 8px; font-size: 16px; padding: 1px 4px; }
.chat-emote:active { transform: scale(0.9); }
.chat-form { display: flex; gap: 4px; }
.chat-form input { flex: 1; min-width: 0; font: inherit; padding: 4px 10px; border: none; border-radius: 10px; background: rgba(255,250,242,0.95); color: var(--ink); user-select: text; }
@media (max-width: 700px), (pointer: coarse) { #ui > .chat-box.touring { bottom: 170px; width: min(260px, calc(100% - 20px)); } .chat-log { max-height: 80px; } }
