@font-face {
  font-family: Montserrat;
  src: url("/fonts/montserrat-latin-var.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --primary: #e32619;
  --primary-dark: #b81d12;
  --bg: #111214;
  --surface: #1a1b1f;
  --surface-2: #23242a;
  --text: #f5f7fa;
  --muted: #b6bcc8;
  --border: rgba(255, 255, 255, .08);
  --amber: #ffd08a;
  --mint: #5ef29a;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Montserrat, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: calc(12px + var(--safe-t)) 14px calc(20px + var(--safe-b));
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.bg .glow {
  position: absolute; inset: auto auto 10% -20%;
  width: 80vw; height: 80vw; border-radius: 50%;
  background: radial-gradient(circle, rgba(227, 38, 25, .22), transparent 65%);
  filter: blur(10px);
}
.vinyl {
  position: absolute; right: -18vw; top: 8vh;
  width: min(52vw, 280px); height: min(52vw, 280px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #1a1b1f 0 14%, #0b0c0f 15% 18%,
      #1a1b1f 19% 22%, #0f1013 23% 70%, #3a3d46 71% 74%, #111214 75% 100%);
  box-shadow: 0 0 0 6px rgba(227, 38, 25, .15), 0 20px 50px rgba(0, 0, 0, .45);
  opacity: .55;
}
.vinyl::after {
  content: "";
  position: absolute; inset: 38%;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: inset 0 0 0 6px #8f120d;
}
.vinyl.on { animation: spin 2.4s linear infinite; opacity: .85; }
@keyframes spin { to { transform: rotate(360deg); } }

.top { text-align: center; margin: 0 0 14px; }
.brand, .gate .brand {
  margin: 0;
  letter-spacing: .28em;
  text-transform: uppercase;
  font-size: .7rem;
  font-weight: 700;
  color: var(--primary);
}
h1 { margin: 4px 0 2px; font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.tag, footer p, .hint, .keys-help { color: var(--muted); margin: 0; font-size: .85rem; }

.transport {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  margin: 0 auto 16px;
  max-width: 640px;
}
.beat { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; margin: 0 0 12px; }
.beat i {
  display: block; height: 6px; border-radius: 99px;
  background: #3a3d46;
}
.beat i.on { background: var(--primary); box-shadow: 0 0 8px rgba(227, 38, 25, .8); }
.beat i.bar { background: #5a5e6a; }

.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.btn {
  appearance: none; border: 0;
  background: var(--surface-2);
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  min-height: 48px;
  flex: 1 1 auto;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.play { background: var(--primary); color: #fff; }
.btn.play[aria-pressed="true"] {
  background: #5ef29a; color: #111214;
  box-shadow: 0 0 0 3px rgba(94, 242, 154, .25);
}
.btn.danger { background: #3a1715; color: #ff9c92; }

.bpm-box { display: flex; align-items: center; gap: 6px; flex: 1 1 160px; justify-content: flex-end; }
.step {
  width: 48px; height: 48px; border: 0; border-radius: 14px;
  background: var(--surface-2); font-size: 1.4rem; font-weight: 700;
}
.bpm { text-align: center; min-width: 64px; }
.bpm strong { display: block; font-size: 1.25rem; line-height: 1; }
.bpm span { font-size: .65rem; letter-spacing: .12em; color: var(--muted); }

.mix {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin: 12px 0 8px;
}
.mix label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .04em;
  text-transform: uppercase;
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 99px;
  background: #3a3d46; margin: 6px 0 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
}

.hint { margin-top: 4px; font-size: .78rem; line-height: 1.35; }

.pads {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 640px;
  margin: 0 auto;
}
.pad {
  position: relative;
  aspect-ratio: 1;
  min-height: 72px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #2a2c33, #1a1b1f);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 8px 18px rgba(0,0,0,.3);
  display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start;
  padding: 8px;
  text-align: left;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}
.pad::before {
  content: "";
  position: absolute; top: 10px; right: 10px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #3a3d46;
}
.pad[data-bank="drums"] { box-shadow: inset 0 0 0 1px rgba(227,38,25,.28), 0 8px 18px rgba(0,0,0,.3); }
.pad[data-bank="bass"] { box-shadow: inset 0 0 0 1px rgba(255,208,138,.28), 0 8px 18px rgba(0,0,0,.3); }
.pad[data-bank="fx"] { box-shadow: inset 0 0 0 1px rgba(94,242,154,.25), 0 8px 18px rgba(0,0,0,.3); }
.pad .name { font-size: .82rem; font-weight: 700; line-height: 1.15; }
.pad .key {
  position: absolute; top: 8px; left: 8px;
  font-size: .65rem; font-weight: 700; color: var(--muted); letter-spacing: .06em;
}
.pad.hit {
  transform: scale(.96);
  background: linear-gradient(180deg, #3a2422, #2a1615);
}
.pad[data-bank="drums"].hit { background: linear-gradient(180deg, #5a1c16, #2a1615); }
.pad[data-bank="bass"].hit { background: linear-gradient(180deg, #3a3224, #241e14); }
.pad[data-bank="fx"].hit { background: linear-gradient(180deg, #1c3328, #14201a); }
.pad.latched::before { background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.pad.latched[data-bank="bass"]::before { background: var(--amber); box-shadow: 0 0 8px var(--amber); }

.keys-help { max-width: 640px; margin: 14px auto 0; font-size: .75rem; text-align: center; }
kbd {
  display: inline-block; min-width: 1.3em; padding: 1px 5px; margin: 0 1px;
  border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border);
  font-size: .7rem; font-family: inherit;
}
footer { max-width: 640px; margin: 18px auto 0; text-align: center; }
footer p { font-size: .75rem; line-height: 1.45; }

.gate {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(11, 12, 15, .86);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.gate[hidden] { display: none; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 28px 22px;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
}
.gate-card h2 { margin: 8px 0 10px; font-size: 1.6rem; }
.gate-card p { color: var(--muted); margin: 0 0 18px; }
.gate-card .btn { width: 100%; }

@media (min-width: 700px) {
  .pads { gap: 12px; }
  .pad { border-radius: 20px; }
  .pad .name { font-size: .95rem; }
  h1 { font-size: 2rem; }
  .mix { grid-template-columns: repeat(4, 1fr); }
}
@media (max-height: 700px) and (orientation: landscape) {
  body { padding-top: calc(6px + var(--safe-t)); }
  .top { display: flex; align-items: baseline; gap: 10px; justify-content: center; margin-bottom: 8px; }
  .top h1 { font-size: 1.15rem; margin: 0; }
  .tag { display: none; }
  .pads { grid-template-columns: repeat(8, 1fr); max-width: 980px; }
  .pad { min-height: 58px; }
  .vinyl { width: 120px; height: 120px; top: auto; bottom: 8px; opacity: .3; }
}

/* ---- Bascule Mixeur / Jeu du drop ---- */
.modes {
  display: flex;
  max-width: 640px;
  margin: 0 auto 14px;
  padding: 4px;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0,0,0,.25);
}
.mode {
  flex: 1 1 0;
  border: 0;
  background: transparent;
  min-height: 46px;
  border-radius: 999px;
  font-weight: 700;
  color: var(--muted);
}
.mode[aria-selected="true"] {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(227, 38, 25, .35);
}

.drop-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
  margin: 0 0 10px;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.drop-stats strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}
.drop-stage {
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
}
.drop-dial {
  --p: 0;
  position: relative;
  width: min(78vw, 300px);
  height: min(78vw, 300px);
  margin: 8px auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    conic-gradient(from -90deg, var(--primary) calc(var(--p) * 360deg), #23242a 0);
  box-shadow: 0 16px 40px rgba(0,0,0,.4);
}
.drop-dial::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: var(--bg);
}
.drop-mark {
  position: absolute;
  top: -2px;
  left: 50%;
  width: 4px;
  height: 16px;
  margin-left: -2px;
  border-radius: 2px;
  background: #fff;
  z-index: 2;
  box-shadow: 0 0 8px rgba(255,255,255,.7);
}
.drop-pad {
  position: relative;
  z-index: 1;
  width: calc(100% - 36px);
  height: calc(100% - 36px);
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #ff6a5c, var(--primary) 48%, var(--primary-dark));
  color: #fff;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.2), 0 10px 24px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  touch-action: none;
  user-select: none;
  transition: transform .08s ease, filter .12s ease;
}
.drop-pad:active, .drop-pad.hit { transform: scale(.96); filter: brightness(1.15); }
.drop-pad.armed { box-shadow: inset 0 2px 0 rgba(255,255,255,.2), 0 0 0 6px rgba(227,38,25,.28), 0 10px 24px rgba(0,0,0,.35); }
.drop-pad.perfect { background: radial-gradient(circle at 38% 30%, #9cffc8, #5ef29a 50%, #1f2a22); color: #111214; }
.drop-label { font-size: clamp(1.4rem, 6vw, 2rem); line-height: 1; }
.drop-count { font-size: clamp(2rem, 10vw, 3.2rem); line-height: 1; min-height: 0; }
.drop-feedback {
  min-height: 2.4em;
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 800;
}
.drop-feedback.perfect { color: var(--mint); }
.drop-feedback.great { color: var(--amber); }
.drop-feedback.good { color: #f5f7fa; }
.drop-feedback.ok, .drop-feedback.miss { color: #ff9c92; }
body.flash-perfect .glow {
  background: radial-gradient(circle, rgba(94, 242, 154, .35), transparent 65%);
}

@media (min-width: 700px) {
  .drop-dial { width: 300px; height: 300px; }
}
@media (max-height: 700px) and (orientation: landscape) {
  .modes { margin-bottom: 8px; }
  .drop-stage { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 20px; }
  .drop-dial { width: 38vh; height: 38vh; margin: 0; }
  .drop-stats { margin-bottom: 6px; }
}
