/* BOOM BOOM MACHINE
   Styles regroupés par composant. Les adaptations mobiles restent dans chaque
   section, avec leurs valeurs pour écrans compacts. */


@font-face {
  font-family: Machine;
  src: local("Arial Black"), url("fonts/arial-black.woff2") format("woff2");
  font-weight: 900;
  font-display: optional;
}

/* 01. Base et éléments communs */

:root {
  color-scheme: dark;
  --bg: #101110;
  --panel: #232522;
  --ink: #f3f3e9;
  --muted: #a5aaa0;
  --acid: #dfff00;
  /* Couleur de chauffe du fond et des quatre accents (format #RRGGBB).
     Les nuances sombres du bouton vibration sont dérivées automatiquement. */
  --heat-color: #e5364f;
  --border: #41463b;
  --orange: #ff8b51;
  --mint: #a6d9c8;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 280px;
  background: radial-gradient(ellipse at 50% 0, #2d3125 0, transparent 68%);
  min-height: 100svh;
}

button {
  -webkit-tap-highlight-color: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

input {
  -webkit-tap-highlight-color: transparent;
}

a {
  -webkit-tap-highlight-color: transparent;
  color: inherit;
  text-decoration: none;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 4px;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.icon-button {
  background: none;
  border: 1px solid var(--border);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 30px;
  line-height: 1;
}

kbd {
  border: 1px solid #454a3e;
  border-radius: 3px;
  padding: 3px 4px;
  font-size: 10px;
}

html:fullscreen {
  overflow: auto;
  background: #151615;
}

html:-webkit-full-screen {
  overflow: auto;
  background: #151615;
}

@media (max-width:760px) {
  body {
    background: #151615;
  }
}

@media (hover:hover) and (pointer:fine) {
  .icon-button:hover {
    background: #34382e;
  }
}

/* 02. Mise en page */

.machine {
  max-width: 1080px;
  margin: auto;
  padding: 28px 32px 20px;
}

.instrument {
  display: grid;
  grid-template-columns: 1fr 1.06fr;
  align-items: stretch;
  background: var(--panel);
  padding: 12px;
  border: 1px solid #484e3e;
  border-radius: 18px;
  box-shadow: 0 10px 0 #070807, 0 30px 100px #0008, inset 0 1px #ffffff18;
  gap: 12px;
}

@media (min-width:1100px) {
  .machine {
    padding-top: 48px;
  }
}

@media (max-width:760px) {
  .machine {
    max-width: 460px;
    padding: 18px 14px max(16px, env(safe-area-inset-bottom));
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .instrument {
    display: block;
    padding: 9px;
    border-radius: 13px;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .machine {
    padding-top: max(11px, env(safe-area-inset-top));
  }
}

@media (max-width:350px) {
  .machine {
    padding-left: 9px;
    padding-right: 9px;
  }
}

/* 03. En-tête et plein écran */

.masthead {
  display: flex;
  align-items: center;
  margin: 0 0 26px;
  justify-content: space-between;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 19px;
  font-weight: 900;
  line-height: .95;
  letter-spacing: -.7px;
}

.brand b {
  font-size: 23px;
  letter-spacing: 1px;
}

.brand-mark {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  width: 38px;
  height: 38px;
  transform: rotate(-5deg);
}

.brand-mark i {
  background: var(--acid);
  border-radius: 2px;
  background-color: var(--heat-accent, var(--acid));
  transition: background-color var(--heat-control-fade, 220ms) ease;
}

.brand-mark i:last-child {
  opacity: .35;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#fullscreen-button,
#fullscreen-button .fullscreen-exit,
#fullscreen-button[aria-pressed="true"] .fullscreen-enter {
  display: none;
}

#fullscreen-button[aria-pressed="true"] .fullscreen-exit {
  display: block;
}

@media (min-width:1100px) {
  .masthead {
    margin-bottom: 32px;
  }
}

@media (min-width:761px) {
  .brand {
    white-space: nowrap;
  }

  .brand br {
    display: none;
  }

  .brand b {
    margin-left: .25em;
    font-size: inherit;
    letter-spacing: inherit;
  }
}

@media (max-width:760px) {
  .masthead {
    margin-bottom: 18px;
  }

  .brand {
    font-size: 16px;
    line-height: 1;
    gap: 10px;
  }

  .brand b {
    font-size: 19px;
    letter-spacing: 1px;
  }

  .brand-mark {
    gap: 3px;
    width: 34px;
    height: 34px;
  }

  .masthead .icon-button {
    height: 35px;
    width: 35px;
  }

  .masthead .icon-button svg {
    width: 19px;
    height: 19px;
  }

  #fullscreen-button {
    display: flex;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .masthead {
    margin-bottom: 12px;
  }
}

@media (max-width:350px) {
  .brand {
    font-size: 14px;
  }

  .brand b {
    font-size: 17px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }
}

/* 04. Scène, portrait et textes animés */

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 9px;
  isolation: isolate;
  background: #dfff00;
  color: #12140a;
  border: 1px solid #050705;
  min-height: 0;
  width: 100%;
  min-width: 0;
  /* Intensité de la sérigraphie : 0 = invisible, 1 = opaque. */
  --serigraphy-opacity: .5;
  --serigraphy-ink: #364009;
  --serigraphy-step: 7.4px;
  --serigraphy-dot: 1.6px;
}

.stage:after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url(data:image/svg+xml,%3Csvg\ xmlns=\'http://www.w3.org/2000/svg\'\ width=\'160\'\ height=\'160\'%3E%3Cfilter\ id=\'n\'%3E%3CfeTurbulence\ type=\'fractalNoise\'\ baseFrequency=\'.8\'\ numOctaves=\'3\'\ stitchTiles=\'stitch\'/%3E%3C/filter%3E%3Crect\ width=\'100%25\'\ height=\'100%25\'\ filter=\'url\(%23n\)\'\ opacity=\'.23\'/%3E%3C/svg%3E);
  opacity: .35;
  mix-blend-mode: multiply;
  z-index: 5;
}

.edition {
  position: absolute;
  left: 22px;
  right: 22px;
  top: 20px;
  display: flex;
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  z-index: 4;
  gap: 8px;
  justify-content: flex-start;
}

.stage-copy {
  position: absolute;
  top: 64px;
  left: 19px;
  z-index: 0;
  display: flex;
  flex-direction: column;
  font-family: Machine, "Arial Black", Impact, sans-serif;
  font-size: clamp(55px, 7vw, 89px);
  font-weight: 900;
  letter-spacing: -.085em;
  line-height: .95;
  transform: rotate(-5deg);
  opacity: 1;
  transition: opacity var(--stage-return-fade, .25s) ease;
  animation: var(--title-float-animation, none) var(--title-float-duration, 8s) ease-in-out infinite;
}

.stage-copy span:last-child {
  font-size: .57em;
  letter-spacing: -.07em;
  margin-top: 6px;
}

.stage-ring {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  z-index: -1;
  pointer-events: none;
}

.portrait-wrap {
  position: absolute;
  width: 480px;
  height: 480px;
  max-width: 125%;
  right: -30px;
  z-index: 2;
  transform-origin: 50% 82%;
  will-change: transform;
  bottom: -18px;
}

/* Conserve la largeur du portrait à 95 %, bouche et clignement compris. */
.portrait {
  height: 100%;
  width: 100%;
  background-image: url(assets/gunn-sprites.png);
  background-size: 200% 200%;
  background-repeat: no-repeat;
  filter: drop-shadow(6px 10px 0 #17200020);
  position: relative;
  background-position: 0% 0%;
  transform: scaleX(.95);
  transform-origin: center bottom;
}

.comic-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.shout {
  position: absolute;
  left: 12%;
  top: 31%;
  font-size: clamp(32px, 5vw, 62px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: -.065em;
  color: var(--ink);
  -webkit-text-stroke: 2px #11150b;
  text-shadow: 3px 3px 0 #11150b, 5px 5px 0 #11150b;
  white-space: nowrap;
  transform: rotate(-12deg);
  animation: shout .55s both;
  font-family: sans-serif;
}

.shout.small {
  font-size: clamp(28px, 4vw, 44px);
}

.portrait:after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: inherit;
  background-size: 200% 200%;
  background-position: var(--mouth-position, 0% 0%);
  background-repeat: no-repeat;
  mask-image: radial-gradient(ellipse 20% 22%at 51% 40%, #000 50%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 20% 22%at 51% 40%, #000 50%, transparent 100%);
}

.idle-portrait {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.portrait.is-idle-animating {
  background-image: none;
}

.portrait.is-idle-animating:after {
  visibility: hidden;
}

.portrait.is-idle-animating .idle-portrait {
  display: block;
}

.stage.is-performing .stage-copy {
  opacity: 0;
  transition-duration: .12s;
}

.stage:before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--heat-color);
  opacity: 0;
  transition: opacity var(--stage-return-fade, .25s) ease;
}

.stage.is-performing:before {
  opacity: var(--stage-heat, 0);
  transition-duration: .22s;
}

.stage.is-performing.is-cooling:before {
  opacity: calc(var(--stage-heat, 0)*.12);
  transition-duration: var(--stage-idle-delay, 1s);
}

.stage.is-returning:before {
  opacity: calc(var(--stage-return-heat, 0)*(1 - var(--stage-return-progress, 0)));
  transition: none;
}

.stage.is-returning .stage-copy {
  opacity: var(--stage-return-progress, 0);
  transition: none;
}

.shout.held {
  animation: shout-enter .16s both;
}

.stage-copy.is-jitter-ready {
  display: block;
}

.stage-copy-content {
  display: flex;
  flex-direction: column;
  column-gap: inherit;
  row-gap: inherit;
}

.stage-copy-content.is-jittering {
  animation: stage-title-jitter .893s steps(1) both;
}

.stage-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: var(--serigraphy-opacity);
  background-image: radial-gradient(circle at 25% 25%, var(--serigraphy-ink) var(--serigraphy-dot), transparent calc(var(--serigraphy-dot) + .3px)), radial-gradient(circle at 75% 75%, var(--serigraphy-ink) var(--serigraphy-dot), transparent calc(var(--serigraphy-dot) + .3px));
  background-size: var(--serigraphy-step) var(--serigraphy-step);
  -webkit-mask-image: radial-gradient(ellipse 65% 88%at -8% 82%, #000 0%, #000 23%, #0009 43%, #0003 60%, transparent 77%), radial-gradient(ellipse 49% 72%at 105% 0%, #000 0%, #000 20%, #0008 43%, #0002 61%, transparent 79%);
  mask-image: radial-gradient(ellipse 65% 88%at -8% 82%, #000 0%, #000 23%, #0009 43%, #0003 60%, transparent 77%), radial-gradient(ellipse 49% 72%at 105% 0%, #000 0%, #000 20%, #0008 43%, #0002 61%, transparent 79%);
}

.stage-ring::after {
  content: "";
  position: absolute;
  box-sizing: border-box;
  width: 340px;
  height: 340px;
  left: 12%;
  top: 36%;
  border-radius: 50%;
  border: 1px solid #3e480633;
  box-shadow: 0 0 0 30px #5260060c, 0 0 0 60px #5260060c;
}

@media (min-width:1100px) {
  .portrait-wrap {
    width: 510px;
    height: 510px;
  }
}

@media (min-width:761px) {
  .stage-copy {
    top: 70px;
    left: 35px;
    right: 18px;
    display: grid;
    grid-template-columns: max-content max-content;
    column-gap: .16em;
    row-gap: 5px;
    font-size: clamp(32px, 4.4vw, 56px);
    line-height: .94;
    transform-origin: top left;
  }

  .stage-copy>span {
    white-space: nowrap;
  }

  .stage-copy>span:last-child {
    grid-column: 1/-1;
    font-size: .72em;
    margin-top: 0;
  }

  .comic-layer {
    bottom: auto;
    height: 40%;
  }

  .stage-copy-content {
    display: grid;
    grid-template-columns: inherit;
  }

  .stage-copy-content>span {
    white-space: nowrap;
  }

  .stage-copy-content>span:last-child {
    grid-column: 1/-1;
    font-size: .72em;
    margin-top: 0;
  }
}

@media (max-width:760px) {
  .stage {
    border-radius: 6px;
    height: auto;
    aspect-ratio: 1.82;
    min-height: 172px;
    container-type: inline-size;
    --serigraphy-step: 6px;
    --serigraphy-dot: 1.3px;
  }

  .edition {
    right: 12px;
    top: 12px;
    left: 13px;
    font-size: 11px;
  }

  .stage-copy {
    letter-spacing: -.085em;
    top: 39px;
    left: 16px;
    font-size: clamp(30px, 12vw, 48px);
    line-height: .92;
    top: clamp(36px, 12.5cqi, 43px);
    font-size: calc(clamp(30px, 13.8cqi, 48px)*.92);
  }

  .stage-copy span:last-child {
    letter-spacing: -.06em;
    font-size: .5em;
    margin-top: 6px;
  }

  .portrait-wrap {
    max-width: none;
    width: 73%;
    height: auto;
    aspect-ratio: 1;
    top: 9px;
    bottom: auto;
    right: -8%;
  }

  .shout {
    font-size: 39px;
    left: 10%;
    top: 32%;
    -webkit-text-stroke: 1.2px;
    text-shadow: 2px 2px 0 #11150b, 3px 3px 0 #11150b;
  }

  .shout.small {
    font-size: 32px;
  }

  .stage-ring::after {
    width: 185px;
    height: 185px;
    left: 39%;
    top: 27%;
    box-shadow: 0 0 0 15px #5260060c, 0 0 0 30px #5260060c;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .stage {
    aspect-ratio: 2.04;
    min-height: 156px;
  }

  .portrait-wrap {
    top: 6px;
    width: 70%;
    right: -7%;
  }
}

@media (max-width:350px) {
  .stage {
    min-height: 155px;
  }

  .stage-copy {
    left: 12px;
  }

  .portrait-wrap {
    width: 75%;
    right: -9%;
    top: 12px;
  }

  .edition {
    font-size: 10px;
  }
}

/* 05. Banque et vumètre */

.console {
  padding: 14px 13px 6px;
  min-width: 0;
  padding-top: 4px;
  padding-bottom: 10px;
}

.console-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 27px;
  margin-bottom: 14px;
}

.bank-label {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  letter-spacing: .06em;
  min-width: 0;
}

.bank-label>span {
  font-family: monospace;
  font-weight: 700;
  background: var(--acid);
  color: #1a2000;
  padding: 5px 6px;
  border-radius: 3px;
  white-space: nowrap;
  background-color: var(--heat-accent, var(--acid));
  transition: background-color var(--heat-control-fade, 220ms) ease;
}

.meter {
  display: flex;
  gap: 3px;
}

.meter i {
  width: 4px;
  height: 11px;
  background: #4b543a;
  border-radius: 1px;
}

.meter i.on {
  background: #a6cd6c;
}

.meter i:nth-last-child(-n+2).on {
  background: var(--orange);
}

.console-top .meter {
  gap: 3px;
  padding: 6px 0;
}

.console-top .meter i {
  width: 4px;
  height: 12px;
}

.meter i:nth-child(n+7).on {
  background: #dfff00;
}

.meter i:nth-child(n+10).on {
  background: #ffb347;
}

.meter i:nth-child(n+12).on {
  background: #ff6455;
}

@media (max-width:760px) {
  .console {
    padding: 12px 3px 11px;
  }

  .console-top {
    min-height: 25px;
    margin-bottom: 11px;
  }

  .bank-label {
    gap: 8px;
  }

  .bank-label>span {
    font-size: 10px;
  }

  .meter i {
    height: 9px;
    width: 3px;
  }

  .meter {
    gap: 3px;
  }

  .console-top .meter i {
    height: 10px;
    width: 3px;
  }

  .console-top .meter {
    gap: 3px;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .console {
    padding-top: 11px;
    padding-bottom: 9px;
  }
}

@media (max-width:350px) {
  .console-top {
    margin-bottom: 10px;
  }
}

/* 06. Pads et états de lecture */

.pad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.pad {
  position: relative;
  min-width: 0;
  min-height: 86px;
  aspect-ratio: 1.03;
  border: 1px solid #666947;
  border-bottom: 4px solid #0b0d08;
  border-radius: 7px;
  background: linear-gradient(155deg, #393d2a, #2b2f22);
  color: #dfe990;
  box-shadow: inset 0 1px 1px #ffffff17, 0 3px 0 #11130c, 0 4px 8px #0005;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform .065s;
  gap: 0;
  padding: 0 4px;
}

/* Six palettes purement visuelles : green, orange, mint, purple, blue, pink.
   Green garde les couleurs par défaut du pad. */
.pad.orange {
  background: linear-gradient(155deg, #453429, #312720);
  color: #f8ba96;
  border-color: #79513b;
  border-bottom-color: #140c07;
}

.pad.mint {
  background: linear-gradient(155deg, #2c3b35, #232e29);
  color: #b7d8cd;
  border-color: #49695c;
  border-bottom-color: #0b120f;
}

.pad.purple {
  --pad-on: #c6a0f0;
  --pad-on-ink: #21152f;
  --pad-on-edge: #7951a5;
  --pad-base: #110c1a;
  --pad-glow: #c6a0f026;
  background: linear-gradient(155deg, #3d334f, #332b43);
  color: #dec7fa;
  border-color: #635579;
  border-bottom-color: var(--pad-base);
}

.pad.blue {
  --pad-on: #9cccf0;
  --pad-on-ink: #122838;
  --pad-on-edge: #547f9f;
  --pad-base: #0b121a;
  --pad-glow: #9cccf026;
  background: linear-gradient(155deg, #2e4051, #263442);
  color: #b6d8f4;
  border-color: #466277;
  border-bottom-color: var(--pad-base);
}

.pad.pink {
  --pad-on: #eca4c3;
  --pad-on-ink: #341823;
  --pad-on-edge: #a6617e;
  --pad-base: #1a0c13;
  --pad-glow: #eca4c326;
  background: linear-gradient(155deg, #4d3441, #402b36);
  color: #f0bbd2;
  border-color: #755367;
  border-bottom-color: var(--pad-base);
}

.pad .pad-number {
  position: absolute;
  font-family: monospace;
  font-size: 11px;
  opacity: .62;
  top: 8px;
  left: 9px;
}

.pad .pad-key {
  position: absolute;
  font-family: monospace;
  font-size: 11px;
  top: 8px;
  right: 9px;
  opacity: .45;
}

.pad-name {
  font-weight: 800;
  white-space: nowrap;
  font-size: clamp(.875rem, 1.7vw, 1.05rem);
  line-height: 1.12;
  letter-spacing: -.035em;
  text-align: center;
}

.pad-sub {
  font-family: monospace;
  font-size: 10px;
  opacity: .65;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
}

.pad .ready-indicator {
  position: absolute;
  background: currentColor;
  border-radius: 50%;
  opacity: 0;
  bottom: 9px;
  right: 9px;
  width: 4px;
  height: 4px;
  box-shadow: 0 0 5px currentColor;
}

.pad.ready .ready-indicator {
  opacity: .8;
}

.pad:not(.ready):not(.empty) {
  opacity: 1;
}

.pad:hover {
  filter: brightness(1.13);
}

.pad.pressed,
.pad.playing {
  transform: translateY(3px);
  background: var(--acid);
  color: #172000;
  border-color: var(--acid);
  border-bottom-color: #96aa00;
  box-shadow: 0 0 18px #dfff0026, inset 0 1px #ffffff88;
}

.pad.orange.pressed,
.pad.orange.playing {
  background: var(--orange);
  border-color: var(--orange);
  border-bottom-color: #b05832;
  color: #361709;
  box-shadow: 0 0 18px #ff8b5126;
}

.pad.mint.pressed,
.pad.mint.playing {
  background: var(--mint);
  border-color: var(--mint);
  border-bottom-color: #5e9281;
  color: #102c22;
  box-shadow: 0 0 18px #a6d9c826;
}

.pad:is(.purple, .blue, .pink).pressed,
.pad:is(.purple, .blue, .pink).playing {
  background: var(--pad-on);
  border-color: var(--pad-on);
  border-bottom-color: var(--pad-on-edge);
  color: var(--pad-on-ink);
  box-shadow: 0 0 18px var(--pad-glow);
}

.pad.empty {
  color: #6b7064;
  box-shadow: inset 0 2px 6px #0005;
  background: repeating-linear-gradient(135deg, #20231e, #20231e 5px, #242720 5px, #242720 6px);
  border: 1px solid #383e31;
  opacity: .75;
}

.pad.empty .pad-name {
  font-weight: 400;
  font-size: 25px;
}

.pad.empty .pad-sub {
  font-size: 10px;
  opacity: 1;
}

.pad-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  margin-top: 4px;
  pointer-events: none;
}

.pad:focus,
.pad:focus-visible {
  outline: none;
}

.pad:not(.empty) {
  border-bottom-width: 2px;
}

.pad:not(.empty):not(.pressed):not(.playing) {
  box-shadow: inset 0 1px 1px #ffffff17, 0 2px 0 #11130c, 0 4px 6px -2px #0005;
}

/* Au démarrage : allumage et extinction nets, dans la couleur de chaque famille.
   Les durées se règlent dans VISUAL_EFFECTS.padStartup, en haut d’app.js.
   Les pads vides restent éteints ; un véritable appui reste prioritaire. */
.pad.is-starting:not(.empty):not(.pressed):not(.playing) {
  background: var(--acid);
  color: #172000;
  border-color: var(--acid);
  border-bottom-color: #0b0d08;
}

.pad.orange.is-starting:not(.empty):not(.pressed):not(.playing) {
  background: var(--orange);
  color: #361709;
  border-color: var(--orange);
  border-bottom-color: #140c07;
}

.pad.mint.is-starting:not(.empty):not(.pressed):not(.playing) {
  background: var(--mint);
  color: #102c22;
  border-color: var(--mint);
  border-bottom-color: #0b120f;
}

.pad:is(.purple, .blue, .pink).is-starting:not(.empty):not(.pressed):not(.playing) {
  background: var(--pad-on);
  color: var(--pad-on-ink);
  border-color: var(--pad-on);
  border-bottom-color: var(--pad-base);
}

@media (max-width:760px) {
  .pad-grid {
    gap: 9px;
  }

  .pad {
    min-height: 66px;
    aspect-ratio: 1.06;
    border-radius: 7px;
    padding: 0 3px;
  }

  .pad-name {
    white-space: nowrap;
    line-height: 1.15;
    letter-spacing: -.045em;
    font-size: 14px;
  }

  .pad-sub {
    font-size: 9px;
  }

  .pad .pad-number {
    font-size: 10px;
    top: 7px;
    left: 7px;
  }

  .pad .pad-key {
    display: none;
  }

  .pad .ready-indicator {
    bottom: 7px;
    right: 7px;
    width: 3px;
    height: 3px;
  }

  .pad.empty .pad-sub {
    font-size: 8px;
  }

  .pad-caption {
    gap: 5px;
    margin-top: 5px;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .pad {
    aspect-ratio: 1.12;
    min-height: 62px;
  }
}

@media (max-width:350px) {
  .pad-grid {
    gap: 7px;
  }

  .pad-name {
    letter-spacing: -.045em;
    font-size: 12px;
  }

  .pad-sub {
    font-size: 8px;
  }

  .pad {
    min-height: 59px;
  }

  .pad .pad-number {
    font-size: 9px;
    top: 6px;
    left: 6px;
  }

  .pad-caption {
    gap: 4px;
    margin-top: 5px;
  }
}

/* 07. Lecture, vibrations et volume */

.transport {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 22px 0 18px;
  align-items: center;
  margin-top: 23px;
  margin-bottom: 18px;
}

.mode-switch {
  display: flex;
  padding: 3px;
  border: 1px solid #434938;
  background: #191d15;
  border-radius: 6px;
}

.mode-switch button {
  border: 0;
  background: none;
  color: #aab19c;
  padding: 7px 14px;
  min-height: 32px;
  border-radius: 3px;
  font-weight: 600;
  font-size: 14px;
}

.mode-switch .selected {
  background: #d8ddcd;
  color: #242b19;
  box-shadow: 0 1px 4px #0005;
}

.stop-button {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #53594a;
  border-radius: 5px;
  background: #2f3429;
  padding: 9px 10px;
  min-height: 40px;
  font-weight: 700;
  font-size: 14px;
}

.stop-button span {
  height: 8px;
  width: 8px;
  background: #e8eadf;
}

.stop-button:active {
  background: #59624a;
}

.volume-row {
  display: flex;
  gap: 13px;
  align-items: center;
  border: 0;
  padding-bottom: 4px;
}

.volume-row label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10px;
  letter-spacing: .09em;
  color: #bfc5b2;
}

.volume-row svg {
  width: 20px;
}

.volume-row input {
  flex: 1;
  min-width: 0;
  height: 26px;
  cursor: pointer;
  accent-color: var(--heat-accent, var(--acid));
  transition: accent-color var(--heat-control-fade, 220ms) ease;
}

.volume-row output {
  font-family: monospace;
  font-size: 13px;
  min-width: 34px;
  text-align: right;
}

.vibration-button {
  display: none;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid #53594a;
  border-radius: 5px;
  background: #2f3429;
  color: #929a85;
  touch-action: manipulation;
}

.vibration-button[hidden] {
  display: none;
}

.vibration-button svg {
  width: 26px;
  height: 26px;
  stroke-width: 1.6;
}

.vibration-button[aria-pressed="true"] {
  background: #272e1e;
  color: var(--heat-accent, var(--acid));
  border-color: var(--heat-vibration-border, #697440);
  background-color: var(--heat-vibration-background, #272e1e);
  transition: color var(--heat-control-fade, 220ms) ease, border-color var(--heat-control-fade, 220ms) ease, background-color var(--heat-control-fade, 220ms) ease;
}

.vibration-button:active {
  background: #3b4430;
}

.vibration-button[aria-pressed="true"]:active {
  background-color: #3b4430;
}

@media (max-width:760px) {
  .transport {
    margin: 17px 0 11px;
    margin-top: 23px;
    margin-bottom: 17px;
  }

  .mode-switch button {
    font-size: 14px;
    min-height: 33px;
    padding: 7px 15px;
  }

  .stop-button {
    min-height: 41px;
    padding: 9px 13px;
    font-size: 13px;
  }

  .volume-row {
    gap: 11px;
    padding: 0;
  }

  .volume-row label {
    font-size: 10px;
  }

  .volume-row svg {
    width: 18px;
  }

  .volume-row output {
    font-size: 13px;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .transport {
    margin-top: 18px;
    margin-bottom: 13px;
  }
}

@media (max-width:350px) {
  .volume-row label span {
    display: inline;
    font-size: 9px;
  }

  .mode-switch button {
    font-size: 13px;
    padding: 7px 12px;
  }

  .stop-button {
    font-size: 12px;
    padding: 9px 10px;
  }
}

@media (max-width:310px) {
  .transport {
    gap: 3px;
  }

  .vibration-button {
    flex-basis: 36px;
    width: 36px;
  }
}

@media (max-width:760px),(any-pointer:coarse) {
  .vibration-button:not([hidden]) {
    display: flex;
  }
}

/* 08. Pied de page */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: #8d9482;
  font-family: monospace;
  font-size: 11px;
  letter-spacing: .02em;
  margin-top: 22px;
}

.footer>span:first-child {
  color: #c1c8b3;
}

.footer button {
  color: #b3bba3;
  border: 0;
  background: none;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  font-size: 13px;
  min-height: 40px;
  padding: 8px 0;
  text-transform: none;
}

.keyboard-hint {
  font-size: 10px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.footer .keyboard-hint {
  font-size: 10px;
}

.footer .keyboard-hint kbd {
  white-space: nowrap;
}

@media (max-width:760px) {
  .footer {
    margin-top: 15px;
    font-size: 11px;
    gap: 10px;
    justify-content: center;
    text-align: center;
  }

  .keyboard-hint {
    display: none;
  }

  .footer button {
    font-size: 12px;
    min-height: 40px;
    white-space: nowrap;
  }
}

@media (max-height:750px) and (max-width:760px) {
  .footer {
    margin-top: 11px;
  }
}

@media (max-width:350px) {
  .footer {
    font-size: 10px;
  }

  .footer button {
    font-size: 11px;
  }
}

/* 09. Fenêtre d’aide */

.modal {
  width: min(480px, calc(100% - 28px));
  max-height: 85svh;
  border: 1px solid #555e44;
  border-radius: 16px;
  background: #24291e;
  color: var(--ink);
  padding: 24px;
  box-shadow: 0 22px 100px #000b;
  overscroll-behavior: contain;
}

.modal::backdrop {
  background: #090b07ba;
  backdrop-filter: blur(5px);
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.modal-heading h2 {
  font-family: Machine, "Arial Black", sans-serif;
  font-size: 25px;
  letter-spacing: -1px;
  line-height: 1.1;
  margin: 0;
}

.modal-heading .icon-button {
  flex-shrink: 0;
}

.modal p {
  line-height: 1.6;
  color: #c4ccb8;
  font-size: 16px;
}

.modal dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 15px;
  font-size: 14px;
  line-height: 1.5;
}

.modal dt {
  font-weight: 700;
  color: var(--acid);
}

.modal dd {
  margin: 0;
  color: #d5daca;
}

.help-note {
  padding: 14px;
  background: #353e2a;
  border-radius: 7px;
  margin-top: 20px;
}

.help-note p {
  margin: 6px 0 0;
}

.modal .small-copy {
  font-size: 12px;
  color: #a7b096;
  line-height: 1.5;
}

.primary-button {
  background: var(--acid);
  border: 0;
  border-radius: 5px;
  color: #152000;
  min-height: 45px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .025em;
  padding: 12px 16px;
}

.keyboard-settings,
.vibration-settings {
  margin-top: 21px;
  padding-top: 18px;
  border-top: 1px solid #46513a;
}

.keyboard-heading {
  font-family: monospace;
  font-size: 13px;
  letter-spacing: .045em;
  color: var(--acid);
  font-weight: 700;
}

.keyboard-settings p,
.vibration-settings p {
  margin: 10px 0;
}

.keyboard-settings select {
  width: 100%;
  min-height: 44px;
  border: 1px solid #626d50;
  background: #1b2115;
  border-radius: 5px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 8px 10px;
}

.keyboard-reference {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.keyboard-reference kbd {
  padding: 6px 9px;
  font-size: 13px;
  border-color: #566046;
  color: #ced6bc;
}

.keyboard-map {
  display: inline-grid;
  max-width: 100%;
  grid-template-columns: minmax(0, 1fr);
}

.keyboard-map .keyboard-reference {
  flex-wrap: nowrap;
}

.keyboard-mobile-note,
.vibration-mobile-note {
  display: none;
}

#help-dialog {
  overflow: hidden;
  padding: 24px 0;
}

#help-dialog>.help-scroll {
  max-height: calc(85svh - 50px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px;
}

@media (max-width:760px) {
  .keyboard-desktop-controls,
  .desktop-only,
  .vibration-desktop-note {
    display: none;
  }

  .keyboard-mobile-note,
  .vibration-mobile-note {
    display: block;
  }
}

@media (hover:hover) and (pointer:fine) {
  #help-dialog>.help-scroll {
    scrollbar-color: #7d856f transparent;
  }
}

.help-confirm {
  display: block;
  margin: 0 auto;
}

.modal .help-credit {
  text-align: center;
  margin: 16px 0 0;
}

.help-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 10. Écran d’accès temporaire */

html.access-locked {
  overflow: hidden;
}

html.access-locked .machine {
  visibility: hidden;
}

#access-gate {
  width: min(360px, calc(100% - 32px));
  max-height: calc(100svh - 32px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 16px 60px #0008, inset 0 1px #ffffff18;
}

#access-gate::backdrop {
  background: var(--bg);
}

#access-gate h2 {
  margin: 0 0 22px;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0;
}

#access-password {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #626d50;
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

#access-password::placeholder {
  color: var(--muted);
  opacity: 1;
}

#access-error {
  min-height: 21px;
  margin: 8px 0 12px;
  font-size: 14px;
  line-height: 1.5;
  color: #f8ba96;
}

#access-gate button {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

/* 11. Notifications */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 15px);
  opacity: 0;
  pointer-events: none;
  transition: .18s;
  z-index: 10;
  background: #e3eccf;
  color: #18220b;
  border: 1px solid #a4b680;
  box-shadow: 0 6px 40px #0008;
  border-radius: 9px;
  max-width: calc(100% - 28px);
  width: max-content;
  padding: 12px 17px;
  font-size: 14px;
  line-height: 1.4;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* 12. Animations */

@keyframes shout {
  0% {
    transform: scale(.6) rotate(-18deg);
    opacity: 0;
  }

  18% {
    transform: scale(1.14) rotate(-9deg);
    opacity: 1;
  }

  65% {
    transform: scale(1) rotate(-12deg);
    opacity: 1;
  }

  100% {
    transform: translateY(-22px) scale(1.04) rotate(-14deg);
    opacity: 0;
  }
}

@keyframes stage-copy-float {
  0%,100% {
    transform: translate(0, 0) rotate(-5deg);
  }

  25% {
    transform: translate(calc(var(--title-float-distance, 2px)*.65), calc(var(--title-float-distance, 2px)*-1)) rotate(-5deg);
  }

  50% {
    transform: translate(0, calc(var(--title-float-distance, 2px)*-.5)) rotate(-5deg);
  }

  75% {
    transform: translate(calc(var(--title-float-distance, 2px)*-.65), calc(var(--title-float-distance, 2px)*.5)) rotate(-5deg);
  }
}

@keyframes shout-enter {
  from {
    transform: scale(.6) rotate(-18deg);
    opacity: 0;
  }

  to {
    transform: scale(1) rotate(-12deg);
    opacity: 1;
  }
}

@keyframes stage-title-jitter {
  0% {
    transform: skewX(-14deg) translateX(-4px);
    opacity: 1;
  }

  4.255% {
    transform: skewX(10deg) translateX(3px);
    opacity: 1;
  }

  8.511% {
    transform: translateY(-3px);
    opacity: .6;
  }

  14.894% {
    transform: none;
    opacity: 1;
  }

  80.851% {
    transform: skewX(8deg);
    opacity: 1;
  }

  85.106% {
    transform: skewX(-6deg) translateY(2px);
    opacity: .75;
  }

  89.362% {
    transform: translateX(2px);
    opacity: .75;
  }

  100% {
    transform: none;
    opacity: 1;
  }
}

/* 13. Réduction des animations */

@media (prefers-reduced-motion:reduce) {
  *,
  *:before,
  *:after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  .shout {
    opacity: 1;
  }

  .stage-copy-content.is-jittering {
    animation: none;
  }
}
