/* world.css - HUD, chat, modals, avatar editor. The island itself is drawn on the canvas. */
:root {
  --ink: #2b2220; --paper: #fffaf0; --paper-2: #fff3dc; --line: #e8d9bf; --muted: #7a6a5a;
  --accent: #2563eb; --accent-ink: #fff; --coral: #ef5a5a; --mint: #2fb57d; --sun: #f2c94c;
  --radius: 16px; --shadow: 0 10px 30px rgba(43, 34, 32, 0.18);
  --font: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #5fc0e0; color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; cursor: default; }
#world.pointer { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- HUD */
#hud { position: fixed; top: 12px; left: 12px; right: 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; pointer-events: none; z-index: 20; }
#hud > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 6px 14px 6px 8px; box-shadow: var(--shadow); }
.brand .mark { width: 30px; height: 30px; border-radius: 50%; background: var(--sun); border: 2px solid var(--ink); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: -0.01em; }
.brand .online { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.brand .online::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #9aa; }
.brand.live .online::before { background: var(--mint); box-shadow: 0 0 0 3px rgba(47, 181, 125, 0.25); }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.hud-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.hbtn { background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 7px 12px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 6px; transition: transform .12s; }
.hbtn:hover { transform: translateY(-1px); background: #fff; }
.hbtn:active { transform: translateY(1px); }
.hbtn.accent { background: var(--accent); color: #fff; border-color: #1b4fc0; }
.hbtn .ic { font-size: 15px; }
#minimap { width: 200px; height: 134px; border: 2px solid var(--ink); border-radius: 12px; box-shadow: var(--shadow); background: #7fb867; cursor: pointer; }
.places-pop { position: absolute; top: 46px; right: 0; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; min-width: 240px; display: none; z-index: 30; }
.places-pop.open { display: block; }
.places-pop button { display: flex; width: 100%; align-items: center; gap: 10px; background: none; border: 0; border-radius: 10px; padding: 8px 10px; text-align: left; font-weight: 700; }
.places-pop button:hover { background: var(--paper-2); }
.places-pop button small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.places-pop .ic { font-size: 20px; width: 26px; text-align: center; }

/* ---------- tooltip / toasts / hint */
#tip { position: fixed; z-index: 25; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: 999px; transform: translate(14px, 18px); white-space: nowrap; display: none; }
#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 8px 16px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); animation: pop .25s ease-out; max-width: 92vw; text-align: center; }
.toast.err { background: #ffe1e1; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#hint { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 15; background: rgba(43, 34, 32, 0.78); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; pointer-events: none; transition: opacity .4s; max-width: 90vw; text-align: center; }

/* ---------- NPC dialog */
#dialog { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); background: var(--paper); border: 3px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow); padding: 14px 16px 12px; z-index: 30; display: none; }
#dialog.open { display: block; animation: rise .22s ease-out; }
@keyframes rise { from { transform: translate(-50%, 16px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
#dialog .who { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
#dialog .who canvas { width: 48px; height: 48px; }
#dialog .who b { font-size: 15px; }
#dialog .who small { color: var(--muted); }
#dialog p { margin: 0 0 12px; font-size: 15px; line-height: 1.45; }
#dialog .acts { display: flex; flex-wrap: wrap; gap: 8px; }
#dialog .acts button { background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13px; }
#dialog .acts button.primary { background: var(--accent); color: #fff; border-color: #1b4fc0; }
#dialog .acts button:hover { transform: translateY(-1px); }
#dialog .x { position: absolute; top: 8px; right: 10px; background: none; border: 0; font-size: 20px; color: var(--muted); }

/* ---------- chat */
#chat { position: fixed; left: 12px; bottom: 12px; width: min(340px, calc(100vw - 24px)); z-index: 20; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
#chat .head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--paper-2); border-bottom: 2px solid var(--line); cursor: pointer; font-weight: 800; font-size: 13px; }
#chat .head .cnt { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12px; }
#chat .head .chev { transition: transform .2s; }
#chat.collapsed .chev { transform: rotate(180deg); }
#chat .msgs { height: 190px; overflow-y: auto; padding: 8px 10px; font-size: 13px; line-height: 1.35; scroll-behavior: smooth; }
#chat.collapsed .msgs, #chat.collapsed .row, #chat.collapsed .emotes { display: none; }
.msg { margin: 0 0 5px; word-wrap: break-word; }
.msg b { margin-right: 4px; }
.msg.sys { color: var(--muted); font-style: italic; font-size: 12px; }
.msg.me b { color: var(--accent); }
.msg time { float: right; font-size: 10px; color: #b0a090; margin-left: 6px; }
#chat .row { display: flex; gap: 6px; padding: 8px; border-top: 2px solid var(--line); }
#chat input { flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 999px; padding: 8px 12px; background: #fff; outline: none; }
#chat input:focus { border-color: var(--accent); }
#chat .send { background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 0 14px; font-weight: 800; }
#chat .emotes { display: flex; gap: 4px; padding: 0 8px 8px; }
#chat .emotes button { background: #fff; border: 2px solid var(--line); border-radius: 10px; font-size: 16px; padding: 3px 7px; line-height: 1; }
#chat .emotes button:hover { border-color: var(--ink); }

/* ---------- modal */
#modal { position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center; background: rgba(43, 34, 32, 0.45); backdrop-filter: blur(3px); padding: 16px; }
#modal.open { display: flex; }
.mbox { width: min(860px, 100%); max-height: calc(100vh - 32px); background: var(--paper); border: 3px solid var(--ink); border-radius: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; animation: pop .22s ease-out; }
.mbox.wide { width: min(1100px, 100%); height: calc(100vh - 32px); }
.mhead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 2px solid var(--line); background: var(--paper-2); }
.mhead h2 { margin: 0; font-size: 17px; flex: 1; letter-spacing: -0.01em; }
.mhead .x { background: none; border: 2px solid var(--ink); border-radius: 50%; width: 32px; height: 32px; font-size: 18px; line-height: 1; display: grid; place-items: center; }
.mhead .ext { font-size: 12px; font-weight: 700; color: var(--accent); text-decoration: none; border: 2px solid var(--accent); border-radius: 999px; padding: 5px 10px; }
.mbody { overflow: auto; padding: 18px; flex: 1; line-height: 1.5; }
.mbody h3 { margin: 18px 0 8px; font-size: 15px; }
.mbody p { margin: 0 0 10px; }
.mbody a { color: var(--accent); }

/* about */
.about { display: grid; grid-template-columns: 220px 1fr; gap: 20px; }
.about img { width: 100%; border-radius: 16px; border: 3px solid var(--ink); }
.about .head { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; margin: 0 0 10px; line-height: 1.3; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; margin: 12px 0; }
.fact { background: #fff; border: 2px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.fact .ic { font-size: 18px; }
.fact small { display: block; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.linkrow { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13px; text-decoration: none; color: var(--ink); cursor: pointer; }
.pill:hover { background: var(--paper-2); }
.pill.accent { background: var(--accent); color: #fff; border-color: #1b4fc0; }

/* skills */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.card { background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.card .ic { font-size: 22px; }
.card b { display: block; margin: 4px 0 2px; }
.card p { font-size: 13px; color: #4a3f38; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--paper-2); border: 2px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; }

/* apps */
.apps { display: grid; grid-template-columns: 250px 1fr; gap: 0; height: 100%; }
.apps .list { border-right: 2px solid var(--line); overflow: auto; padding: 8px; background: var(--paper); }
.appbtn { display: flex; gap: 10px; align-items: center; width: 100%; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px 10px; text-align: left; margin-bottom: 6px; }
.appbtn:hover { border-color: var(--ink); }
.appbtn.active { border-color: var(--accent); background: #eff4ff; }
.appbtn .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; color: #fff; flex: none; }
.appbtn b { display: block; font-size: 14px; }
.appbtn small { display: block; color: var(--muted); font-size: 11px; }
.apps .view { position: relative; background: #fff; display: flex; flex-direction: column; }
.apps .view .bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 2px solid var(--line); font-size: 13px; background: var(--paper-2); }
.apps .view .bar .status { background: var(--mint); color: #fff; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 800; }
.apps .view .bar .status.dev { background: var(--sun); color: var(--ink); }
.apps .view .bar .status.soon { background: #7c5ce0; }
.apps .view .bar .status.site { background: var(--accent); }
.apps .view .bar .tag { flex: 1; color: #4a3f38; }
.apps .view .bar .back { display: none; }
.apps iframe { flex: 1; width: 100%; border: 0; background: #fff; }
.apps .loading { position: absolute; inset: 44px 0 0; display: grid; place-items: center; color: var(--muted); font-weight: 700; background: #fff; }
.apps .loading.off { display: none; }
.mbox.wide .mbody { padding: 0; overflow: hidden; }

/* forms */
form.inq { display: grid; gap: 10px; }
form.inq .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
form.inq label { display: grid; gap: 4px; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
form.inq input, form.inq select, form.inq textarea { border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; outline: none; font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 14px; }
form.inq input:focus, form.inq select:focus, form.inq textarea:focus { border-color: var(--accent); }
form.inq textarea { min-height: 120px; resize: vertical; }
form.inq .hp { position: absolute; left: -9999px; }
form.inq .foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
form.inq .foot small { color: var(--muted); }
.btn { background: var(--accent); color: #fff; border: 2px solid #1b4fc0; border-radius: 999px; padding: 10px 18px; font-weight: 800; }
.btn:disabled { opacity: .6; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--ink); }
ul.tight { margin: 6px 0 12px; padding-left: 20px; }
ul.tight li { margin-bottom: 4px; }
.sent { text-align: center; padding: 30px 10px; }
.sent .big { font-size: 46px; }

/* avatar editor + welcome */
.editor { display: grid; grid-template-columns: 200px 1fr; gap: 18px; }
.editor .preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.editor .preview canvas { width: 180px; height: 220px; background: linear-gradient(#bfe6f5, #f3e0b4); border: 3px solid var(--ink); border-radius: 18px; }
.editor .opts { display: grid; gap: 12px; }
.opt label { display: block; font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 5px; }
.sw { display: flex; flex-wrap: wrap; gap: 6px; }
.sw button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(0,0,0,.15); padding: 0; }
.sw button.on { border: 3px solid var(--ink); transform: scale(1.12); }
.sw button.txt { width: auto; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 700; background: #fff; text-transform: capitalize; }
.sw button.txt.on { background: var(--accent); color: #fff; border-color: #1b4fc0; transform: none; }
.editor input[type=text] { width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 9px 12px; background: #fff; outline: none; font-weight: 700; }
.editor input[type=text]:focus { border-color: var(--accent); }
.welcome { text-align: center; }
.welcome canvas { width: 150px; height: 190px; background: linear-gradient(#bfe6f5, #f3e0b4); border: 3px solid var(--ink); border-radius: 18px; }
.welcome h3 { margin: 10px 0 4px; font-size: 22px; }
.welcome p { color: #4a3f38; max-width: 460px; margin: 0 auto 14px; }
.welcome .acts { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* player card */
#pcard { position: fixed; z-index: 35; background: var(--paper); border: 2px solid var(--ink); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px; display: none; font-size: 13px; }
#pcard.open { display: block; }
#pcard b { display: block; margin-bottom: 6px; }
#pcard button { background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: 5px 10px; font-weight: 700; font-size: 12px; margin-right: 4px; }

/* status */
#status { position: fixed; top: 60px; left: 12px; z-index: 20; background: #ffe1e1; border: 2px solid var(--coral); border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700; display: none; }
#status.on { display: block; }
#loader { position: fixed; inset: 0; z-index: 60; background: #5fc0e0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px; transition: opacity .5s; }
#loader.off { opacity: 0; pointer-events: none; }

@media (max-width: 720px) {
  .brand h1 { display: none; }
  .brand .online { font-size: 11px; }
  .hbtn .lbl { display: none; }
  .hbtn { padding: 7px 10px; }
  #minimap { width: 130px; height: 88px; }
  #chat { width: calc(100vw - 24px); }
  #chat .msgs { height: 130px; }
  .about { grid-template-columns: 1fr; }
  .about img { max-width: 180px; }
  .editor { grid-template-columns: 1fr; }
  .editor .preview canvas { width: 140px; height: 170px; }
  .apps { grid-template-columns: 1fr; }
  .apps .list { border-right: 0; }
  .apps.viewing .list { display: none; }
  .apps:not(.viewing) .view { display: none; }
  .apps .view .bar .back { display: inline-block; }
  .apps .view .bar .tag { display: none; }
  form.inq .two { grid-template-columns: 1fr; }
  .mbody { padding: 14px; }
  #hint { bottom: auto; top: 64px; font-size: 12px; }
  #dialog { bottom: 12px; }
}
