@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;1,400&family=DM+Mono:wght@300;400&family=Cormorant+Garamond:wght@300;400;600&display=swap");

:root {
  --amber: #c8783c;
  --gold: #d4a843;
  --cream: #f0e8d8;
  --wood-dark: #2a1a0e;
  --wood-light: #7a4a28;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0d0905;
  font-family: "DM Mono", monospace;
  color: var(--cream);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  cursor: grab;
  user-select: none;
}
body.dragging { cursor: grabbing; }

#three-canvas { position: fixed; inset: 0; z-index: 1; }

#room-overlay {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(5, 3, 1, 0.55) 100%);
}

#yt-container {
  position: fixed; bottom: -9999px; left: -9999px;
  width: 0; height: 0; visibility: hidden;
  pointer-events: none; z-index: -1; overflow: hidden;
}

/* ── PLAYLIST PANEL ── */
#playlist-panel {
  position: fixed; top: 24px; right: 24px; width: 300px; z-index: 10;
  background: rgba(20, 12, 6, 0.88); backdrop-filter: blur(12px);
  border: 1px solid rgba(200, 120, 60, 0.2); border-radius: 12px;
  overflow: hidden; box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6); max-height: 560px;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid rgba(200, 120, 60, 0.15);
}
.panel-title {
  font-family: "Cormorant Garamond", serif; font-size: 13px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--gold);
}
.icon-btn {
  background: none; border: 1px solid rgba(200, 120, 60, 0.3);
  border-radius: 6px; color: var(--amber); width: 28px; height: 28px;
  cursor: pointer; font-size: 13px; display: flex; align-items: center;
  justify-content: center; transition: all 0.2s;
}
.icon-btn:hover { background: rgba(200, 120, 60, 0.15); border-color: var(--amber); }

.search-wrap {
  padding: 10px 14px; border-bottom: 1px solid rgba(200, 120, 60, 0.1);
  display: flex; gap: 8px;
}
#search-input {
  flex: 1; background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(200, 120, 60, 0.2); border-radius: 6px;
  color: var(--cream); font-family: "DM Mono", monospace;
  font-size: 11px; padding: 7px 10px; outline: none; transition: border-color 0.2s;
}
#search-input::placeholder { color: rgba(240, 232, 216, 0.3); }
#search-input:focus { border-color: var(--amber); }
#search-btn {
  background: var(--amber); border: none; border-radius: 6px;
  color: var(--wood-dark); font-size: 12px; padding: 0 12px;
  cursor: pointer; font-family: "DM Mono", monospace; transition: background 0.2s;
}
#search-btn:hover { background: var(--gold); }
#search-btn:disabled { opacity: 0.5; cursor: not-allowed; }

#search-results {
  max-height: 180px; overflow-y: auto;
  border-bottom: 1px solid rgba(200, 120, 60, 0.1); display: none;
}
#search-results::-webkit-scrollbar { width: 4px; }
#search-results::-webkit-scrollbar-thumb { background: var(--wood-light); border-radius: 2px; }

