/* ============ La Samplothèque — studio de nuit ============ */
:root {
  --bg: #14110e;
  --panel: #201b15;
  --panel-2: #2a231b;
  --line: #3b3226;
  --text: #f1e6d0;
  --muted: #a99878;
  --amber: #ffb347;
  --amber-deep: #e07b1f;
  --led-green: #7dff9b;
  --red: #ff6b5e;
  --radius: 14px;
  --font-display: 'Righteous', 'Trebuchet MS', sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 80% -10%, #2b2115 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, sans-serif;
  line-height: 1.45;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 400; letter-spacing: .5px; }
h2 { font-size: 1.15rem; color: var(--amber); margin: 0 0 .6rem; text-transform: uppercase; }
h3 { font-size: .95rem; margin: 1.2rem 0 .2rem; color: var(--text); }
.mono { font-family: var(--font-mono); font-size: .8rem; }
.hint { color: var(--muted); font-size: .78rem; margin: .1rem 0 .6rem; }
.link { color: var(--amber); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.4rem; flex-wrap: wrap;
  padding: 1rem 1.4rem; border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.9rem; margin: 0; color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 179, 71, .35); }
.tagline { margin: 0; color: var(--muted); font-size: .8rem; letter-spacing: 2px; text-transform: uppercase; }
.session { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.user::before { content: "◉ "; color: var(--led-green); }

.led {
  width: 12px; height: 12px; border-radius: 50%;
  background: #4b4437; box-shadow: inset 0 0 3px #000;
  transition: background .3s, box-shadow .3s;
}
.led.on { background: var(--red); box-shadow: 0 0 10px var(--red); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .55; } }

/* ---------- polaroids (les 3 photos) ---------- */
.crew { display: flex; gap: .7rem; }
.polaroid {
  width: 74px; height: 74px; object-fit: cover;
  border: 5px solid #fdf6e6; border-bottom-width: 16px;
  box-shadow: 0 6px 14px rgba(0,0,0,.5);
  transition: transform .25s ease;
}
.polaroid:hover { transform: scale(1.7) rotate(0deg) !important; z-index: 5; position: relative; }
.tilt-l  { transform: rotate(-5deg); }
.tilt-r  { transform: rotate(4deg) translateY(4px); }
.tilt-l2 { transform: rotate(-2deg); }

/* ---------- layout ---------- */
.layout {
  display: grid; grid-template-columns: 380px 1fr; gap: 1.2rem;
  padding: 1.2rem 1.4rem; max-width: 1400px; margin: 0 auto;
}
.right-col { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.two-cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.2rem; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  min-width: 0;
}

/* ---------- boutons ---------- */
.btn-primary, .btn-secondary {
  font-family: var(--font-display); font-size: 1rem; letter-spacing: .5px;
  border-radius: 999px; border: none; cursor: pointer;
  padding: .55rem 1.4rem; transition: transform .1s, box-shadow .2s, background .2s;
}
.btn-primary {
  background: linear-gradient(180deg, var(--amber), var(--amber-deep));
  color: #241500; box-shadow: 0 4px 16px rgba(224, 123, 31, .4);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary.big { width: 100%; font-size: 1.25rem; padding: .85rem; }
.btn-primary.stop { background: linear-gradient(180deg, var(--red), #c8372c); color: #2b0300; }
.btn-secondary {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
}
.btn-secondary:hover { border-color: var(--amber); }

/* ---------- champs / sliders ---------- */
.field { display: block; margin: .9rem 0; font-size: .85rem; color: var(--text); }
.field .val { float: right; color: var(--amber); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }

input[type="range"] {
  width: 100%; margin-top: .35rem; appearance: none; height: 6px;
  background: var(--panel-2); border-radius: 3px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--amber); border: 3px solid #241500; cursor: grab;
  box-shadow: 0 0 8px rgba(255,179,71,.5);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--amber); border: 3px solid #241500; cursor: grab;
}
input[type="range"]:disabled { opacity: .35; }

/* ---------- switch ---------- */
.switch-row { display: flex; align-items: center; gap: .6rem; font-size: .85rem; cursor: pointer; margin: .8rem 0; }
.switch-row input { display: none; }
.switch {
  width: 40px; height: 22px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line); position: relative; transition: background .2s; flex-shrink: 0;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: left .2s, background .2s;
}
.switch-row input:checked + .switch { background: var(--amber-deep); }
.switch-row input:checked + .switch::after { left: 20px; background: #241500; }

/* ---------- liste d'effets ---------- */
.fx-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.fx-item {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: .5rem .7rem;
}
.fx-item .fx-head { display: flex; align-items: center; gap: .55rem; font-size: .85rem; cursor: pointer; }
.fx-item .fx-emoji { width: 1.4em; text-align: center; }
.fx-item input[type="checkbox"] { accent-color: var(--amber); width: 16px; height: 16px; }
.fx-item .fx-slider { margin-top: .4rem; display: none; }
.fx-item.enabled { border-color: var(--amber-deep); }
.fx-item.enabled .fx-slider { display: block; }
.fx-item .fx-strength { float: right; color: var(--amber); font-family: var(--font-mono); font-size: .75rem; }

/* ---------- now playing ---------- */
.np-body { display: flex; gap: 1.1rem; align-items: center; }
.cassette {
  width: 120px; height: 76px; flex-shrink: 0; border-radius: 8px;
  background: linear-gradient(160deg, #35281a, #241b10);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
}
.reel {
  width: 34px; height: 34px; border-radius: 50%;
  border: 4px dashed var(--muted); background: #14110e;
}
.playing .reel { animation: spin 1.8s linear infinite; border-color: var(--amber); }
@keyframes spin { to { transform: rotate(360deg); } }

.np-info { flex: 1; min-width: 0; }
.np-title { font-size: 1rem; color: var(--text); margin: 0 0 .4rem; overflow-wrap: anywhere; }
.np-badges { display: flex; flex-wrap: wrap; gap: .3rem; min-height: 1.4rem; }
.badge {
  font-family: var(--font-mono); font-size: .68rem;
  background: var(--panel-2); border: 1px solid var(--amber-deep); color: var(--amber);
  border-radius: 999px; padding: .1rem .55rem;
}
.badge.none { border-color: var(--line); color: var(--muted); }
.progress { height: 6px; background: var(--panel-2); border-radius: 3px; margin: .6rem 0 .3rem; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--amber-deep), var(--amber)); transition: width .25s linear; }
.np-next { color: var(--muted); margin: 0; }

