:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --panel2: #1b2740;
  --line: #2a3a5c;
  --text: #eef2ff;
  --muted: #9fb0d0;
  --accent: #ff8f1f;
  --accent2: #ffc542;
  --danger: #ff5c5c;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1f2f55 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
}
a { color: var(--accent2); }
.wrap { max-width: 560px; margin: 0 auto; padding: 18px 14px 60px; }
.hero { text-align: center; padding: 8px 0 14px; }
.hero .badge { display: inline-block; background: var(--accent); color: #1a1000; font-weight: 800; letter-spacing: .12em; font-size: 11px; padding: 5px 10px; border-radius: 999px; }
.hero h1 { margin: 10px 0 4px; font-size: 26px; line-height: 1.15; }
.hero h1 span { color: var(--accent2); }
.hero p { margin: 0; color: var(--muted); font-size: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.card h2 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card h2 .num { background: var(--accent); color: #1a1000; width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 6px; }
input[type=text], textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 16px; font-family: inherit; outline: none;
}
input[type=text]:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

.preview-wrap { position: relative; }
#preview { width: 100%; height: 260px; border-radius: 12px; background: linear-gradient(#5fa9ff, #cfe8ff); display: block; touch-action: none; }
.preview-hint { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; font-size: 11px; color: #123; opacity: .7; pointer-events: none; }

.tabs { display: flex; gap: 6px; margin: 12px 0; background: var(--panel2); padding: 4px; border-radius: 10px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 10px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; font-family: inherit; }
.tabs button.active { background: var(--accent); color: #1a1000; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.preset { background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 8px; cursor: pointer; text-align: center; transition: .15s; }
.preset img { width: 100%; aspect-ratio: 1; border-radius: 8px; background: #cfe8ff; display: block; }
.preset b { display: block; margin-top: 6px; font-size: 13px; }
.preset small { color: var(--muted); font-size: 11px; line-height: 1.3; display: block; }
.preset.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,143,31,.25); }

.opt-group { margin-top: 12px; }
.opt-group .title { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--panel2); border: 2px solid var(--line); color: var(--text); border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; font-family: inherit; }
.chip.active { border-color: var(--accent); background: rgba(255,143,31,.15); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.swatch.active { border-color: #fff; transform: scale(1.1); }

.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 15px; font-size: 17px; font-weight: 800; cursor: pointer; font-family: inherit; }
.btn-primary { background: linear-gradient(90deg, var(--accent), var(--accent2)); color: #1a1000; box-shadow: 0 8px 24px rgba(255,143,31,.35); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; font-size: 14px; padding: 11px; margin-top: 8px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }
.continue { background: rgba(255,197,66,.12); border: 1px dashed var(--accent2); border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 10px; }

/* ===== WORLD ===== */
body.world { overflow: hidden; background: #87ceeb; }
#world { position: fixed; inset: 0; display: block; touch-action: none; }
.hud { position: fixed; z-index: 5; pointer-events: none; }
.hud * { pointer-events: auto; }
.hud-top { top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px; gap: 8px; }
.hud-title { background: rgba(11,18,32,.75); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.12); color: #fff; border-radius: 12px; padding: 8px 12px; font-size: 12px; line-height: 1.2; }
.hud-title b { display: block; color: var(--accent2); font-size: 14px; }
.hud-actions { display: flex; gap: 6px; }
.hbtn { background: rgba(11,18,32,.75); backdrop-filter: blur(6px); border: 1px solid rgba(255,255,255,.12); color: #fff; border-radius: 12px; padding: 9px 11px; font-size: 14px; cursor: pointer; font-family: inherit; }
.hbtn:active { background: rgba(255,143,31,.6); }
.hud-bottom { bottom: 0; left: 0; right: 0; padding: 12px; display: flex; justify-content: center; }
.hint { background: rgba(11,18,32,.65); color: #dfe7ff; border-radius: 999px; padding: 7px 14px; font-size: 12px; text-align: center; transition: all .4s; }
.hint.auto { background: rgba(255,143,31,.9); color: #1a1000; font-weight: 700; }

#joystick { position: fixed; left: 18px; bottom: 60px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.35); z-index: 6; touch-action: none; display: none; }
#joystick .knob { position: absolute; width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.75); left: 35px; top: 35px; box-shadow: 0 4px 12px rgba(0,0,0,.3); }
#jumpBtn { position: fixed; right: 22px; bottom: 80px; width: 78px; height: 78px; border-radius: 50%; background: rgba(255,143,31,.85); border: 3px solid rgba(255,255,255,.6); color: #1a1000; font-weight: 800; font-size: 15px; z-index: 6; touch-action: none; display: none; font-family: inherit; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
#jumpBtn:active { transform: scale(.94); }
@media (pointer: coarse) { #joystick { display: block; } #jumpBtn { display: block; } .hint.desktop-only { display: none; } }
@media (max-width: 520px) { .hud-title { font-size: 11px; padding: 6px 9px; } .hud-title b { font-size: 12px; } .hbtn { padding: 8px 9px; font-size: 13px; } }

.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(6,10,20,.88); display: flex; align-items: center; justify-content: center; padding: 20px; }
.overlay .box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 420px; width: 100%; text-align: center; color: var(--text); }
.overlay h2 { margin: 0 0 8px; color: var(--accent2); }
.overlay p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 14px; }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 15; transform: translateX(100%); transition: transform .25s; display: flex; flex-direction: column; color: var(--text); }
.panel.open { transform: translateX(0); }
.panel header { display: flex; justify-content: space-between; align-items: center; padding: 14px; border-bottom: 1px solid var(--line); }
.panel header h3 { margin: 0; font-size: 16px; }
.panel .list { overflow-y: auto; padding: 10px; flex: 1; }
.gitem { background: var(--panel2); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; display: flex; gap: 10px; align-items: flex-start; }
.gitem .av { width: 44px; height: 44px; border-radius: 10px; background: #cfe8ff; flex: none; }
.gitem .body { flex: 1; min-width: 0; }
.gitem b { display: block; font-size: 14px; }
.gitem p { margin: 3px 0 6px; font-size: 13px; color: var(--muted); line-height: 1.4; word-wrap: break-word; }
.gitem button { background: var(--accent); border: 0; color: #1a1000; font-weight: 700; border-radius: 8px; padding: 6px 10px; font-size: 12px; cursor: pointer; font-family: inherit; }
.gitem.me { border: 1px solid var(--accent2); }

.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: rgba(11,18,32,.9); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; font-size: 14px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; }
