:root { --gold: #f2c45a; --ink: #f3ead8; --bg: #0d0b10; --panel: rgba(20, 16, 26, 0.94); --edge: #6b4f2a; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden;
  font: 15px/1.35 Georgia, "Times New Roman", serif; user-select: none; -webkit-user-select: none; touch-action: none; }
canvas#world { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }
.hidden { display: none !important; }
button { font: inherit; color: var(--ink); border: 1px solid var(--edge); border-radius: 10px; cursor: pointer;
  background: linear-gradient(#3a2c1c, #22190f); padding: 8px 14px; }
button:active { filter: brightness(1.3); }
button.main { font-size: 18px; padding: 12px 26px; background: linear-gradient(#8a5a22, #4a2f10); border-color: var(--gold); }
button.small { font-size: 13px; padding: 6px 10px; }
button.round { width: 46px; height: 46px; border-radius: 50%; padding: 0; font-size: 20px; }
.panel { position: fixed; inset: 0; background: var(--panel); overflow-y: auto; padding: 16px 16px 40px;
  padding-top: max(16px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: center; gap: 12px; z-index: 5; }
h1 { margin: 6px 0 0; color: var(--gold); font-weight: normal; letter-spacing: 1px; text-shadow: 0 2px 8px #000; }
h2 { margin: 0; color: var(--gold); font-weight: normal; }
.err { color: #ff8a7a; min-height: 1.2em; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; max-width: 520px; }
#loading { justify-content: center; background: radial-gradient(circle at 50% 40%, #2a1d12, #0d0b10 70%); }

/* creator */
#preview { width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(#3a2b1b, #120d09 70%);
  box-shadow: 0 0 30px #000 inset, 0 0 0 1px var(--edge); }
#classes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: 520px; }
.cls { width: 150px; padding: 10px; border-radius: 12px; border: 1px solid #3c2e1d; background: #1c1610; text-align: center; }
.cls.on { border-color: var(--gold); box-shadow: 0 0 12px rgba(242, 196, 90, 0.35); }
.cls b { color: var(--gold); display: block; font-size: 17px; font-weight: normal; }
.cls small { opacity: 0.8; }
#looks { width: 100%; max-width: 520px; display: flex; flex-direction: column; gap: 8px; }
.look { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.look span { width: 90px; opacity: 0.85; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #000; box-shadow: 0 0 0 1px #555; }
.sw.on { box-shadow: 0 0 0 2px var(--gold); }
.opt { padding: 5px 9px; border-radius: 8px; border: 1px solid #3c2e1d; background: #1c1610; font-size: 13px; }
.opt.on { border-color: var(--gold); color: var(--gold); }
#name { font: inherit; font-size: 18px; text-align: center; padding: 10px; border-radius: 10px; width: 240px;
  color: var(--ink); background: #120e0a; border: 1px solid var(--edge); outline: none; user-select: text; }

/* hud */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#hud > * { pointer-events: auto; }
#top { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex;
  flex-direction: column; gap: 4px; max-width: 360px; pointer-events: none; }
.bar { position: relative; height: 16px; border-radius: 8px; background: rgba(0, 0, 0, 0.55); overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12); }
.bar.thin { height: 6px; }
.bar span { position: absolute; inset: 0; font-size: 11px; line-height: 15px; text-align: center; text-shadow: 0 1px 2px #000; }
.fill { height: 100%; width: 0; transition: width 0.15s; }
.fill.hp { background: linear-gradient(#e0493a, #8c1d16); }
.fill.mp { background: linear-gradient(#4b8cf0, #1d3f8c); }
.fill.xp { background: linear-gradient(#f2c45a, #a57a1c); }
#info { font-size: 13px; text-shadow: 0 1px 3px #000; }
#stick { position: absolute; left: 22px; bottom: max(26px, env(safe-area-inset-bottom)); width: 130px; height: 130px;
  border-radius: 50%; background: radial-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.15); touch-action: none; }
#knob { position: absolute; left: 40px; top: 40px; width: 50px; height: 50px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 240, 210, 0.55), rgba(140, 100, 50, 0.4));
  border: 1px solid rgba(255, 230, 180, 0.5); }
#skills { position: absolute; right: 16px; bottom: max(22px, env(safe-area-inset-bottom)); display: grid;
  grid-template-columns: 64px 64px; gap: 10px; touch-action: none; }
.skill { position: relative; width: 64px; height: 64px; border-radius: 50%; font-size: 12px; line-height: 1.1;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 4px; overflow: hidden;
  background: radial-gradient(circle at 40% 30%, #5a4026, #20160c); border: 1px solid var(--gold); }
.skill.big { grid-column: 2; grid-row: 1 / span 2; width: 64px; height: 138px; border-radius: 32px; font-size: 14px; }
.skill .cd { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); height: 0; }
#bagbtn { position: absolute; right: 16px; top: max(10px, env(safe-area-inset-top)); }
#potion { position: absolute; right: 162px; bottom: max(26px, env(safe-area-inset-bottom)); width: 54px; height: 54px;
  font-size: 15px; background: radial-gradient(circle at 40% 30%, #7a2a22, #2a0c08); border-color: #e0493a; }
#toast { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); padding: 8px 14px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.7); color: var(--gold); opacity: 0; transition: opacity 0.4s; pointer-events: none;
  text-align: center; max-width: 80vw; }
#toast.on { opacity: 1; }

/* bag */
#stats { width: 100%; max-width: 520px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 14px; }
#stats .pt { display: flex; justify-content: space-between; align-items: center; }
#stats button { padding: 0 8px; font-size: 14px; }
#worn, #items { width: 100%; max-width: 520px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.item { padding: 7px 9px; border-radius: 9px; background: #17120d; border: 1px solid #33271a; font-size: 13px; }
.item .slot { opacity: 0.6; font-size: 11px; display: block; }
#itemcard { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); width: min(92vw, 420px);
  background: #120e0a; border: 1px solid var(--gold); border-radius: 14px; padding: 12px; z-index: 6; }
#itemcard .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
#invitelink { font-size: 12px; word-break: break-all; user-select: text; }