.search-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  cursor: pointer; transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.search-item:hover { background: rgba(200, 120, 60, 0.1); }
.search-item img { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.si-info { min-width: 0; flex: 1; }
.si-title { font-size: 11px; color: var(--cream); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-ch { font-size: 10px; color: var(--amber); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.si-add {
  margin-left: auto; background: none; border: 1px solid rgba(200, 120, 60, 0.3);
  border-radius: 4px; color: var(--amber); font-size: 14px; width: 22px; height: 22px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.2s;
}
.si-add:hover { background: rgba(200, 120, 60, 0.2); }

#playlist-tracks { max-height: 260px; overflow-y: auto; }
#playlist-tracks::-webkit-scrollbar { width: 4px; }
#playlist-tracks::-webkit-scrollbar-thumb { background: var(--wood-light); border-radius: 2px; }

.playlist-empty { padding: 24px; text-align: center; font-size: 11px; color: rgba(240, 232, 216, 0.3); line-height: 1.6; }

.track-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  cursor: pointer; transition: background 0.15s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03); position: relative;
}
.track-item:hover { background: rgba(200, 120, 60, 0.08); }
.track-item.active { background: rgba(200, 120, 60, 0.15); }
.track-item.active::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--amber); border-radius: 0 2px 2px 0;
}
.track-item img { width: 36px; height: 36px; border-radius: 4px; object-fit: cover; flex-shrink: 0; }
.ti-info { min-width: 0; flex: 1; }
.ti-name { font-size: 11px; color: var(--cream); white-space: nowrap; overflow: hidden; max-width: 160px; }
.ti-ch { font-size: 10px; color: var(--amber); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ti-rm { background: none; border: none; color: rgba(240, 232, 216, 0.2); cursor: pointer; font-size: 14px; padding: 2px 4px; transition: color 0.2s; flex-shrink: 0; }
.ti-rm:hover { color: #e05555; }

/* ── NOW PLAYING ── */
#now-playing {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: rgba(20, 12, 6, 0.9); backdrop-filter: blur(12px);
  border: 1px solid rgba(200, 120, 60, 0.2); border-radius: 16px;
  padding: 12px 24px 10px; display: flex; flex-direction: column; gap: 10px;
  min-width: 420px; box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 0.4s;
}
#now-playing.visible { opacity: 1; }
#np-controls { display: flex; align-items: center; gap: 16px; }
#np-progress-wrap { display: flex; align-items: center; gap: 8px; width: 100%; }
#np-time-cur { font-size: 10px; color: var(--amber); min-width: 32px; }
#np-time-tot { font-size: 10px; color: rgba(200, 120, 60, 0.5); min-width: 32px; text-align: right; }
#np-progress {
  flex: 1; -webkit-appearance: none; height: 3px;
  background: rgba(200, 120, 60, 0.2); border-radius: 2px; outline: none; cursor: pointer;
}
#np-progress::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px;
  border-radius: 50%; background: var(--amber); cursor: pointer;
}

.np-art {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  animation: spin 3s linear infinite; animation-play-state: paused;
  border: 2px solid var(--amber); background: var(--wood-dark); flex-shrink: 0;
}
.np-art.playing { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

.np-info { flex: 1; min-width: 0; }
.np-track {
  font-family: "Cormorant Garamond", serif; font-size: 13px;
  color: var(--cream); white-space: nowrap; overflow: hidden; max-width: 160px;
}
.np-artist { font-size: 10px; color: var(--amber); margin-top: 2px; }

/* 마키 */
.marquee-wrap { overflow: hidden; display: block; position: relative; }
.marquee-text { display: inline-block; white-space: nowrap; }
.marquee-text.scrolling { animation: marquee-scroll 9s linear infinite; }
@keyframes marquee-scroll {
  0%, 25%  { transform: translateX(0); }
  75%, 100% { transform: translateX(var(--mo, 0px)); }
}

.ctrl-btn {
  background: none; border: none; color: var(--cream); font-size: 18px;
  cursor: pointer; padding: 4px; transition: color 0.2s, transform 0.15s; line-height: 1;
}
.ctrl-btn:hover { color: var(--gold); transform: scale(1.1); }

#play-btn {
  width: 36px; height: 36px; background: var(--amber); border: none;
  border-radius: 50%; color: var(--wood-dark); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, transform 0.15s;
}
#play-btn:hover { background: var(--gold); transform: scale(1.05); }

#vol-wrap { display: flex; align-items: center; gap: 5px; }
#vol-icon { color: var(--amber); cursor: pointer; display: flex; align-items: center; flex-shrink: 0; }
#vol-icon svg {
  width: 16px; height: 16px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.2s;
}
#vol-icon:hover svg { opacity: 0.7; }
#vol-slider {
  -webkit-appearance: none; width: 56px; height: 3px;
  background: rgba(200, 120, 60, 0.3); border-radius: 2px; outline: none; cursor: pointer;
}
#vol-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 10px; height: 10px; border-radius: 50%; background: var(--amber);
}

