@import url("https://fonts.googleapis.com/css2?family=Familjen+Grotesk:wght@400;500&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20,400,1,0");

.material-symbols-outlined {
  font-size: 18px;
  line-height: 1;
  user-select: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.spin {
  display: inline-block;
  animation: spin 1s linear infinite;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #000;
  --surface: #111111;
  --border: #202020;
  --button: #333;
  --text: #cccccc;
  --dim: #888;
  --accent: #888888;
  --warm: #aaaaaa;
  overscroll-behavior: none;
}

html {
  font-size: 18px;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Familjen Grotesk", sans-serif;
  /* overflow: hidden; */
}

/* ── Stage ─────────────────────────────────────────────────────────────────── */

#app {
  width: 100vw;
  height: 100vh;
  position: relative;
}

#stage {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px;
}

canvas {
  display: block;
}

#output-canvas {
  display: none;
}

#upload-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#upload-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#upload-btn {
  width: 100%;
  background: none;
  border: none;
  background-color: var(--button);
  border-radius: 4px;
  color: var(--text);
  font-family: "Familjen Grotesk", sans-serif;
  font-size: 0.75rem;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    border-color 0.2s,
    color 0.2s;
}

#upload-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#file-input {
  display: none;
}

#upload-options {
  display: flex;
  gap: 16px;
  margin-top: 1.5rem;
  justify-content: center;
}

.upload-option-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.upload-option-label {
  font-size: 0.65rem;
  color: var(--dim);
  text-align: center;
}

.select-label {
  font-size: 0.75rem;
  margin-top: 2rem;
  text-align: center;
  color: var(--dim);
}

#presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}

h1 {
  font-size: 0.8rem;
  color: var(--dim);
  text-align: center;
  margin-bottom: 2rem;
  font-weight: normal;
  span {
    color: var(--text);
  }
}

.preset-btn {
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-family: "Familjen Grotesk", sans-serif;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  transition: background 0.2s;
}

.preset-btn:hover {
  background: var(--button);
}

.preset-btn img {
  display: block;
  width: 120px;
  height: 120px;
  object-fit: contain;
  object-position: bottom;
}

.preset-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 4px;
  font-size: 0.6rem;
  color: var(--text);
  line-height: 1.2;
  text-align: center;
}

.preset-label em {
  font-style: normal;
  color: var(--dim);
}

#art-btn {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 50;
  background: var(--button);
  border: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  width: 32px;
  height: 32px;
  border-radius: 4px;
}

#art-btn:hover {
  background: #fff;
  color: #000;
}

/* ── Replay button ─────────────────────────────────────────────────────────── */

#replay-btn {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--button);
  border: none;
  color: var(--text);
  font-size: 0.75rem;
  font-family: "Familjen Grotesk", sans-serif;
  padding: 10px 20px;
  border-radius: 4px;
  font-size: 14px;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

#replay-btn:hover {
  background: #fff;
  color: #000;
}

/* ── Credits ───────────────────────────────────────────────────────────────── */

#credits {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

#credits-btn {
  background: var(--button);
  border: none;
  color: var(--dim);
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

#credits-btn:hover {
  background: #fff;
  color: #000;
}

#credits-btn.open {
  background: #fff;
  color: #000;
}

#credits-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#credits-body p {
  font-size: 0.65rem;
  color: var(--dim);
  line-height: 1.4;
}

#credits-body a {
  color: var(--text);
  text-decoration: none;
}

#credits-body a:hover {
  text-decoration: underline;
}

/* ── Logo ──────────────────────────────────────────────────────────────────── */

#logo {
  position: fixed;
  left: 16px;
  padding: 2px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
}

/* ── Close button ──────────────────────────────────────────────────────────── */

#close-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  background: var(--button);
  border: none;
  color: var(--dim);
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.15s;
}

#close-btn:hover {
  background: #fff;
  color: #000;
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */

#panel {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

#panel-header {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

#play-btn {
  position: fixed;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  background: var(--button);
  border: none;
  color: var(--dim);
  width: 32px;
  height: 32px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}

#play-btn:hover {
  background: #fff;
  color: #000;
}
#play-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
#play-btn.playing {
  color: var(--warm);
}
#play-btn.playing:hover {
  background: #fff;
  color: #000;
}