/* ---------- dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius);
  padding: 1.2rem; text-align: center; color: var(--muted);
  transition: border-color .2s, background .2s;
}
.dropzone.drag { border-color: var(--amber); background: rgba(255,179,71,.06); color: var(--amber); }
.dropzone p { margin: 0 0 .6rem; }
.upload-log { list-style: none; margin: .6rem 0 0; padding: 0; max-height: 130px; overflow: auto; }
.upload-log li { padding: .1rem 0; }
.upload-log .ok { color: var(--led-green); }
.upload-log .ko { color: var(--red); }

/* ---------- historique & palmarès ---------- */
.history, .leaderboard { margin: 0; padding: 0; list-style: none; max-height: 380px; overflow: auto; }
.history li { margin-bottom: .55rem; font-size: .8rem; }
.history .h-file { font-family: var(--font-mono); overflow-wrap: anywhere; }
.history .h-fx { color: var(--muted); font-size: .72rem; }
.history .h-btn {
  background: none; border: 1px solid var(--amber-deep); color: var(--amber);
  border-radius: 6px; cursor: pointer; font-size: .7rem; padding: 0 .45rem; margin-left: .4rem;
}
.history .h-btn:hover { background: var(--amber-deep); color: #241500; }
.history .h-btn:disabled { opacity: .4; cursor: wait; }
.leaderboard li { margin-bottom: .35rem; overflow-wrap: anywhere; }
.leaderboard .rank {
  display: inline-block; min-width: 2.3em; color: var(--muted);
  font-family: var(--font-mono);
}
.leaderboard .count { color: var(--amber); }

/* ---------- mémoires ---------- */
.preset-list { display: flex; flex-direction: column; gap: .3rem; margin-top: .5rem; }
.preset { display: flex; gap: .35rem; }
.preset-load {
  flex: 1; text-align: left; font-family: var(--font-mono); font-size: .78rem;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: .35rem .6rem; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.preset-load:hover { border-color: var(--amber); }
.preset-load.empty { color: var(--muted); font-style: italic; cursor: default; }
.preset-load.empty:hover { border-color: var(--line); }
.preset-save, .preset-del {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: .78rem; padding: .3rem .5rem; flex-shrink: 0;
}
.preset-save:hover { border-color: var(--amber); }
.preset-del:hover { border-color: var(--red); color: var(--red); }

/* ---------- boîte à samples ---------- */
.box-details summary { cursor: pointer; color: var(--muted); }
.box-details summary:hover { color: var(--amber); }
.box-list { list-style: none; margin: .5rem 0 0; padding: 0; max-height: 180px; overflow: auto; }
.box-list li { padding: .12rem 0; overflow-wrap: anywhere; }
.box-list .uploader { color: var(--muted); }

/* ---------- studio découpe ---------- */
.hidden { display: none !important; }
.rec-controls { display: flex; gap: .6rem; flex-wrap: wrap; }
#wave {
  display: block; width: 100%; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  cursor: crosshair; touch-action: none;
}
.editor { margin-top: .9rem; }
.editor-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin: .6rem 0; }
.editor-row label { display: flex; align-items: center; gap: .35rem; color: var(--muted); }
.editor-row input[type="number"] {
  width: 90px; padding: .3rem .45rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: var(--font-mono); font-size: .8rem;
}
.editor-row input[type="text"] {
  flex: 1; min-width: 140px; padding: .45rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: var(--font-mono); font-size: .8rem;
}
.editor-row input:focus { outline: 2px solid var(--amber-deep); }
#cut-dur { color: var(--amber); }

