:root{
  --bg: #0b0f14;
  --card: #121a23;
  --text: #e7eef7;
  --muted: #9bb0c6;

  --red: #ff3b30;
  --orange: #ff9500;

  --radius: 18px;

  /* Responsive dots */
  --dot-size: clamp(28px, 8vw, 56px);
}

*{ box-sizing: border-box; }
html, body{ height: 100%; }

body{
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 700px at 50% 0%, #122033 0%, var(--bg) 60%);
  color: var(--text);
}

/* -------------------------
   Header
------------------------- */

.app-header{
  padding: 26px 16px 42px;
  display:flex;
  justify-content:center;
}

.app-title{
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.92);
}

.title-emoji{
  margin-right: 0.4em;
  font-size: 1.05em;
  transform: translateY(-1px);
}

/* -------------------------
   Main / Card
------------------------- */

.app-main{
  padding: 10px 16px 24px;
  display:flex;
  justify-content:center;
}

.card{
  width: min(580px, 100%);
  overflow: hidden;

  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);

  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 22px;

  padding: clamp(18px, 4vw, 28px) clamp(12px, 2.5vw, 20px);
  display: grid;
  row-gap: clamp(18px, 3.8vw, 34px);

  box-shadow:
    0 30px 90px rgba(0,0,0,0.45),
    0 1px 0 rgba(255,255,255,0.10) inset;
}

/* -------------------------
   Line 1: beat dots
------------------------- */

/* Layout: shrink-wrap the dot row and center it */
.dots{
  display: flex;
  gap: clamp(12px, 3vw, 36px);

  width: max-content;
  max-width: 100%;
  margin-inline: auto;
}

/* Dot colors + glow tint */
.dot{
  --glow: rgba(255,255,255,0.18);

  position: relative;
  isolation: isolate; /* keeps z-index:-1 behind *this* dot only */
  width: var(--dot-size);
  aspect-ratio: 1 / 1;
  flex: 0 0 auto;

  border-radius: 999px;
  opacity: 0.55;
  transform: scale(1);

  transition: transform 110ms ease, opacity 110ms ease;
}

.dot--red{
  background: var(--red);
  --glow: rgba(255, 59, 48, 0.22);
}

.dot--orange{
  background: var(--orange);
  --glow: rgba(255,149, 0, 0.20);
}

/* Mobile-safe glow (no filter/drop-shadow) */
.dot::after{
  content: "";
  position: absolute;
  inset: -6px;                 /* smaller radius */
  border-radius: 999px;
  pointer-events: none;
  z-index: -1;

  background: radial-gradient(
    circle,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0) 55%,
    var(--glow) 65%,
    rgba(255,255,255,0.06) 78%,
    rgba(255,255,255,0) 90%
  );

  opacity: 0;
  transform: scale(0.98);
  transition: opacity 120ms ease;
}

/* Active state */
.dot.is-active{
  opacity: 0.65;               /* not full intensity */
  transform: scale(1.15);
}

.dot.is-active::after{
  opacity: 1;
  transform: scale(1);
}


/* -------------------------
   Line 2: BPM row
------------------------- */

.bpm-row{
  display: grid;
  grid-template-columns: auto max-content auto;
  align-items: center;
  justify-content: center;

  column-gap: clamp(12px, 3.4vw, 24px);
}

.bpm-group{
  display:flex;
  gap: 6px;
}

.bpm-display{
  display: flex;
  justify-content: center;
}

.bpm-value{
  position: relative;
  text-align: center;
  font-weight: 800;
  font-size: clamp(64px, 12vw, 120px);
  line-height: 1;
}

.bpm-unit{
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 1px);

  display: block;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0;
  color: rgba(255,255,255,0.62);
}

/* -------------------------
   BPM controls
------------------------- */

.text-btn{
  height: 40px;
  width: 56px;

  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;

  color: rgba(255,255,255,0.65);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.4px;

  display:flex;
  align-items:center;
  justify-content:center;
  justify-self: center;

  cursor:pointer;
  transition: background 120ms ease, transform 100ms ease, color 120ms ease;
}

.text-btn:hover{
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.85);
}

.text-btn:active{
  transform: scale(0.96);
  background: rgba(255,255,255,0.14);
}

/* -------------------------
   Beats per bar (UI only)
------------------------- */

.beats-row{
  display: grid;
  grid-template-columns: auto max-content auto;
  align-items: center;
  justify-content: center;
  margin-top: -10px;
  margin-bottom: 12px;

  column-gap: clamp(16px, 4vw, 28px);
}

.beats-display{
  display: flex;
  justify-content: center;
}