#panel-header button {
  background: var(--button);
  border: none;
  color: var(--dim);
  width: 32px;
  border-radius: 4px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

#panel-header button:hover {
  background: #fff;
  color: #000;
}
#panel-toggle.open {
  border-color: var(--accent);
  color: var(--accent);
}

#panel-body {
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px;
  width: 15rem;
  border-radius: 4px;
}

/* ── Panel contents ────────────────────────────────────────────────────────── */

#img-thumb-wrap {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  cursor: pointer;
  overflow: hidden;
}
#img-thumb-wrap.visible {
  display: block;
}
#img-thumb-wrap:hover {
  border-color: var(--accent);
}

#img-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: opacity 0.2s;
}
#img-thumb-wrap:hover #img-thumb {
  opacity: 1;
}

#img-thumb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  transition:
    background 0.2s,
    opacity 0.2s;
}
#img-thumb-wrap:hover #img-thumb-overlay {
  background: rgba(0, 0, 0, 0.5);
  opacity: 1;
}

.panel-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.toggle-label {
  font-size: 0.7rem;
  color: var(--dim);
  flex-shrink: 0;
}

.mode-toggle {
  display: flex;
  border: 1px solid var(--border);
  overflow: hidden;
  border-radius: 2px;
}

.mode-toggle button {
  background: none;
  border: none;
  color: var(--dim);
  font-family: "Familjen Grotesk", sans-serif;
  font-size: 0.7rem;
  padding: 3px 8px;
  cursor: pointer;
  width: 100%;
  transition:
    background 0.15s,
    color 0.15s;
  white-space: nowrap;
  text-align: center;
}

.mode-toggle button:not(:last-child) {
  border-right: 1px solid var(--border);
}

.mode-toggle button.active {
  background: var(--border);
  color: var(--accent);
}

.slider-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.slider-field label {
  display: flex;
  gap: 6px;
  align-items: baseline;
  font-size: 0.7rem;
  color: var(--dim);
}

.slider-field label span {
  color: var(--accent);
}

.slider-field input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 1px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.select-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.select-field label {
  font-size: 0.7rem;
  color: var(--dim);
}

.blend-bar {
  display: flex;
  height: 2px;
  gap: 1px;
  margin-top: 2px;
}

.blend-seg {
  height: 100%;
  background: var(--accent);
  width: 50%;
  transition: width 0.8s ease;
  min-width: 0;
}

.blend-names {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.blend-names span {
  font-size: 0.6rem;
  color: var(--dim);
}

/* ── Instrument colors ─────────────────────────────────────────────────────── */

/* Melody: Piano | Harp */
#melody-blend .blend-seg:nth-child(1) {
  background: #d4c4a8;
}
#melody-blend .blend-seg:nth-child(2) {
  background: #a8c890;
}
#melody-names span:nth-child(1) {
  color: #d4c4a8;
}
#melody-names span:nth-child(2) {
  color: #a8c890;
}

/* Bass: Cello | Piano */
#bass-blend .blend-seg:nth-child(1) {
  background: #c08858;
}
#bass-blend .blend-seg:nth-child(2) {
  background: #d4c4a8;
}
#bass-names span:nth-child(1) {
  color: #c08858;
}
#bass-names span:nth-child(2) {
  color: #d4c4a8;
}

/* Pad: Horn | Rhodes */
#pad-blend .blend-seg:nth-child(1) {
  background: #b89040;
}
#pad-blend .blend-seg:nth-child(2) {
  background: #60b8b0;
}
#pad-names span:nth-child(1) {
  color: #b89040;
}
#pad-names span:nth-child(2) {
  color: #60b8b0;
}

#phase-progress {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#phase-track {
  height: 2px;
  background: var(--border);
  position: relative;
  overflow: hidden;
}

#phase-bar {
  position: absolute;
  inset: 0;
  right: auto;
  width: 0%;
  background: var(--accent);
  transition: width 2s linear;
}

#phase-label {
  font-size: 0.65rem;
  color: var(--dim);
  text-align: right;
  min-height: 0.85rem;
  transition: color 1s;
}
