:root {
  --bg: #ffffff;
  --fg: #141312;
  --muted: #6b6560;
  --accent: #e0407a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161318;
    --fg: #f2eee9;
    --muted: #9a938c;
    --accent: #ff6ea0;
  }
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent);
}

.shell {
  max-width: 48rem;
  margin: 0 auto;
  padding: 4rem 1rem;
}

.muted {
  color: var(--muted);
}

/* The app's one canvas (`web::screen`), parked here between the screens
   that hold it; shown behind the page for the 2D pass, which then lets
   it through the page's own background. */
#ddi-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

#ddi-screen.shown {
  display: block;
}

.screen-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

html.screen-backdrop,
html.screen-backdrop body {
  background: transparent;
}

.ui-test-dom {
  position: fixed;
  left: 24px;
  bottom: 8px;
  margin: 0;
  color: #f2eee9;
  font-size: 0.85rem;
}

.game-canvas-host {
  position: fixed;
  inset: 0;
  background: #050308;
  /* Fingers on the play screen are lane presses: no text selection, no
     long-press menu, no tap flash. */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* During play, no scrolling, pinch or double-tap zoom anywhere on the
   screen (the quit button is double-tapped). The overlays before and after
   keep normal touch behaviour. */
.game-canvas-host.playing {
  touch-action: none;
}

/* Where the play screen puts the app's canvas. */
.game-canvas-slot {
  position: absolute;
  inset: 0;
}

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: ui-monospace, monospace;
}

.canvas-overlay.error {
  color: #ff8aa8;
}

.canvas-badge {
  position: absolute;
  right: 0.75rem;
  bottom: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}

.back-link {
  position: absolute;
  left: 0.75rem;
  top: 0.5rem;
  color: #fff;
  text-decoration: none;
  opacity: 0.7;
}

.diff-beginner { background: #3a8ddb; }
.diff-easy { background: #3aa65a; }
.diff-medium { background: #c99a1e; }
.diff-hard { background: #d1483a; }
.diff-challenge { background: #8b4fc9; }
.diff-edit { background: #666; }

.error {
  color: #d1483a;
}

.results {
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  /* A phone in landscape is shorter than the card: scroll, don't clip. */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0.5rem 0;
}

.results-card {
  background: #1a1620;
  padding: 1.5rem 2rem;
  border-radius: 16px;
  min-width: 280px;
  max-width: min(34rem, 90vw);
  text-align: center;
}

.results-grade {
  font-size: 3rem;
  font-weight: 800;
}

.results-score {
  font-size: 1.6rem;
  font-weight: 700;
}

.results-fc {
  color: #ffd166;
  font-weight: 700;
  margin: 0.5rem 0;
}

.results-table {
  margin: 1rem auto;
  border-collapse: collapse;
  text-align: left;
}

.results-table td {
  padding: 0.1rem 0.6rem;
}

.results-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
}

.results-actions button {
  font: inherit;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.results-actions a {
  color: #fff;
}

.cal-track {
  position: relative;
  height: 48px;
  margin: 0.75rem 0;
  border: 1px solid color-mix(in srgb, var(--fg) 20%, transparent);
  border-radius: 8px;
  overflow: hidden;
}

.cal-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--accent);
}

.cal-marker {
  position: absolute;
  left: 0;
  top: 8px;
  width: 100%;
  height: 32px;
  pointer-events: none;
}

.cal-marker::after {
  content: "";
  position: absolute;
  left: calc(50% - 8px);
  width: 16px;
  height: 32px;
  border-radius: 4px;
  background: var(--fg);
}

.cal-status {
  font-family: ui-monospace, monospace;
}

/* Used by the generated seo-body fragment. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.boot-noscript {
  padding: 2rem;
  font-family: ui-monospace, monospace;
}

.debug-hud {
  position: absolute;
  left: 0.75rem;
  bottom: 0.5rem;
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  pointer-events: none;
}

a.button,
label.button,
button.button {
  display: inline-block;
  border: none;
  font: inherit;
  padding: 0.35rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.cal-verdict {
  margin: 0.75rem auto;
}

.device-line {
  font-size: 0.8rem;
}

/* #/video-check */
.video-check-table td {
  vertical-align: top;
}

.video-check-frame canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* A file's frames from each decoder, side by side. */
.video-check-pair {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.video-check-pair .video-check-frame {
  flex: 1 1 18rem;
  margin: 0;
}

/* A noteskin's elements alone (`#/skin-preview`), at their pixels. */
.skin-preview {
  padding: 16px;
}

.skin-preview canvas {
  display: block;
}

.skin-preview-status {
  color: var(--muted, #aaa);
  font-size: 0.85rem;
}

/* The UI core's developer screen (`components::ui_dev`): the canvas over
   the visible area, a hidden textarea at the caret, a hidden file input. */
.ui-dev {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0c0c12;
}

.ui-dev-frame {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.ui-dev-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
}

.ui-dev-input {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  pointer-events: none;
}

.ui-dev-files {
  position: fixed;
  left: -1000px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* Song select (`components::select_page`): the theme's screen on the
   canvas over the whole window (the `.ui-dev-*` rules place it); the
   import's real inputs kept out of sight, the drop note over it all. */
.select-page {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0a090d;
}

.select-page .import-panel {
  position: fixed;
  left: -1000px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

/* Elements the shell hides (`hidden`) stay hidden whatever else sets
   their display. */
[hidden] {
  display: none !important;
}

.select-page .drop-note {
  position: fixed;
  inset: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #ff6ea0;
  border-radius: 12px;
  background: rgba(10, 9, 13, 0.7);
  color: #f2eee9;
  font-size: 1.25rem;
  pointer-events: none;
  z-index: 10;
}

.select-page .select-error {
  position: fixed;
  left: 1rem;
  top: 1rem;
  z-index: 10;
}