.beats-value{
  position: relative;
  text-align: center;
  font-weight: 600;
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1;
  color: rgba(255,255,255,0.78);
}

/* Label below number */
.beats-unit{
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 4px);

  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  color: rgba(255,255,255,0.38);
}

/* Slightly smaller buttons for beats */
.text-btn--small{
  width: 44px;
  height: 32px;
  font-size: 16px;
  color: rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.045);
  border-color: rgba(255,255,255,0.06);
}
.text-btn--small:hover{
  color: rgba(255,255,255,0.72);
  background: rgba(255,255,255,0.075);
}

.tap-row{
  display: flex;
  justify-content: center;
  margin-top: 2px;
}

.tap-btn{
  width: clamp(112px, 20vw, 138px);
  height: 36px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 12px;
  touch-action: manipulation;
}

.tap-btn.is-key-pressed{
  transform: scale(0.96);
  background: rgba(255,255,255,0.14);
}

/* Responsive BPM row for small screens */
@media (max-width: 520px){

  .app-main{
    padding: 0 12px 16px;
  }

  .card{
    width: 100%;
    border-radius: 20px;
    box-shadow: 0 18px 60px rgba(0,0,0,0.35);
  }

  .bpm-row{
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas:
      "display display"
      "minus plus";
    justify-content: center;
    align-items: center;

    column-gap: 18px;
    row-gap: 10px; /* much tighter under BPM */
    text-align: center;
  }

  .bpm-display{
    grid-area: display;
    order: 0; /* no need for order hacks anymore */
  }

  /* Target the two groups by position */
  .bpm-row .bpm-group:first-child{
    grid-area: minus;
    justify-content: center;
    justify-self: start;
  }

  .bpm-row .bpm-group:last-child{
    grid-area: plus;
    justify-content: center;
    justify-self: end;
  }

  .bpm-unit{
    position: static;
    transform: none;
    left: auto;
    top: auto;
    margin-top: 4px;  /* controls spacing under the number */
  }

  /* Keep more vertical separation between Tap Tempo and Beats on small screens. */
  .beats-row{
    margin-top: 0;
    margin-bottom: 14px;
  }

  .tap-btn{
    width: min(156px, 54vw);
  }
}

/* -------------------------
   Transport
------------------------- */

.transport{
  display:flex;
  justify-content:center;
  gap: 18px;
}

.transport-btn{
  appearance: none;
  -webkit-appearance: none;

  width: clamp(88px, 14vw, 110px);
  height: clamp(88px, 14vw, 110px);

  display:flex;
  align-items:center;
  justify-content:center;

  background: rgba(255,255,255,0.09);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 16px;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    0 6px 18px rgba(0,0,0,0.2);

  cursor:pointer;
  transition: background 140ms ease, transform 120ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.transport-btn:not([disabled]):hover{
  background: rgba(255,255,255,0.13);
  border-color: rgba(255,255,255,0.24);
}

.transport-btn:not([disabled]):active{
  transform: scale(0.94);
  background: rgba(255,255,255,0.18);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.30);
}

.transport-btn[disabled]{
  opacity: 1;
  cursor: not-allowed;
  background: rgba(255,255,255,0.01);
  border-color: rgba(255,255,255,0.035);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
}

.transport-btn svg{
  width: clamp(48px, 7vw, 60px);
  height: clamp(48px, 7vw, 60px);
  fill: rgba(255,255,255,0.95);
  display:block;
}

.transport-btn[disabled] svg{
  fill: rgba(255,255,255,0.2);
}

.shortcuts-row{
  display: flex;
  justify-content: center;
  margin-top: -2px;
}

.shortcuts-btn{
  width: auto;
  min-width: 120px;
  height: 32px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.shortcuts-overlay{
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(78px, 10vh, 124px) 16px 24px;
}

.shortcuts-overlay[hidden]{
  display: none;
}

.shortcuts-backdrop{
  position: absolute;
  inset: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: rgba(8, 12, 18, 0.68);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.shortcuts-panel{
  position: relative;
  width: min(420px, calc(100vw - 32px));
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(25,33,44,0.96);
  box-shadow: 0 24px 68px rgba(0,0,0,0.52);
  padding: 14px;
}

.shortcuts-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.shortcuts-title{
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
}

.shortcuts-close{
  width: 32px;
  height: 32px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.86);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.shortcuts-list{
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.shortcuts-list li{
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.82);
  font-size: 14px;
}

.shortcuts-list kbd{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 520px){
  .shortcuts-row,
  .shortcuts-overlay{
    display: none;
  }
}
