/* ===================== Worldo — pixel RPG ===================== */
:root {
  --ink: #14101f;
  --ink-2: #1d1730;
  --panel: rgba(24, 18, 40, 0.92);
  --panel-line: #3a2f58;
  --parchment: #efe4c8;
  --gold: #e8c24b;
  --gold-dk: #b8912f;
  --red: #d3493f;
  --green: #5ab54a;
  --blue: #4a9de0;
  --text: #efe9ff;
  --text-dim: #b3a9cf;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0c0916;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; touch-action: none;
}
[hidden] { display: none !important; }

#game {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  display: block;
  image-rendering: pixelated;
  cursor: crosshair;
  background: #2a3d5c;
}

/* ---------- passcode gate ---------- */
.gate {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background:
    radial-gradient(1000px 700px at 50% -10%, #2a2050, transparent 65%),
    linear-gradient(180deg, #171029, #0c0916);
  transition: opacity .42s ease;
}
.gate.gate-out { opacity: 0; pointer-events: none; }
.gate-panel {
  width: 100%; max-width: 360px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 18px; padding: 30px 26px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.gate-word {
  margin: 0; font-size: 2.4rem; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(180deg, #ffe9a8, var(--gold) 55%, var(--gold-dk));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.gate-sub { margin: 0; color: var(--text-dim); font-size: .95rem; }
#gate-form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.gate-input {
  width: 100%; padding: 12px 14px; font-size: 1rem; text-align: center; letter-spacing: .18em;
  background: var(--ink); color: var(--text);
  border: 1.5px solid var(--panel-line); border-radius: 10px; outline: none;
}
.gate-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,194,75,.2); }
.gate-go { font-size: 1rem; padding: 12px; }
.gate-err { margin: 0; color: var(--red); font-size: .85rem; font-weight: 700; }
.gate-panel.gate-shake { animation: gateShake .4s ease; }
@keyframes gateShake {
  10%, 90% { transform: translateX(-2px); }
  30%, 70% { transform: translateX(5px); }
  50% { transform: translateX(-7px); }
}

/* ---------- landing / splash ---------- */
.landing {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: #0c0916;
  transition: opacity .42s ease;
}
.landing.landing-out { opacity: 0; pointer-events: none; }
.landing-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%; display: block; image-rendering: pixelated;
}
.landing-inner {
  position: relative; z-index: 1;
  width: 100%; max-width: 560px;
  display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center;
  background: rgba(16, 11, 26, 0.62); backdrop-filter: blur(3px);
  border: 1px solid var(--panel-line); border-radius: 20px; padding: 30px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.landing-lore { margin: 0; color: var(--text); font-size: 1.02rem; line-height: 1.5; max-width: 440px; }
.landing-links { display: flex; gap: 12px; align-items: center; }
.landing-links a { color: var(--gold); font-weight: 700; font-size: .92rem; text-decoration: none; }
.landing-links a:hover { text-decoration: underline; }
.landing-links span { color: var(--text-dim); }

/* ---------- overlays base ---------- */
.screen {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(1000px 700px at 50% -10%, #2a2050, transparent 65%),
    linear-gradient(180deg, #171029, #0c0916);
  overflow-y: auto;
}
.title-inner {
  width: 100%; max-width: 640px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  text-align: center;
}
.logo { display: flex; align-items: center; gap: 12px; }
.logo-mark { width: 48px; height: 48px; image-rendering: pixelated; filter: drop-shadow(0 3px 5px rgba(0,0,0,.55)); }
.logo-word {
  margin: 0; font-size: 3.2rem; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(180deg, #ffe9a8, var(--gold) 55%, var(--gold-dk));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.tagline { margin: -6px 0 4px; color: var(--text-dim); font-size: .98rem; letter-spacing: .01em; }

/* continue */
.continue-card {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 18px; border-radius: 12px; cursor: pointer;
  background: linear-gradient(180deg, #2c8a4a, #1f6a37);
  border: 1px solid #43b567; color: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.35);
  transition: transform .1s, filter .15s;
}
.continue-card:hover { filter: brightness(1.08); }
.continue-card:active { transform: scale(.98); }
.cont-title { font-weight: 800; font-size: 1.05rem; }
.cont-sub { font-size: .82rem; opacity: .9; }

/* creator */
.creator {
  width: 100%;
  display: flex; gap: 18px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 16px; padding: 18px;
  box-shadow: 0 16px 44px rgba(0,0,0,.45);
}
.creator-left { flex: 0 0 auto; }
#cc-preview {
  width: 176px; height: 176px;
  image-rendering: pixelated;
  background: radial-gradient(circle at 50% 40%, #2b2450, #1a1430);
  border: 1px solid var(--panel-line); border-radius: 12px;
}
.creator-right { flex: 1; text-align: left; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); font-weight: 700; }
.name-input {
  width: 100%; padding: 10px 12px; font-size: 1rem;
  background: var(--ink); color: var(--text);
  border: 1.5px solid var(--panel-line); border-radius: 9px; outline: none;
}
.name-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,194,75,.2); }

.cls-grid { display: flex; flex-direction: column; gap: 6px; }
.cls-btn {
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  padding: 8px 12px; border-radius: 9px; cursor: pointer;
  background: var(--ink); border: 1.5px solid var(--panel-line); color: var(--text);
  transition: border-color .12s, background .12s;
}
.cls-btn:hover { border-color: #5a4a80; }
.cls-btn.active { border-color: var(--gold); background: #241a3a; }
.cls-name { font-weight: 800; font-size: .95rem; }
.cls-desc { font-size: .76rem; color: var(--text-dim); }

.appearance { display: flex; gap: 18px; }
.swatch-row { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
  border: 2px solid rgba(255,255,255,.15);
}
.swatch.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232,194,75,.35); }

.start-btn {
  width: 100%; max-width: 420px;
  padding: 15px; border: 0; border-radius: 12px; cursor: pointer;
  font-size: 1.15rem; font-weight: 900; letter-spacing: .01em;
  color: #2a1c06;
  background: linear-gradient(180deg, #ffe08a, var(--gold) 60%, var(--gold-dk));
  box-shadow: 0 8px 22px rgba(232,194,75,.28), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .1s, filter .15s;
}
.start-btn:hover { filter: brightness(1.05); }
.start-btn:active { transform: scale(.98); }
.footnote { color: var(--text-dim); font-size: .76rem; margin: 2px 0 8px; }

/* Solo / Online play-mode chooser on the title screen */
.mode-select { display: flex; gap: 10px; width: 100%; max-width: 420px; margin: 4px 0 2px; }
.mode-pill {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 8px; border-radius: 11px; cursor: pointer;
  border: 2px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04);
  color: var(--text); font-size: 1rem; font-weight: 800; letter-spacing: .01em;
  transition: border-color .14s, background .14s, transform .1s; position: relative;
}
.mode-pill:hover { background: rgba(255,255,255,.08); }
.mode-pill:active { transform: scale(.98); }
.mode-pill.selected { border-color: var(--gold); background: rgba(232,194,75,.14); box-shadow: 0 0 0 1px var(--gold) inset; }
.mode-ico { font-size: 1.15rem; line-height: 1; }
.mode-badge {
  font-size: .58rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase;
  color: #2a1c06; background: var(--gold); border-radius: 5px; padding: 1px 4px; margin-left: 1px;
}
.mode-desc { color: var(--text-dim); font-size: .82rem; margin: 4px 0 10px; min-height: 1.1em; max-width: 420px; text-align: center; }

/* ---------- dialogue ---------- */
.dialogue {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 15; width: min(560px, calc(100vw - 32px));
  cursor: pointer;
}
.dlg-inner {
  background: var(--panel); border: 2px solid var(--gold-dk);
  border-radius: 14px; padding: 14px 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.dlg-name { color: var(--gold); font-weight: 800; font-size: .95rem; margin-bottom: 4px; }
.dlg-text { font-size: 1.02rem; line-height: 1.4; min-height: 2.6em; }
.dlg-hint { text-align: right; color: var(--text-dim); font-size: .74rem; margin-top: 4px; }
.dlg-actions { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.dlg-btn {
  cursor: pointer; font: inherit; font-weight: 700; font-size: .9rem;
  padding: 8px 16px; border-radius: 9px; color: var(--text);
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.16);
  transition: transform .06s ease, background .12s ease, border-color .12s ease;
}
.dlg-btn:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); }
.dlg-btn.primary {
  color: #1a1206; background: linear-gradient(180deg, #ffd968, var(--gold));
  border-color: var(--gold-dk);
}
.dlg-btn.primary:hover { filter: brightness(1.06); }

/* ---------- death ---------- */
.death {
  position: fixed; inset: 0; z-index: 18;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 50%, rgba(90,10,10,.4), rgba(6,4,10,.82));
  animation: fade .3s ease;
}
.death-inner { text-align: center; }
.death-title { font-size: 2.4rem; font-weight: 900; color: #e5554a; text-shadow: 0 3px 0 rgba(0,0,0,.4); letter-spacing: .04em; }
.death-sub { color: var(--text-dim); margin-top: 6px; }

/* ---------- intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 19;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1000px 700px at 50% 0%, #241b47, transparent 60%), rgba(8, 6, 14, .86);
  animation: fade .3s ease;
}
.intro-panel {
  width: 100%; max-width: 500px; text-align: center;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 18px; padding: 26px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.intro-mark { width: 40px; height: 40px; image-rendering: pixelated; filter: drop-shadow(0 3px 5px rgba(0,0,0,.5)); }
.intro-title {
  margin: 6px 0 14px; font-size: 1.7rem; font-weight: 900; letter-spacing: -.01em;
  background: linear-gradient(180deg, #ffe9a8, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.intro-panel p { color: var(--text-dim); line-height: 1.55; margin: 8px 0; font-size: .98rem; }
.intro-panel .start-btn { margin-top: 18px; }

/* ---------- cinematic intro (letterboxed cards over the live world) ---------- */
.intro.cinematic {
  align-items: flex-end; justify-content: center; padding: 0;
  background: transparent;   /* the game canvas shows through, panning behind */
}
.cine-bar { position: fixed; left: 0; right: 0; height: 12vh; background: #05040a; z-index: 1;
  box-shadow: 0 0 40px rgba(0,0,0,.6); }
.cine-top { top: 0; } .cine-bot { bottom: 0; }
.cine-card {
  position: relative; z-index: 2; width: min(600px, calc(100vw - 40px));
  margin-bottom: calc(12vh + 26px); text-align: center;
  background: linear-gradient(180deg, rgba(20,15,34,.72), rgba(12,9,22,.9));
  border: 1px solid rgba(232,194,75,.28); border-radius: 16px; padding: 20px 26px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5); backdrop-filter: blur(3px);
  animation: cardIn .5s ease;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.cine-card .intro-body { color: var(--text); line-height: 1.5; font-size: 1.05rem; min-height: 3.1em; margin: 6px 0 12px; }
.cine-dots { display: flex; gap: 7px; justify-content: center; margin: 10px 0 14px; }
.cine-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.25); transition: background .2s, transform .2s; }
.cine-dots span.on { background: var(--gold); transform: scale(1.25); }
.cine-actions { display: flex; gap: 12px; justify-content: center; align-items: center; }
.cine-actions .start-btn { margin: 0; }
.cine-skip {
  cursor: pointer; font: inherit; font-weight: 700; font-size: .85rem; color: var(--text-dim);
  background: transparent; border: 1px solid rgba(255,255,255,.18); border-radius: 9px; padding: 8px 14px;
}
.cine-skip:hover { color: var(--text); border-color: rgba(255,255,255,.34); }

/* ---------- multiplayer settings ---------- */
.mp-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mp-input {
  flex: 1 1 160px; min-width: 0; font: inherit; font-size: .9rem; color: var(--text);
  background: rgba(0,0,0,.28); border: 1px solid var(--panel-line); border-radius: 8px; padding: 8px 10px;
}
.mp-status { font-size: .85rem; color: var(--text-dim); margin-top: 8px; }
.mp-status .on { color: #7ee787; font-weight: 700; }

/* ---------- loading (shows the real generated world) ---------- */
.loading {
  position: fixed; inset: 0; z-index: 22;
  background: #0c0916;
  transition: opacity .42s ease;
}
.load-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block; image-rendering: pixelated;
}
.load-panel {
  position: absolute; left: 50%; bottom: 13%; transform: translateX(-50%);
  width: min(560px, calc(100vw - 40px));
  display: flex; flex-direction: column; align-items: center; gap: 15px;
  text-align: center;
}
.load-logo { display: flex; align-items: center; gap: 12px; }
.load-logo .logo-mark { width: 40px; height: 40px; }
.load-word {
  font-size: 2.4rem; font-weight: 900; letter-spacing: -.02em;
  background: linear-gradient(180deg, #ffe9a8, var(--gold) 55%, var(--gold-dk));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
}
.load-bar {
  width: 100%; height: 10px; border-radius: 999px;
  background: rgba(255,255,255,.1);
  border: 1px solid var(--panel-line); overflow: hidden;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.load-bar-fill {
  width: 0%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dk), var(--gold) 60%, #ffe9a8);
  transition: width .12s linear;
}
.load-tip {
  color: var(--text-dim); font-size: .92rem; line-height: 1.45;
  max-width: 460px; min-height: 2.6em;
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
}

/* ---------- shop ---------- */
.shop {
  position: fixed; inset: 0; z-index: 19;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(8, 6, 14, .72); backdrop-filter: blur(2px);
  animation: fade .18s ease;
}
.shop-panel {
  position: relative; width: 100%; max-width: 440px;
  max-height: 92vh; max-height: calc(100dvh - 36px);   /* never taller than the screen */
  display: flex; flex-direction: column;               /* header/search/foot fixed, list scrolls */
  background: var(--panel); border: 2px solid var(--gold-dk);
  border-radius: 16px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
  animation: rise .22s ease;
}
.shop-x {
  position: absolute; top: 12px; right: 12px;
  width: 30px; height: 30px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--ink); color: var(--text-dim); font-size: .85rem;
}
.shop-x:hover { color: var(--text); }
.shop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; padding-right: 28px; }
.shop-head h2 { margin: 0; font-size: 1.3rem; color: var(--gold); }
.shop-coins-wrap { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
#shop-coin-ico canvas { width: 18px; height: 18px; image-rendering: pixelated; display: block; }
.shop-items { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--gold-dk) transparent; padding-right: 4px; }
.shop-items::-webkit-scrollbar { width: 8px; }
.shop-items::-webkit-scrollbar-thumb { background: var(--gold-dk); border-radius: 6px; }
.shop-items::-webkit-scrollbar-track { background: transparent; }
/* forge recipe search */
.craft-search {
  width: 100%; box-sizing: border-box; margin: 0 0 10px; padding: 9px 12px;
  border-radius: 10px; border: 1px solid var(--panel-line); background: var(--ink);
  color: var(--text); font-size: .92rem; font-family: inherit;
}
.craft-search::placeholder { color: var(--text-dim); }
.craft-search:focus { outline: none; border-color: var(--gold-dk); }
.craft-none { text-align: center; color: var(--text-dim); font-size: .85rem; padding: 18px 0; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); border: 1px solid var(--panel-line);
  border-radius: 11px; padding: 10px 12px;
}
.si-icon { width: 30px; height: 30px; flex: 0 0 auto; }
.si-icon canvas { width: 30px; height: 30px; image-rendering: pixelated; display: block; }
.si-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.si-name { font-weight: 700; font-size: .96rem; }
.si-lvl { font-size: .72rem; color: var(--gold); font-weight: 700; margin-left: 4px; }
.si-desc { font-size: .8rem; color: var(--text-dim); }
.si-buy {
  flex: 0 0 auto; border: 0; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 12px; font-weight: 800; font-size: .9rem; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffe08a, var(--gold) 60%, var(--gold-dk)); color: #2a1c06;
  transition: filter .12s, transform .08s;
}
.si-coin { width: 15px; height: 15px; image-rendering: pixelated; display: block; }
.si-buy:hover { filter: brightness(1.06); }
.si-buy:active { transform: scale(.96); }
.si-buy.disabled { background: #2c2440; color: #6b6288; cursor: default; }
.shop-foot { text-align: center; color: var(--text-dim); font-size: .78rem; margin: 14px 0 0; }

/* crafting (Field Forge) — reuses the shop chrome, adds material chips */
.craft-res { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.craft-chip { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: .82rem; color: var(--text); font-variant-numeric: tabular-nums; }
.craft-chip canvas { width: 16px; height: 16px; image-rendering: pixelated; display: block; }
.craft-cost .cost-ok { color: #9fd6a0; font-weight: 700; }
.craft-cost .cost-no { color: #e0553f; font-weight: 700; }
.shop-item.rec-locked { opacity: .55; }
.rec-rarity { font-size: .62rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; opacity: .9; vertical-align: middle; }
.altar-progress { margin: 2px 0 10px; font-size: .82rem; color: #b9a7e8; text-align: center; font-weight: 600; }
.altar-progress b { color: #ffb14a; }
.si-name .bless-dur { font-size: .72rem; font-weight: 700; color: #7ee787; margin-left: 6px; }

/* armour sets — matched-trio bonuses, shown under the recipe list */
.craft-sets { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 8px; }
.craft-sets-head { font-size: .68rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-dim); }
.set-row { padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.set-row.set-done { background: rgba(255,177,74,.1); border-color: rgba(255,177,74,.55); box-shadow: 0 0 12px rgba(255,177,74,.18) inset; }
.set-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.set-name { font-weight: 800; font-size: .9rem; color: #ffcf8a; }
.set-tag { font-size: .64rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.set-done .set-tag { color: #ffb14a; }
.set-bonus { font-size: .78rem; color: var(--text-dim); margin-top: 2px; }
.set-bonus b { color: #7ee787; font-weight: 800; }
.set-pieces { font-size: .74rem; margin-top: 3px; }
.set-pieces .cost-ok { color: #9fd6a0; font-weight: 700; }
.set-pieces .cost-no { color: var(--text-dim); font-weight: 600; opacity: .8; }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------- settings ---------- */
.settings-modal {
  position: fixed; inset: 0; z-index: 21;
  display: flex; align-items: center; justify-content: center; padding: 18px;
  background: rgba(8, 6, 14, .72); backdrop-filter: blur(2px);
  animation: fade .18s ease;
}
.settings-panel {
  position: relative; width: 100%; max-width: 420px;
  background: var(--panel); border: 2px solid var(--gold-dk);
  border-radius: 16px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55); animation: rise .22s ease;
}
.settings-panel h2 { margin: 0 0 14px; font-size: 1.3rem; color: var(--gold); }
.set-section { margin-bottom: 16px; }
.set-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); font-weight: 800; margin-bottom: 8px; }
.set-row { display: flex; align-items: center; gap: 8px; }
.set-btn {
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 800; font-size: .9rem;
  background: var(--ink); color: var(--text); border: 1.5px solid var(--panel-line);
}
.set-btn:hover { border-color: #5a4a80; }
.set-btn.off { opacity: .58; }
.set-btn.danger { border-color: var(--red); color: #ffb3ad; }
.set-btn.danger:hover { border-color: #ff6a5e; background: rgba(211,73,63,.16); }
.newchar-confirm { margin-top: 10px; padding: 10px 12px; border: 1.5px solid var(--red); border-radius: 10px; background: rgba(211,73,63,.08); }
.newchar-warn { margin: 0 0 10px; color: #ffc9c3; font-size: .82rem; line-height: 1.4; font-weight: 600; }

/* ---------- quick-emote picker ---------- */
.emote-bar {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 8px 10px; z-index: 40;
  background: rgba(20,16,31,.92); border: 1px solid var(--panel-line); border-radius: 14px;
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
}
.emote-bar[hidden] { display: none; }
.emote-btn {
  width: 40px; height: 40px; border-radius: 10px; cursor: pointer; padding: 0;
  font-size: 22px; line-height: 1; background: var(--ink); border: 1.5px solid var(--panel-line);
}
.emote-btn:hover { border-color: var(--gold); background: #241a3a; }
.emote-btn:active { transform: scale(.94); }
body.touch .emote-bar { bottom: 150px; }
@media (max-width: 620px) { .emote-btn { width: 44px; height: 44px; font-size: 24px; } }
.set-vol { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--gold); min-width: 46px; text-align: center; }
.set-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: .86rem; color: var(--text-dim); }
.set-controls b { color: #fff; font-weight: 700; }
.set-foot { color: var(--text-dim); font-size: .78rem; margin: 4px 0 14px; }

/* ---------- chat (multiplayer) ---------- */
.chat {
  position: fixed; left: 14px; bottom: 66px; z-index: 14;
  width: min(360px, 70vw);
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
}
.chat-log {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 168px; overflow-y: auto;
}
.chat-msg {
  align-self: flex-start;
  background: rgba(18, 14, 30, 0.72);
  border: 1px solid var(--panel-line);
  padding: 4px 9px; border-radius: 10px;
  font-size: .84rem; line-height: 1.25; color: var(--text);
  max-width: 100%; word-break: break-word;
}
.chat-msg .chat-from { color: #9ad0ff; font-weight: 700; }
.chat-msg.self { background: rgba(46, 40, 70, 0.82); }
.chat-msg.self .chat-from { color: var(--gold); }
.chat-input {
  pointer-events: auto;
  width: 100%; padding: 9px 12px; border-radius: 10px;
  background: var(--ink); color: var(--text);
  border: 1.5px solid var(--gold-dk); outline: none; font-size: .92rem;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%);
  z-index: 30;
  background: var(--panel); border: 1px solid var(--panel-line);
  color: var(--text); padding: 9px 18px; border-radius: 999px;
  font-size: .9rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: toastIn .2s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; } }

@media (max-width: 560px) {
  .creator { flex-direction: column; align-items: center; }
  .creator-right { width: 100%; }
  .logo-word { font-size: 2.6rem; }
  #cc-preview { width: 140px; height: 140px; }
  .shop-panel, .settings-panel, .intro-panel { padding: 16px; }
  .dialogue { bottom: max(12px, env(safe-area-inset-bottom)); width: calc(100vw - 20px); }
  .dlg-text { font-size: .95rem; }
  .landing-lore { font-size: .95rem; }
}

/* ============ on-screen touch controls (mobile) ============ */
/* The pad is a passthrough overlay; only the stick + buttons capture touches,
   and the whole thing only shows on touch devices while actually in-game. */
.touchpad { position: fixed; inset: 0; z-index: 18; pointer-events: none; display: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.touch.playing .touchpad { display: block; }
.touchpad > * { pointer-events: auto; }

.tp-stick {
  position: fixed; left: calc(env(safe-area-inset-left, 0px) + 22px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  width: 128px; height: 128px; border-radius: 50%;
  background: radial-gradient(circle, rgba(30,24,48,.42), rgba(30,24,48,.24));
  border: 2px solid rgba(232,194,75,.32); touch-action: none;
}
.tp-nub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 58px; height: 58px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #6b5aa0, #362a58);
  border: 2px solid rgba(255,255,255,.35); box-shadow: 0 3px 10px rgba(0,0,0,.4);
}
/* compact cluster: F Q E across the top, the big Attack tucked at bottom-right —
   keeps its footprint clear of the joystick even on a 360px-wide phone */
.tp-actions {
  position: fixed; right: calc(env(safe-area-inset-right, 0px) + 18px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 26px);
  display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: 54px 82px;
  gap: 8px; align-items: center; justify-items: center; touch-action: none;
}
.tp-btn {
  width: 54px; height: 54px; border-radius: 50%; font-size: 1.1rem; font-weight: 800;
  color: #fff; background: rgba(30,24,48,.6); border: 2px solid rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent; font-family: inherit; padding: 0;
}
.tp-btn.tp-f { grid-column: 1; grid-row: 1; background: rgba(242,168,90,.62); }
.tp-btn.tp-q { grid-column: 2; grid-row: 1; background: rgba(232,85,106,.7); }
.tp-btn.tp-e { grid-column: 3; grid-row: 1; }
.tp-btn.tp-attack { grid-column: 3; grid-row: 2; width: 82px; height: 82px; font-size: 1.7rem;
  justify-self: end; background: rgba(211,73,63,.78); border-color: rgba(255,180,160,.5); }
.tp-btn.down { transform: scale(.9); filter: brightness(1.15); }
.tp-menu {
  position: fixed; left: calc(env(safe-area-inset-left, 0px) + 12px); top: 46%;
  transform: translateY(-50%); display: flex; flex-direction: column; gap: 10px; touch-action: none;
}
.tp-mini {
  width: 46px; height: 46px; border-radius: 12px; font-size: 1.15rem;
  background: rgba(30,24,48,.6); border: 1px solid rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tp-mini.down { transform: scale(.9); }
/* leave the top-left HP panel room: nudge the menu strip down a touch on very short screens */
@media (max-height: 460px) { .tp-menu { top: auto; bottom: calc(env(safe-area-inset-bottom,0px) + 26px); transform: none; } }
