:root {
  --ink: #16141a; --paper: #f2efe6; --panel: #e9e6dc; --head: #22384a; --head2: #2d4b62;
  --green: #5fa83a; --green-d: #3e7a22; --btn: #d8d4c8; --btn-d: #9c978a; --accent: #f28b24; --red: #d8403a;
  --font: 'Pixelify Sans', ui-monospace, monospace; --pix: 'Silkscreen', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0d0c10; color: var(--ink); font-family: var(--font); }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; cursor: pointer; }
button { font-family: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Habbo-ish buttons + windows ---------- */
.hbtn { background: var(--btn); border: 2px solid var(--ink); border-radius: 6px; padding: 6px 12px; font-size: 14px; font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--btn-d), inset 0 2px 0 #fff8; color: var(--ink); }
.hbtn:hover { filter: brightness(1.06); }
.hbtn:active { box-shadow: inset 0 2px 0 var(--btn-d); transform: translateY(1px); }
.hbtn.green { background: var(--green); color: #fff; box-shadow: inset 0 -3px 0 var(--green-d), inset 0 2px 0 #fff5; text-shadow: 0 1px 0 #0006; }
.hbtn.small { padding: 3px 8px; font-size: 12px; border-radius: 5px; }
.hbtn.big { padding: 9px 18px; font-size: 17px; }
.hbtn:disabled { opacity: .5; cursor: default; }
.iconbtn { background: none; border: 0; color: inherit; font-size: 16px; padding: 0 4px; }

.win { position: fixed; background: var(--panel); border: 2px solid var(--ink); border-radius: 8px; box-shadow: 0 6px 0 #0005, 0 0 0 1px #fff3 inset; overflow: hidden; }
.win-head { background: repeating-linear-gradient(0deg, var(--head) 0 2px, var(--head2) 2px 4px); color: #fff; font-family: var(--pix); font-size: 13px;
  padding: 7px 10px; display: flex; justify-content: space-between; align-items: center; letter-spacing: .5px; border-bottom: 2px solid var(--ink); cursor: move; user-select: none; }
.win-head .x { background: var(--red); color: #fff; border: 2px solid var(--ink); border-radius: 4px; width: 22px; height: 22px; line-height: 14px; font-size: 16px; padding: 0; }
.panel { position: fixed; background: #16141ae6; color: #f2efe6; border: 2px solid #000; border-radius: 8px; box-shadow: 0 4px 0 #0006; }

/* ---------- room title ---------- */
#roomTitle { top: 12px; left: 12px; padding: 8px 12px; }
.rt-name { font-family: var(--pix); font-weight: 700; font-size: 18px; color: var(--accent); letter-spacing: 1px; text-shadow: 2px 2px 0 #000; }
.rt-sub { font-size: 12px; opacity: .85; }

/* ---------- now playing ---------- */
#np { top: 12px; right: 12px; display: flex; gap: 10px; padding: 8px; align-items: center; width: min(430px, calc(100vw - 24px)); }
.np-disc { position: relative; width: 58px; height: 58px; flex: none; border-radius: 50%; background: radial-gradient(circle, #222 0 30%, #111 31% 33%, #1b1b1b 34% 60%, #0a0a0a 61%);
  animation: spin 1.8s linear infinite; animation-play-state: paused; border: 2px solid #000; }
.np-disc.on { animation-play-state: running; }
.np-disc img { position: absolute; inset: 15px; width: 24px; height: 24px; border-radius: 50%; object-fit: cover; image-rendering: auto; }
.np-disc .hole { position: absolute; left: 26px; top: 26px; width: 3px; height: 3px; border-radius: 50%; background: #000; }
@keyframes spin { to { transform: rotate(360deg); } }
.np-meta { flex: 1; min-width: 0; }
.np-label { font-family: var(--pix); font-size: 9px; letter-spacing: 1px; color: var(--accent); }
.np-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-artist { font-size: 13px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-by { font-size: 11px; opacity: .6; }
.np-bar { height: 4px; background: #333; border-radius: 2px; margin-top: 4px; overflow: hidden; }
.np-bar div, .prevbar div { height: 100%; width: 0; background: var(--accent); }
.np-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.vol { display: flex; align-items: center; }
.vol input { width: 80px; accent-color: var(--accent); }

/* ---------- toolbar ---------- */
#toolbar { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; gap: 6px; align-items: stretch; background: #16141ae6;
  border: 2px solid #000; border-radius: 10px; padding: 6px; box-shadow: 0 4px 0 #0006; max-width: calc(100vw - 16px); }
#chatForm { display: flex; }
#chatInput { width: clamp(140px, 28vw, 360px); font-family: var(--font); font-size: 15px; border: 2px solid #000; border-radius: 6px; padding: 6px 10px; background: #fffdf5; }
.tbtn { background: #2b2833; color: #f2efe6; border: 2px solid #000; border-radius: 6px; font-size: 11px; font-family: var(--pix); padding: 2px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 52px; box-shadow: inset 0 -3px 0 #0008; }
.tbtn i { font-style: normal; font-size: 16px; line-height: 16px; font-family: var(--font); }
.tbtn:hover { background: #3a3644; }
.tbtn.on { background: var(--accent); color: #111; }
@media (max-width: 720px) { .tbtn { min-width: 40px; font-size: 0; } .tbtn i { font-size: 18px; } #roomTitle { display: none; } }

/* ---------- chat bubbles ---------- */
#bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fff; border: 2px solid #000; border-radius: 7px; padding: 3px 8px 3px 6px;
  font-size: 13px; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 2px 0 #0004; transition: top .25s, opacity .6s;
  display: flex; gap: 5px; align-items: center; }
.bubble b { font-weight: 700; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -5px; border: 5px solid transparent; border-top-color: #000; }
.bubble.bot { background: #fff6dc; }
.bubble.me { background: #e7f6ff; }
.bubble.sys { background: #ffe0c2; }
.bubble canvas { width: 20px; height: 20px; image-rendering: pixelated; flex: none; }
#nametag { position: fixed; transform: translate(-50%, -100%); background: #000c; color: #fff; font-size: 12px; padding: 2px 6px; border-radius: 4px; pointer-events: none; white-space: nowrap; }

/* ---------- crate window ---------- */
#crateWin { left: 50%; top: calc(50% - 20px); transform: translate(-50%, -50%); width: min(640px, calc(100vw - 20px)); }
.crate-body { display: flex; gap: 18px; padding: 16px; background: linear-gradient(#e9e6dc, #dcd8cc); }
.stage { position: relative; width: 240px; height: 240px; flex: none; }
.cover-big { position: absolute; left: 0; top: 0; width: 240px; height: 240px; border: 2px solid #000; box-shadow: 4px 4px 0 #0004; background: #333; z-index: 2; object-fit: cover;
  transition: transform .18s; }
.cover-big.flip { transform: perspective(600px) rotateX(-70deg) translateY(30px); }
.vinyl { position: absolute; left: 10px; top: 10px; width: 220px; height: 220px; border-radius: 50%; z-index: 1;
  background: repeating-radial-gradient(circle, #111 0 2px, #1d1d1d 2px 4px); border: 2px solid #000; transition: left .5s cubic-bezier(.2,.9,.3,1.2); left: 44px; }
.vinyl.out { left: 120px; }
.vinyl.out.spin { animation: spin 1.8s linear infinite; }
.vinyl-label { position: absolute; left: 70px; top: 70px; width: 76px; height: 76px; border-radius: 50%; overflow: hidden; border: 3px solid #000; }
.vinyl-label img { width: 100%; height: 100%; object-fit: cover; }
.vinyl-label::after { content: ''; position: absolute; left: 34px; top: 34px; width: 6px; height: 6px; border-radius: 50%; background: #ddd; border: 1px solid #000; }
.info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; padding-left: 100px; }
.crate-tag { font-family: var(--pix); font-size: 10px; background: var(--ink); color: var(--accent); align-self: flex-start; padding: 2px 6px; border-radius: 3px; }
.rec-title { font-size: 22px; font-weight: 700; line-height: 1.1; }
.rec-title.small { font-size: 16px; }
.rec-artist { font-size: 16px; }
.rec-album { font-size: 13px; opacity: .7; }
.btnrow { display: flex; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.hint { font-size: 11px; opacity: .6; }
.prevbar { height: 5px; background: #0002; border-radius: 3px; overflow: hidden; }
.strip { display: flex; gap: 4px; padding: 8px 10px 10px; overflow-x: auto; background: #2b2833; border-top: 2px solid #000; scrollbar-width: thin; }
.strip img { width: 46px; height: 46px; border: 2px solid #000; flex: none; cursor: pointer; opacity: .65; transition: transform .1s, opacity .1s; object-fit: cover; background: #444; }
.strip img:hover { opacity: 1; transform: translateY(-3px); }
.strip img.sel { opacity: 1; outline: 2px solid var(--accent); transform: translateY(-4px); }
@media (max-width: 640px) {
  .crate-body { flex-direction: column; align-items: center; }
  .info { padding-left: 0; width: 100%; }
  .vinyl.out { left: 60px; }
}

/* ---------- DJ window ---------- */
#djWin { right: 12px; top: 96px; width: min(600px, calc(100vw - 24px)); max-height: calc(100vh - 176px); display: flex; flex-direction: column; }
.dj-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
.dj-now { display: flex; gap: 12px; align-items: center; background: var(--ink); color: var(--paper); padding: 8px; border-radius: 6px; }
.dj-now img { width: 64px; height: 64px; border: 2px solid #000; object-fit: cover; }
.dj-cols { display: flex; gap: 12px; min-height: 0; flex: 1; }
.dj-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.col-head { font-family: var(--pix); font-size: 11px; margin-bottom: 6px; }
.qlist, .rlist { list-style: none; margin: 0; padding: 0; overflow-y: auto; max-height: calc(100vh - 420px); background: #fffdf5; border: 2px solid var(--ink); border-radius: 6px; min-height: 80px; }
.qlist li, .rlist li { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-bottom: 1px solid #0001; font-size: 13px; }
.qlist li img, .rlist li img { width: 34px; height: 34px; border: 1px solid #000; flex: none; object-fit: cover; }
.qlist .t, .rlist .t { flex: 1; min-width: 0; }
.qlist .t div, .rlist .t div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qlist .t small, .rlist .t small { opacity: .6; }
.qlist .empty, .rlist .empty { opacity: .5; justify-content: center; padding: 16px; }
#searchForm { display: flex; gap: 6px; margin-bottom: 4px; }
#searchInput { flex: 1; font-family: var(--font); font-size: 14px; border: 2px solid var(--ink); border-radius: 6px; padding: 4px 8px; }
.search-scope { font-size: 11px; margin-bottom: 6px; opacity: .8; }
@media (max-width: 640px) { .dj-cols { flex-direction: column; } .qlist, .rlist { max-height: 24vh; } #djWin { right: 12px; left: 12px; width: auto; } }

/* ---------- entry ---------- */
#entry { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0d0c10aa, #0d0c10f2 70%); z-index: 10; padding: 12px; }
.entry-card { position: relative; width: min(680px, 100%); max-height: calc(100vh - 24px); overflow-y: auto; }
.entry-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.logo { text-align: center; line-height: .95; }
.logo-top { font-family: var(--pix); font-size: 18px; letter-spacing: 6px; color: var(--red); }
.logo-main { font-family: var(--pix); font-weight: 700; font-size: 48px; letter-spacing: 4px; color: var(--ink); text-shadow: 3px 3px 0 var(--accent); }
.logo-sub { font-family: var(--pix); font-size: 10px; letter-spacing: 2px; opacity: .6; margin-top: 4px; }
.look-wrap { display: flex; gap: 14px; }
.preview-box { flex: none; background: repeating-conic-gradient(#b8894f 0 25%, #a7773f 0 50%) 0 0/24px 24px; border: 2px solid var(--ink); border-radius: 6px; padding: 6px; display: flex; flex-direction: column; align-items: center; }
#lookCanvas { width: 144px; height: 200px; image-rendering: pixelated; }
.rot { display: flex; gap: 6px; }
.look-controls { flex: 1; display: grid; grid-template-columns: 58px 1fr; gap: 5px 8px; align-items: center; font-size: 12px; }
.look-controls .lbl { font-family: var(--pix); font-size: 10px; }
.sw { display: flex; flex-wrap: wrap; gap: 3px; }
.sw button { width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 3px; padding: 0; }
.sw button.sel { outline: 2px solid var(--accent); outline-offset: 1px; }
.opt { display: flex; gap: 3px; flex-wrap: wrap; }
.opt button { font-size: 11px; padding: 2px 6px; border: 2px solid var(--ink); border-radius: 4px; background: var(--btn); }
.opt button.sel { background: var(--ink); color: var(--accent); }
.entry-foot { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
#nameInput { flex: 1; min-width: 150px; font-family: var(--font); font-size: 17px; border: 2px solid var(--ink); border-radius: 6px; padding: 7px 10px; }
.entry-note { font-size: 11px; opacity: .6; text-align: center; }
@media (max-width: 560px) { .look-wrap { flex-direction: column; align-items: center; } .logo-main { font-size: 36px; } }

#toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 6px; border: 2px solid #000; font-size: 14px; z-index: 20; }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; color: #aaa; font-family: var(--pix); background: #0d0c10; z-index: 30; }

#soundGate { position: fixed; left: 50%; top: 100px; transform: translateX(-50%); background: var(--accent); color: #111; font-family: var(--pix); font-size: 13px;
  padding: 8px 14px; border: 2px solid #000; border-radius: 6px; box-shadow: 0 3px 0 #0006; z-index: 15; animation: pulse 1.2s ease-in-out infinite; cursor: pointer; }
@keyframes pulse { 50% { transform: translateX(-50%) scale(1.05); } }

#tips { left: 12px; bottom: 12px; width: 270px; padding: 10px 12px; font-size: 12px; }
#tips ul { margin: 6px 0 0; padding-left: 16px; line-height: 1.45; }
#tips b { color: var(--accent); font-weight: 600; }
.tips-x { position: absolute; right: 6px; top: 4px; }
@media (max-width: 1500px) { #tips { bottom: 80px; } }
@media (max-width: 700px) { #tips { width: 210px; font-size: 11px; bottom: 76px; padding: 8px 10px; } #tips li:last-child { display: none; } }