/* ── LP SHELF ── */
#lp-shelf {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; height: 220px;
  background: linear-gradient(to top, rgba(10, 6, 2, 0.98) 60%, transparent);
  padding: 16px 0 20px;
}
.shelf-label {
  font-family: "Cormorant Garamond", serif; font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: rgba(200, 120, 60, 0.5); padding: 0 32px; margin-bottom: 12px;
}
#shelf-track {
  display: flex; gap: 16px; padding: 20px 32px 8px;
  overflow-x: auto; overflow-y: visible; scroll-behavior: smooth; cursor: ew-resize;
}
#shelf-track::-webkit-scrollbar { height: 3px; }
#shelf-track::-webkit-scrollbar-thumb { background: var(--wood-light); border-radius: 2px; }

.shelf-lp { flex-shrink: 0; width: 100px; cursor: pointer; transition: transform 0.25s ease; }
.shelf-lp:hover { transform: translateY(-8px) scale(1.04); }
.shelf-lp.active { transform: translateY(-12px) scale(1.06); }

.shelf-lp-disc {
  width: 100px; height: 100px; border-radius: 50%; position: relative;
  overflow: hidden; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7); background: #111;
}
.shelf-lp-disc::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(
    from 0deg, #111 0deg, #1a1a1a 5deg, #111 10deg, #1a1a1a 15deg,
    #111 20deg, #1a1a1a 25deg, #111 30deg, #1a1a1a 35deg,
    #111 40deg, #1a1a1a 45deg, #111 50deg, #1a1a1a 55deg,
    #111 60deg, #1a1a1a 65deg, #111 70deg, #1a1a1a 75deg,
    #111 80deg, #1a1a1a 85deg, #111 90deg, #1a1a1a 95deg,
    #111 100deg, #1a1a1a 360deg
  );
  z-index: 1;
}
.shelf-lp-art {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  z-index: 2; border: 2px solid rgba(0, 0, 0, 0.5);
}
.shelf-lp-hole {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 8px; height: 8px; border-radius: 50%; background: #0a0602; z-index: 3;
}
.shelf-lp-title {
  font-size: 9px; color: rgba(240, 232, 216, 0.5); text-align: center;
  margin-top: 6px; white-space: nowrap; overflow: hidden; max-width: 100px;
}
.shelf-lp.active .shelf-lp-title { color: var(--amber); }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 220px; left: 50%;
  transform: translateX(-50%) translateY(20px); z-index: 20;
  background: rgba(200, 120, 60, 0.9); color: var(--wood-dark); font-size: 11px;
  padding: 8px 20px; border-radius: 20px; opacity: 0; pointer-events: none;
  transition: opacity 0.3s, transform 0.3s; font-weight: 500; white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── LOADING ── */
#loading {
  position: fixed; inset: 0; z-index: 100; background: #0d0905;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 20px; transition: opacity 0.6s;
}
#loading.hidden { opacity: 0; pointer-events: none; }
.loading-title { font-family: "Playfair Display", serif; font-size: 32px; color: var(--amber); letter-spacing: 0.1em; }
.loading-sub { font-size: 11px; color: rgba(200, 120, 60, 0.4); letter-spacing: 0.2em; }
.loading-bar { width: 200px; height: 2px; background: rgba(200, 120, 60, 0.15); border-radius: 1px; overflow: hidden; }
.loading-fill { height: 100%; background: var(--amber); border-radius: 1px; animation: loadfill 1.2s ease-out forwards; }
@keyframes loadfill { from { width: 0; } to { width: 100%; } }

#hint {
  position: fixed; bottom: 240px; left: 32px; z-index: 10;
  font-size: 10px; color: rgba(200, 120, 60, 0.35); letter-spacing: 0.12em; pointer-events: none;
}
