.activity-page {
  gap: 4px;
}

/* Compact activity controls - one bar that blends into the activity surface */
.activity-chrome {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  padding: 4px 2px 8px;
  margin: 0;
  background: var(--activity-chrome-bg, transparent);
  border: 0;
  border-bottom: 1px solid var(--activity-chrome-edge, transparent);
  box-shadow: none;
  flex: 0 0 auto;
  z-index: 5;
  overflow: visible;
  color: var(--text-primary);
}
.chrome-btn--menu-toggle {
  flex: 0 0 auto;
  min-width: 64px;
  font-weight: 800;
  order: 40;
  margin-left: auto;
}
.chrome-group--audio {
  order: 41;
  margin-left: 0;
}
.activity-chrome #btnFullscreen {
  order: 42;
}
.activity-chrome__body {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}
/* Collapsed: keep Hide/Menu visible; hide the rest */
body.activity-chrome-collapsed .activity-chrome__body {
  display: flex;
}
body.activity-chrome-collapsed .activity-chrome__body > *:not(.chrome-btn--menu-toggle) {
  display: none !important;
}
body.activity-chrome-collapsed .activity-chrome {
  min-height: 0;
  padding-bottom: 4px;
  border-bottom: 0;
}
body.activity-chrome-collapsed .chrome-btn--menu-toggle {
  background: #15294b;
  color: #fff;
  border-color: #15294b;
}

@media (max-width: 700px) {
  .activity-chrome {
    gap: 4px;
    padding: 2px 0 6px;
    flex-wrap: wrap;
    overflow: visible;
  }
  .activity-chrome__body {
    flex: 1 1 100%;
    width: 100%;
    flex-wrap: wrap;
  }
  .activity-chrome .chrome-btn--nav,
  .activity-chrome .chrome-btn--comments {
    font-size: 0.78rem;
    padding: 0 8px;
    min-width: 0;
  }
  .activity-chrome .chrome-btn--signout {
    display: none;
  }
  .activity-chrome .chrome-group[aria-label="Theme"] {
    display: none;
  }
  .chrome-group--pads .chrome-value {
    min-width: 2.5rem;
    font-size: 0.8rem;
  }
  .beat-light--bar {
    flex: 1 1 100%;
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 4px 0 0;
    height: auto;
    order: 30;
  }
  .beat-light--bar .beat-light__label {
    display: none;
  }
  .beat-light--bar .beat-light__box {
    width: min(100%, calc(160px * var(--beat-flash-width, var(--beat-flash-size, 1))));
  }
}

.chrome-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chrome-group--pads {
  margin-left: 2px;
  padding: 2px 6px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--teal-bright, #00beb4) 35%, var(--panel-border));
  background: color-mix(in srgb, var(--teal, #00a99d) 14%, transparent);
}

.chrome-group--flow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  flex-shrink: 0;
}

.chrome-btn.chrome-btn--action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 68px;
  height: 40px;
  padding: 0 12px;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
  line-height: 1.1;
  flex: 0 0 auto;
}

.activity-chrome .chrome-btn--action[hidden] {
  display: none !important;
}

