:root {
  --ink: #14100d;
  --panel: rgba(24, 18, 14, 0.86);
  --panel-solid: #1c1611;
  --line: rgba(232, 176, 74, 0.16);
  --line-strong: rgba(232, 176, 74, 0.34);
  --text: #f3ead8;
  --muted: #b3a68e;
  --faint: #7d725f;
  --red: #e5533d;
  --red-deep: #b23a2a;
  --gold: #e8b04a;
  --green: #6fcf8e;
  --amber: #f0b84a;
  --radius: 14px;
  --display: 'Shippori Mincho', 'Hiragino Mincho ProN', Georgia, serif;
  --ui: 'Zen Kaku Gothic New', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font-family: var(--ui); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
#world { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; image-rendering: pixelated; touch-action: none; }

/* ---------- botones base ---------- */
.primary { background: var(--red); color: #fff7ee; border: 0; border-radius: 10px; padding: 12px 20px; font-weight: 700; letter-spacing: .01em; box-shadow: 0 1px 0 rgba(255,255,255,.18) inset, 0 6px 18px rgba(229,83,61,.28); transition: transform .15s cubic-bezier(.2,.8,.2,1), background .15s; }
.primary:hover { background: #ee6450; }
.primary:active { transform: scale(.97); }
.primary.small { padding: 8px 14px; font-size: 13px; }
.ghost { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; transition: background .15s, border-color .15s; }
.ghost:hover { background: rgba(255,255,255,.08); border-color: var(--line-strong); }
.ghost.small { padding: 6px 10px; font-size: 13px; }
.ghost.tiny { padding: 4px 8px; font-size: 12px; }
.icon { background: none; border: 0; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); }
.icon:hover { background: rgba(255,255,255,.07); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); white-space: nowrap; }
.chip small { color: var(--muted); }
.muted { color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 2px; border-radius: 5px; border: 1px solid var(--line-strong); border-bottom-width: 2px; background: rgba(255,255,255,.04); font-family: var(--ui); font-size: 12px; text-align: center; }

/* ---------- lobby ---------- */
#lobby { position: fixed; inset: 0; display: flex; align-items: center; padding: 24px clamp(16px, 6vw, 96px); background: linear-gradient(90deg, rgba(20,16,13,.94) 0%, rgba(20,16,13,.78) 42%, rgba(20,16,13,.15) 75%, rgba(20,16,13,0) 100%); z-index: 20; overflow-y: auto; }
.lobby-card { width: min(520px, 100%); animation: rise .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.eyebrow { color: var(--gold); letter-spacing: .18em; text-transform: uppercase; font-size: 12px; font-weight: 700; margin: 0 0 10px; }
h1 { font-family: var(--display); font-weight: 800; font-size: clamp(64px, 10vw, 112px); line-height: .92; margin: 0 0 24px; letter-spacing: -.01em; }
.lede { color: var(--muted); font-size: 16px; line-height: 1.6; margin: 0 0 26px; max-width: 46ch; }
.maker { display: grid; grid-template-columns: 112px 1fr; gap: 22px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.025); margin-bottom: 18px; }
.preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#preview { width: 96px; height: 152px; image-rendering: pixelated; background: radial-gradient(circle at 50% 70%, rgba(232,176,74,.16), transparent 65%); border-radius: 12px; }
.pickers { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .pick > span { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.field input, .field select, #status { background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(232,176,74,.15); }
.pick { display: grid; grid-template-columns: 60px 1fr; align-items: center; gap: 8px; }
.swatches, .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sw { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; outline: 1px solid rgba(255,255,255,.12); transition: transform .12s; padding: 0; }
.sw:hover { transform: scale(1.12); }
.sw.on { border-color: var(--text); outline-color: var(--gold); }
.chipbtn { border: 1px solid var(--line); background: rgba(255,255,255,.03); border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); }
.chipbtn.on { border-color: var(--gold); color: var(--text); background: rgba(232,176,74,.12); }
#btn-enter { width: 100%; padding: 15px; font-size: 16px; }
.fine { color: var(--faint); font-size: 12px; margin: 12px 0 0; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#topbar { position: absolute; top: 14px; left: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; right: 360px; pointer-events: none; }
#topbar > * { pointer-events: auto; }
.brand { font-family: var(--display); font-weight: 800; font-size: 20px; padding: 4px 12px 4px 4px; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.brand .torii { color: var(--red); }
#zone-chip { cursor: default; color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); display: inline-block; }
#net-chip.ok .dot { background: var(--green); box-shadow: 0 0 8px var(--green); }
#net-chip.bad .dot { background: var(--red); }

#videos { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; pointer-events: auto; max-width: calc(100vw - 760px); overflow-x: auto; padding-bottom: 4px; }
.vtile { position: relative; width: 168px; aspect-ratio: 4/3; border-radius: 12px; overflow: hidden; background: var(--panel-solid); border: 2px solid var(--line); flex: none; transition: border-color .15s, box-shadow .15s; animation: pop .35s cubic-bezier(.2,.9,.3,1.3) both; }
@keyframes pop { from { opacity: 0; transform: scale(.85); } }
.vtile.speaking { border-color: var(--green); box-shadow: 0 0 0 3px rgba(111,207,142,.25); }
.vtile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.vtile.me video { transform: scaleX(-1); }
.vtile .portrait { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 60%, rgba(232,176,74,.15), transparent 70%); }
.vtile .portrait img { height: 74%; image-rendering: pixelated; }
.vtile .name { position: absolute; left: 6px; bottom: 6px; right: 6px; display: flex; gap: 5px; align-items: center; font-size: 12px; background: rgba(0,0,0,.55); padding: 3px 7px; border-radius: 6px; width: max-content; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#side { position: absolute; top: 14px; right: 14px; bottom: 14px; width: 330px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); overflow: hidden; transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .3s; }
#side.closed { transform: translateX(calc(100% + 20px)); opacity: 0; pointer-events: none; }
.floating { position: absolute; top: 14px; right: 14px; }
.floating em, .tab em { font-style: normal; background: var(--red); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.tab em { background: rgba(255,255,255,.1); color: var(--muted); }
.tab em#chat-unread { background: var(--red); color: #fff; }
.tabs { display: flex; align-items: center; gap: 4px; padding: 8px; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: none; border: 0; padding: 9px; border-radius: 9px; color: var(--muted); font-weight: 500; }
.tab.on { background: rgba(232,176,74,.12); color: var(--text); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#people { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.person { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; }
.person:hover { background: rgba(255,255,255,.04); }
.person .av { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.05); display: grid; place-items: center; overflow: hidden; position: relative; }
.person .av img { height: 34px; image-rendering: pixelated; margin-top: 6px; }
.person .av i { position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--panel-solid); }
.person .who { min-width: 0; }
.person .who b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .who small { color: var(--muted); font-size: 12px; }
.person .tag { font-size: 10px; color: var(--gold); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 6px; margin-left: 4px; vertical-align: 2px; }
.person .acts { display: flex; gap: 2px; opacity: .55; transition: opacity .15s; }
.person:hover .acts { opacity: 1; }
.person .acts button { background: rgba(255,255,255,.05); border: 0; border-radius: 8px; padding: 5px 7px; font-size: 13px; }
.person .acts button:hover { background: rgba(255,255,255,.12); }
.st-disponible { background: var(--green); } .st-ocupado { background: var(--red); } .st-ausente { background: var(--amber); }

#channels { display: flex; gap: 6px; padding: 10px 10px 6px; flex-wrap: wrap; }
#channels button { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); position: relative; }
#channels button.on { border-color: var(--gold); color: var(--text); background: rgba(232,176,74,.1); }
#channels button .u { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
#messages { flex: 1; overflow-y: auto; padding: 6px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { line-height: 1.45; animation: rise .25s ease-out both; }
.msg .meta { font-size: 12px; color: var(--muted); }
.msg .meta b { color: var(--text); font-weight: 700; margin-right: 6px; }
.msg.mine .meta b { color: var(--gold); }
.msg .body { word-wrap: break-word; }
.msg.sys { color: var(--faint); font-size: 12px; text-align: center; }
.empty { color: var(--faint); text-align: center; margin: auto; padding: 20px; line-height: 1.6; }
#chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
#chat-input { flex: 1; min-width: 0; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; outline: none; }
#chat-input:focus { border-color: var(--gold); }

#dock { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.dbtn { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.04); border: 1px solid transparent; border-radius: 11px; padding: 9px 12px; transition: background .15s, transform .12s; min-height: 40px; }
.dbtn:hover { background: rgba(255,255,255,.09); }
.dbtn:active { transform: scale(.95); }
.dbtn .ico { font-size: 16px; line-height: 1; }
.dbtn .lbl { font-size: 13px; }
.dbtn.off { background: rgba(229,83,61,.12); border-color: rgba(229,83,61,.3); }
.dbtn.off .ico { filter: grayscale(1); opacity: .7; }
.dbtn.live { background: rgba(111,207,142,.14); border-color: rgba(111,207,142,.45); }
.dbtn.quiet { opacity: .5; }
.sep { width: 1px; height: 26px; background: var(--line); margin: 0 2px; }
.emotes { display: flex; gap: 2px; }
.emotes button { background: none; border: 0; font-size: 19px; width: 36px; height: 36px; border-radius: 9px; transition: transform .15s cubic-bezier(.2,.9,.3,1.4), background .15s; }
.emotes button:hover { background: rgba(255,255,255,.08); transform: translateY(-3px) scale(1.15); }
#status { padding: 8px 10px; font-size: 13px; }

#mini-wrap { position: absolute; left: 14px; bottom: 14px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#mini { display: block; width: 180px; height: 120px; image-rendering: pixelated; border-radius: 8px; cursor: crosshair; }
.zoom { position: absolute; right: -44px; bottom: 0; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 36px; height: 36px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; font-size: 18px; }
.zoom button:hover { border-color: var(--line-strong); }

#prompt { position: absolute; transform: translate(-50%, -100%); background: var(--panel-solid); border: 1px solid var(--line-strong); border-radius: 10px; padding: 6px 10px 6px 6px; display: flex; gap: 8px; align-items: center; font-size: 13px; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: pop .2s ease-out both; }
#prompt kbd { background: var(--gold); color: var(--ink); border-color: #b9862f; font-weight: 700; }

#banner { position: absolute; top: 74px; left: 50%; transform: translateX(-50%); display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 12px 18px; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); max-width: min(480px, calc(100vw - 32px)); animation: banner 4.2s cubic-bezier(.2,.8,.2,1) both; pointer-events: none; }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -10px); } 10%, 82% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -6px); } }
#banner-icon { font-size: 28px; }
#banner b { font-family: var(--display); font-size: 20px; }
#banner p { margin: 2px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

#toasts { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 40; pointer-events: none; }
.toast { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: toast 3.6s ease both; }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 8%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- diálogos ---------- */
.dlg { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.dlg.wide { width: min(1240px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(10,8,6,.6); backdrop-filter: blur(4px); }
.dlg[open] { animation: pop .25s cubic-bezier(.2,.9,.3,1.2) both; }
.dlg header { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dlg header h2 { font-family: var(--display); font-size: 22px; margin: 0; }
.dlg header .icon { margin-left: auto; }
.dlg > div, .dlg > dl, .dlg > p { padding: 16px 18px; margin: 0; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; align-items: center; }
.keys dt { color: var(--muted); }
.keys dd { margin: 0; }
.settings { display: flex; flex-direction: column; gap: 14px; }
.toggle { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.toggle input { width: 18px; height: 18px; accent-color: var(--red); }
.board-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
#board { display: block; width: 100%; height: auto; max-height: calc(100vh - 170px); object-fit: contain; aspect-ratio: 5/3; background: #f6f5ef; border-radius: 0 0 18px 18px; touch-action: none; cursor: crosshair; }
#notice-body h3 { font-family: var(--display); margin: 0 0 8px; font-size: 18px; }
#notice-body p { color: var(--muted); line-height: 1.6; margin: 0 0 14px; }
.zlist { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.zlist button { text-align: left; background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.zlist button:hover { border-color: var(--gold); }
.zlist small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  #videos { max-width: calc(100vw - 32px); top: 64px; }
  #topbar { right: 70px; }
}
@media (max-width: 760px) {
  #lobby { background: rgba(20,16,13,.88); align-items: flex-start; }
  .maker { grid-template-columns: 1fr; }
  .preview-wrap { flex-direction: row; justify-content: center; }
  .pick { grid-template-columns: 54px 1fr; }
  #side { left: 10px; right: 10px; width: auto; top: 60px; bottom: 76px; }
  #dock { left: 10px; right: 10px; transform: none; bottom: 10px; overflow-x: auto; justify-content: flex-start; }
  .dbtn .lbl, .emotes button:nth-child(n+4), .brand { display: none; }
  #mini-wrap { bottom: 76px; left: 10px; }
  #mini { width: 120px; height: 80px; }
  #topbar { right: 64px; top: 10px; left: 10px; }
  #net-text { display: none; }
  .vtile { width: 120px; }
  #banner { top: 110px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