/* ---------- footer ---------- */
.footer { text-align: center; color: var(--muted); padding: 1.4rem; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem 2.4rem; text-align: center; max-width: 380px; width: calc(100% - 2rem);
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-photos { display: flex; justify-content: center; gap: .6rem; margin-bottom: 1rem; }
.login-form label { display: block; text-align: left; font-size: .8rem; color: var(--muted); margin: .8rem 0; }
.login-form input {
  width: 100%; margin-top: .25rem; padding: .55rem .7rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: var(--font-mono);
}
.login-form input:focus { outline: 2px solid var(--amber-deep); }
.login-form .btn-primary { width: 100%; margin-top: 1rem; }
.error { color: var(--red); font-size: .85rem; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .two-cols { grid-template-columns: 1fr; }
  .session { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  .playing .reel, .led.on { animation: none; }
  .polaroid, .btn-primary { transition: none; }
}

/* ---------- favoris ---------- */
.fav-list { max-height: 320px; }
.history a.h-btn { text-decoration: none; display: inline-block; }
.history .h-btn.danger:hover { background: var(--red); border-color: var(--red); color: #2b0300; }

/* ---------- boîte à samples : recherche + lecture ---------- */
.box-search { margin: .5rem 0 .2rem; }
.box-search input {
  width: 100%; padding: .45rem .6rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: var(--font-mono); font-size: .8rem;
}
.box-search input:focus { outline: 2px solid var(--amber-deep); }
.box-list li { display: flex; align-items: baseline; gap: .4rem; }
.box-play {
  background: none; border: 1px solid var(--amber-deep); color: var(--amber);
  border-radius: 6px; cursor: pointer; font-size: .7rem; padding: 0 .4rem; flex-shrink: 0;
}
.box-play:hover { background: var(--amber-deep); color: #241500; }
.box-play:disabled { opacity: .4; cursor: wait; }
.box-name { overflow-wrap: anywhere; }

/* ---------- mode jeu ---------- */
.game .game-status {
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; margin-bottom: .7rem;
}
.game-timer { color: var(--amber); font-size: 1rem; min-width: 5em; }
.game-timer.hurry { color: var(--red); animation: blink 1s infinite; }
.game-choices {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem;
}
.game-choice {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: .6rem .7rem; cursor: pointer; font-size: .82rem;
  text-align: left; overflow-wrap: anywhere; transition: border-color .15s, background .15s;
}
.game-choice:hover:not(:disabled) { border-color: var(--amber); }
.game-choice:disabled { cursor: default; opacity: .85; }
.game-choice.correct { border-color: var(--led-green); background: rgba(125,255,155,.12); color: var(--led-green); }
.game-choice.wrong { border-color: var(--red); background: rgba(255,107,94,.12); color: var(--red); }
.game-feedback { margin: .8rem 0 .3rem; color: var(--amber); min-height: 1.2rem; }
.game-scores { margin-top: .6rem; }
.score-list { list-style: none; margin: .3rem 0 0; padding: 0; }
.score-list li { margin-bottom: .3rem; }
.score-list .rank { display: inline-block; min-width: 2.3em; color: var(--muted); }
.score-list .count { color: var(--amber); }

/* ---------- salon (lobby) ---------- */
.lobby-players { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; min-height: 1.8rem; }
.lobby-chip {
  background: var(--panel-2); border: 1px solid var(--amber-deep); color: var(--amber);
  border-radius: 999px; padding: .2rem .7rem; font-family: var(--font-mono); font-size: .78rem;
}
.lobby-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
#lobby-settings { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.game-choice.picked { border-color: var(--amber); }

/* ---------- avertissement serveur périmé ---------- */
.stale-warning {
  color: var(--red) !important;
  background: rgba(255,107,94,.08);
  border: 1px solid var(--red);
  border-radius: 10px;
  padding: .7rem .8rem;
  line-height: 1.5;
}
.stale-warning code {
  background: #14110e; color: var(--amber);
  padding: .05rem .35rem; border-radius: 4px; font-family: var(--font-mono);
}

/* ---------- actions du jeu (révéler / suivant) ---------- */
.game-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin: .6rem 0; }
#game-answered { color: var(--muted); }

/* ---------- blind test : bandeau présence ---------- */
.game-presence-bar { margin-bottom: .8rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
#chief-note { margin: .3rem 0 0; }

/* ---------- blind test : accueil lobbies ---------- */
.lobby-create { display: flex; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.lobby-create input { flex: 1; min-width: 160px; }
#lobby-list { display: flex; flex-direction: column; gap: .5rem; }
.lobby-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.lobby-row-info { display: flex; flex-direction: column; gap: .1rem; }
.room-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  flex-wrap: wrap; margin-bottom: .8rem; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
#btn-reveal:disabled, #btn-next:disabled { opacity: .55; }