.chrome-btn--setup.is-active,
.chrome-btn--setup[aria-pressed="true"] {
  border-color: var(--teal-bright, #00beb4);
  background: color-mix(in srgb, var(--teal, #00a99d) 22%, var(--input-bg));
  color: var(--text-primary);
}

.chrome-btn--start {
  border-color: var(--teal-bright, #00ddd0);
  background: var(--start-gradient, var(--teal));
  color: #fff;
}

.activity-chrome .chrome-btn--comments {
  border-color: color-mix(in srgb, var(--teal-bright, #00beb4) 55%, var(--panel-border));
  background: color-mix(in srgb, var(--teal, #00a99d) 16%, var(--input-bg, #fff));
  color: var(--text-primary);
  font-weight: 800;
}

.activity-chrome .chrome-btn--comments:hover,
.activity-chrome .chrome-btn--comments:focus-visible {
  border-color: var(--teal-bright, #00beb4);
  background: color-mix(in srgb, var(--teal, #00a99d) 26%, var(--input-bg, #fff));
}

.chrome-btn--setup {
  border-color: var(--panel-border);
  background: var(--input-bg, var(--icon-btn-bg));
  color: var(--text-primary);
}

.chrome-group--audio {
  margin-left: 0;
}

.chrome-value {
  min-width: 3.4em;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-primary);
  user-select: none;
}

.chrome-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--icon-btn-bg, var(--input-bg));
  color: var(--icon-btn-text, var(--text-primary));
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  box-shadow: none;
  flex: 0 0 auto;
  cursor: pointer;
}

.chrome-btn--size {
  width: 44px;
  height: 40px;
  min-width: 44px;
  font-size: 20px;
  border-color: color-mix(in srgb, var(--teal-bright, #00beb4) 40%, var(--panel-border));
  background: color-mix(in srgb, var(--teal, #00a99d) 18%, var(--icon-btn-bg, var(--input-bg)));
}

.chrome-btn--back {
  width: auto;
  min-width: 40px;
  padding: 0 10px;
  font-size: 18px;
}

.activity-chrome .theme-btn > span:not(.icon) {
  display: none;
}

.activity-chrome .theme-btn {
  min-width: 40px;
  width: 40px;
  max-width: 40px;
  flex: 0 0 auto;
  padding: 0;
  letter-spacing: 0;
  text-transform: none;
  font-size: 18px;
  border-radius: 10px;
}

.activity-chrome .theme-btn[aria-pressed="true"],
.activity-chrome .theme-btn.is-active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal-bright);
}

html[data-theme="light"] .chrome-btn {
  background: var(--surface-panel);
  border-color: var(--panel-border);
  color: var(--text-primary);
}

html[data-theme="light"] .chrome-btn--size {
  background: var(--input-bg);
  border-color: var(--edge-strong);
  color: var(--teal-dark);
}

html[data-theme="light"] .activity-chrome {
  border-color: var(--activity-chrome-edge);
}

html[data-theme="light"] .chrome-btn--setup {
  background: var(--surface-selected-orange);
  border-color: var(--orange);
  color: #7a3208;
}

html[data-theme="light"] .activity-ready-hint {
  color: var(--text-secondary);
}

html[data-theme="light"] .activity-chrome .theme-btn[aria-pressed="true"],
html[data-theme="light"] .activity-chrome .theme-btn.is-active {
  background: var(--teal);
  color: #ffffff;
  border-color: var(--teal-dark);
}

.activity-page .app-header {
  display: none;
}

.activity-page .hero {
  display: none;
}

.header-leading {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1 1 auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--icon-btn-bg);
  color: var(--icon-btn-text);
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  flex: 0 0 auto;
}

.activity-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  min-height: 0;
  flex: 1 1 auto;
  height: auto;
  width: 100%;
}

.activity-page.page {
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  max-height: 100vh;
  max-height: 100dvh;
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
  gap: 6px;
  padding-top: calc(var(--safe-top) + 4px);
  padding-bottom: calc(var(--safe-bottom) + 4px);
  padding-left: calc(var(--safe-left, 0px) + 8px);
  padding-right: calc(var(--safe-right, 0px) + 8px);
  background: var(--page-bg);
  color: var(--text-primary);
  box-sizing: border-box;
}

/* True fullscreen / immersive: lock the stage to the viewport; controls must
   not cause the page layout to reflow or shrink. */
html.is-immersive,
html:fullscreen,
html:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: var(--page-bg);
}

body[data-page="activity"].is-immersive,
body[data-page="activity"]:fullscreen,
body[data-page="activity"]:-webkit-full-screen {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body[data-page="activity"] {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text-primary);
}

body[data-page="activity"] .activity-page {
  box-sizing: border-box;
}

body[data-page="activity"] #app {
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100%;
}

#btnFullscreen[aria-pressed="true"] {
  border-color: var(--teal-bright);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--teal-bright) 35%, transparent);
}

.activity-chrome #btnFullscreen {
  margin-left: 2px;
  order: 42;
}

.activity-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
  flex: 1;
}

.activity-pads {
  position: relative;
  display: grid;
  gap: clamp(12px, 2vw, 22px);
  align-items: stretch;
  align-content: center;
  min-height: 0;
  flex: 1;
  padding: clamp(10px, 2vw, 22px);
  border-radius: 24px;
  background: var(--activity-stage-bg);
  border: 1px solid var(--activity-stage-border, transparent);
  box-shadow: var(--shadow-panel);
  color: var(--text-primary);
  /* Square pad size scales with +/-. Width and height stay equal. */
  --pad-size: calc(min(26vmin, 168px) * var(--tile-scale, 1));
}

@media (max-width: 640px) {
  .activity-pads {
    --pad-size: calc(min(28vw, 112px) * var(--tile-scale, 1));
    padding: 8px;
  }
}

/* Free layout: children drag square pads into place. */
.activity-pads.activity-pads--free {
  display: block;
  overflow: hidden;
  touch-action: none;
}

.activity-pads.activity-pads--free .pad-wrap {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--pad-size) * var(--pad-width-scale, 1));
  margin: 0;
  gap: 0;
  z-index: 1;
}

