html,
body {
  margin: 0;
  height: 100%;
  background: #f4f1ea;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

#pigment-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none; /* deliver raw pointer drags instead of scrolling */
}

.controls {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 14px;
  box-sizing: border-box;
  pointer-events: none; /* let drags pass through the bar to the canvas */
  transition: opacity 320ms ease, visibility 320ms ease;
}

/* Game-only controls: present in the game, faded away in the tutorial, which
   keeps just sound, marks, and exit. */
.only-game {
  transition: opacity 320ms ease, visibility 320ms ease;
}

.in-tutorial .only-game {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.controls-top {
  top: calc(14px + env(safe-area-inset-top, 0px));
  justify-content: space-between;
}

.controls-bottom {
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  justify-content: space-between;
}

.group {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.chip {
  pointer-events: auto;
  border: none;
  border-radius: 11px;
  padding: 9px 15px;
  font: 600 14px system-ui, sans-serif;
  color: rgba(49, 51, 49, 0.7);
  background: rgba(49, 51, 49, 0.08);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease;
}

.chip-active {
  color: #f4f1ea;
  background: rgba(49, 51, 49, 0.82);
}

/* Nothing to act on (no move to undo, or busy): dim and inert. */
.chip-disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* The boot screen, shown until the first frame draws, then faded away. */
#splash {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f4f1ea;
  transition: opacity 400ms ease, visibility 400ms ease;
}

#splash.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-mark {
  animation: splash-pulse 1.6s ease-in-out infinite;
}

@keyframes splash-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* Dark mode follows the system; the canvas matches it in app.js. */
@media (prefers-color-scheme: dark) {
  html,
  body {
    background: #161718;
  }

  #splash {
    background: #161718;
  }

  .chip {
    color: rgba(228, 226, 220, 0.72);
    background: rgba(228, 226, 220, 0.1);
  }

  .chip-active {
    color: #161718;
    background: rgba(228, 226, 220, 0.85);
  }
}

/* Tighten the bars so they never crowd on a narrow phone. */
@media (max-width: 520px) {
  .controls {
    gap: 7px;
    padding: 0 10px;
  }

  .group {
    gap: 7px;
  }

  .chip {
    padding: 8px 11px;
    font-size: 13px;
    border-radius: 10px;
  }

  /* Too many bottom chips for one narrow row: wrap to two, centred, within
     the band the layout already reserves for this bar. */
  .controls-bottom {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-mark {
    animation: none;
  }

  .controls {
    transition: none;
  }
}