.activity-pads.activity-pads--free .pad {
  width: 100%;
  height: var(--pad-size);
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
}

/* Space pad matches letter pads (square). */
.activity-pads.activity-pads--free .pad-wrap--space .pad {
  aspect-ratio: 1 / 1;
}

.activity-pads.activity-pads--free .pad-label {
  font-size: calc(var(--pad-size) * 0.42);
}

.activity-pads.activity-pads--free .pad-label.is-dark {
  font-size: calc(var(--pad-size) * 0.22);
}

.activity-pads.activity-pads--free.is-arrange .pad-wrap.is-draggable .pad {
  cursor: grab;
}

.activity-pads.activity-pads--free .pad-wrap.is-dragging {
  z-index: 30;
}

.activity-pads.activity-pads--free .pad-wrap.is-dragging .pad {
  cursor: grabbing;
  transform: scale(1.04);
  box-shadow:
    inset 0 -18px 40px rgba(0, 0, 0, 0.22),
    inset 0 0 0 3px #fff,
    0 12px 28px rgba(0, 0, 0, 0.35);
}

.activity-pads.activity-pads--free .pad-wrap.is-overlap .pad {
  box-shadow:
    inset 0 -18px 40px rgba(0, 0, 0, 0.22),
    inset 0 0 0 3px #ffb514,
    0 0 0 3px rgba(255, 181, 20, 0.45);
}

.activity-mode-label {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

.activity-ready-btn {
  min-height: 48px;
  min-width: 148px;
  padding: 0 28px;
  border-radius: 14px;
  border: 2px solid var(--teal-bright, #00ddd0);
  background: var(--start-gradient, var(--teal));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: var(--shadow-button);
}

.activity-ready-btn:hover {
  filter: brightness(1.05);
}

.activity-ready-hint {
  margin: 0;
  max-width: 36rem;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text-secondary);
}

.activity-chrome .chrome-btn--setup {
  width: auto;
  height: auto;
  min-width: auto;
  min-height: 40px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

/* Full activity surface follows the selected theme (chrome + stage together). */
html[data-theme="dark"] {
  --activity-chrome-bg: transparent;
  --activity-chrome-edge: rgba(121, 166, 196, 0.12);
  --activity-stage-bg: #061827;
  --activity-stage-border: rgba(121, 166, 196, 0.18);
}

html[data-theme="light"] {
  --activity-chrome-bg: transparent;
  --activity-chrome-edge: rgba(6, 33, 58, 0.12);
  --activity-stage-bg: var(--surface-panel);
  --activity-stage-border: var(--input-border);
}

html[data-theme="light"] .activity-pads {
  box-shadow: var(--shadow-panel);
  background: #ffffff;
  border-color: var(--border);
}

html[data-theme="light"] .activity-ready-bar {
  background: linear-gradient(180deg, var(--accent-teal-wash) 0%, transparent 100%);
  border-radius: 16px;
  padding-top: 8px;
}

html[data-theme="light"] .activity-mode-label {
  color: var(--blue-pad);
}

html[data-theme="light"] .chrome-group--pads {
  background: linear-gradient(180deg, var(--accent-teal-wash) 0%, var(--chrome-pad-group-bg) 100%);
  border-color: var(--teal);
  box-shadow: 0 0 12px var(--glow-teal);
}

.activity-pads .pad .pad-label {
  position: relative;
  z-index: 3;
}

.activity-pads .finger-label {
  color: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .activity-pads .finger-label {
  color: var(--finger-label, #465f70);
}

.settings-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 60;
  width: min(420px, 92vw);
  max-height: min(82vh, 560px);
  padding: 0;
  overflow: visible;
  background: transparent;
}

.settings-modal[hidden] {
  display: none !important;
}

.settings-dialog {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px 22px;
  border-radius: 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-panel), 0 24px 60px rgba(0, 0, 0, 0.35);
}

.settings-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-dialog-head .panel-title {
  margin: 0;
}

.settings-dialog .select-trigger {
  min-height: 52px;
}

.side-actions {
  display: grid;
  gap: 10px;
}

.side-actions button {
  min-height: 48px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-weight: 700;
}

.side-actions .primary {
  background: var(--start-gradient);
  border: 0;
  color: #fff;
  box-shadow: var(--shadow-button);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 50;
}

html[data-theme="light"] .drawer-backdrop {
  background: rgba(9, 42, 69, 0.35);
}

.drawer-backdrop[hidden] {
  display: none !important;
}

/* ---------- Controls (compact for phone landscape) ---------- */
.ctrl-btn {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  flex: 0 0 auto;
}

.ctrl-btn--compact {
  min-height: 40px;
  padding: 0 10px;
}

.ctrl-btn.ctrl-play {
  background: var(--start-gradient);
  border: 0;
  color: #fff;
  box-shadow: var(--shadow-button);
  min-width: 132px;
}

.tile-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--input-bg);
  flex: 0 0 auto;
}

.ctrl-label {
  font-weight: 700;
  color: var(--text-secondary);
}

.step-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--icon-btn-bg);
  color: var(--icon-btn-text);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-soft);
  flex: 0 0 auto;
}

.stepper-value {
  min-width: 44px;
  text-align: center;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  line-height: 1;
}

.stepper-value #sizeValue {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stepper-unit {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Keep the Beat Going: prompt to press keys when song is stopped */
.keep-press-prompt {
  position: fixed;
  left: 50%;
  bottom: 12%;
  top: auto;
  transform: translateX(-50%);
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.keep-press-prompt.is-visible {
  opacity: 1;
  visibility: visible;
}

.keep-press-prompt-inner {
  text-align: center;
  padding: 12px 22px;
  border-radius: 16px;
  background: rgba(6, 24, 39, 0.82);
  border: 1px solid rgba(0, 221, 208, 0.45);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  animation: keepPromptPulse 1.4s ease-in-out infinite;
}

.keep-press-title {
  margin: 0;
  font-size: clamp(1.15rem, 3.2vw, 1.55rem);
  font-weight: 800;
  color: #fff;
}

.keep-press-sub {
  margin: 4px 0 0;
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 600;
  color: rgba(200, 235, 245, 0.88);
}

@keyframes keepPromptPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  .keep-press-prompt-inner {
    animation: none;
  }
}

/* ---------- Rotate to landscape hint (only after Start Playing) ---------- */
.rotate-hint {
  display: none;
}

@media (orientation: portrait) {
  body[data-page="activity"].is-activity-playing .rotate-hint {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: grid;
    place-items: center;
    background: var(--page-bg);
    text-align: center;
  }

  body[data-page="activity"].is-activity-playing .rotate-hint-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    color: var(--text-primary);
    padding: 24px;
  }

  .rotate-icon {
    font-size: clamp(64px, 22vw, 120px);
    animation: rotateNudge 1.8s ease-in-out infinite;
  }

  .rotate-hint-inner p {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    font-weight: 700;
    margin: 0;
  }
}

@keyframes rotateNudge {
  0%, 100% { transform: rotate(-12deg); }
  50% { transform: rotate(78deg); }
}
