:root {
  --ink: #fff4de;
  --ink-dim: #d7c09a;
  --gold: #f0c56a;
  --gold-deep: #b8862b;
  --wood: #3a1a12;
  --night: #0a0608;
  --panel-pad: 28px;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  background: var(--night);
  color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Mincho ProN", serif;
  user-select: none;
  -webkit-user-select: none;
}

body {
  overflow-x: hidden;
}

#stage {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 20px 28px;
}

.bg {
  position: fixed;
  inset: 0;
  background:
    url("../assets/bg/stage.jpg") center 40% / cover no-repeat;
  filter: saturate(1.12) contrast(1.08) brightness(1.18);
  z-index: -3;
}

.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(255, 190, 90, 0.16), transparent 48%),
    linear-gradient(180deg, rgba(6, 3, 4, 0.18) 0%, rgba(6, 3, 4, 0.42) 72%, rgba(6, 3, 4, 0.62) 100%);
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  box-shadow: inset 0 0 120px 16px rgba(0, 0, 0, 0.4);
}

body.on-beat .bg::after {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 196, 90, 0.24), transparent 52%),
    linear-gradient(180deg, rgba(6, 3, 4, 0.12) 0%, rgba(6, 3, 4, 0.38) 100%);
}

body.accent-beat .bg::after {
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 214, 120, 0.32), transparent 54%),
    linear-gradient(180deg, rgba(6, 3, 4, 0.08) 0%, rgba(6, 3, 4, 0.36) 100%);
}

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

.back {
  color: var(--gold);
  text-decoration: none;
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-family: "Cormorant Garamond", serif;
}

.brand {
  text-align: center;
}

.brand .en {
  font-family: "Cinzel", "Cormorant Garamond", serif;
  letter-spacing: 0.42em;
  font-size: 0.72rem;
  color: var(--gold);
}

.brand h1 {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  letter-spacing: 0.18em;
  background: linear-gradient(180deg, #fff1c4 0%, #e0ae4a 55%, #8a5a18 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-dim);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 460px);
  gap: 18px;
  align-items: stretch;
  min-height: 0;
}

.viz-wrap {
  position: relative;
  min-height: 520px;
  border-radius: 8px;
}

.viz-wrap::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 42%;
  width: 55%;
  height: 70%;
  transform: translate(-50%, -50%);
  background: radial-gradient(ellipse at center, rgba(255, 176, 70, 0.18), transparent 68%);
  pointer-events: none;
}

#viz {
  display: block;
  width: 100%;
  height: 100%;
}

.console {
  background: url("../assets/ui/panel.png") center / 100% 100% no-repeat;
  padding: 54px 48px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.45));
}

.bpm-block {
  text-align: center;
}

.bpm-label {
  font-family: "Cinzel", serif;
  letter-spacing: 0.32em;
  font-size: 0.7rem;
  color: var(--gold);
}

#bpm {
  font-family: "Cinzel", serif;
  font-size: clamp(4.4rem, 9vw, 6.4rem);
  line-height: 0.9;
  background: linear-gradient(180deg, #fff6d2, #f0c56a 60%, #a56b1c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(240, 197, 106, 0.15);
}

.bpm-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, #5a2d14, #d4a24a);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3c6, #c7922a);
  border: 1px solid #7a4e14;
  box-shadow: 0 0 10px rgba(240, 197, 106, 0.55);
  cursor: pointer;
}

.nudge {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(212, 168, 74, 0.45);
  background: rgba(20, 8, 6, 0.45);
  color: var(--gold);
  font-size: 1.2rem;
  border-radius: 50%;
  cursor: pointer;
}

.wood-btn {
  position: relative;
  border: 0;
  background: url("../assets/ui/button.png") center / 100% 100% no-repeat;
  color: #fff4de;
  font-family: "Cinzel", "Noto Sans JP", serif;
  letter-spacing: 0.14em;
  min-height: 58px;
  padding: 0 16px;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.wood-btn:hover {
  filter: brightness(1.08);
}

.wood-btn:active,
.wood-btn.playing {
  filter: brightness(0.86) saturate(1.1);
  transform: translateY(1px);
}

.play-row,
.sound-row,
.save-row {
  display: grid;
  gap: 10px;
}

.play-row {
  grid-template-columns: 1.4fr 1fr;
}

.sound-row {
  grid-template-columns: 1fr 1fr;
}

.save-row {
  grid-template-columns: 1fr auto;
}

.sound-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 72px;
  border: 1px solid rgba(212, 168, 74, 0.28);
  background: rgba(18, 8, 6, 0.42);
  color: var(--ink-dim);
  border-radius: 12px;
  cursor: pointer;
  font-family: "Noto Sans JP", sans-serif;
}

.sound-btn img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
}

.sound-btn.active {
  border-color: var(--gold);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgba(240, 197, 106, 0.35), inset 0 0 24px rgba(240, 197, 106, 0.12);
}

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

.field label,
.tiny {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--gold);
  font-family: "Cinzel", serif;
}

select,
#preset-name {
  background: rgba(12, 6, 5, 0.55);
  border: 1px solid rgba(212, 168, 74, 0.35);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 0.95rem;
}

.presets {
  margin-top: 18px;
}

.presets-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.presets-head h2 {
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  letter-spacing: 0.22em;
  color: var(--gold);
}

#selected-label {
  color: var(--ink-dim);
  font-size: 0.8rem;
}

.slots {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.slot {
  text-align: left;
  border: 1px solid rgba(212, 168, 74, 0.28);
  background:
    linear-gradient(180deg, rgba(62, 28, 16, 0.72), rgba(18, 8, 6, 0.78));
  color: inherit;
  border-radius: 12px;
  padding: 12px 12px 10px;
  cursor: pointer;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slot:hover {
  border-color: rgba(240, 197, 106, 0.55);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.slot.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(240, 197, 106, 0.4), 0 0 22px rgba(240, 197, 106, 0.18);
}

.slot-index {
  font-family: "Cinzel", serif;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  color: var(--gold);
}

.slot-name {
  font-weight: 700;
  font-size: 0.98rem;
}

.slot-meta {
  color: var(--ink-dim);
  font-size: 0.74rem;
}

.save-bar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 16px);
  background: rgba(20, 10, 8, 0.88);
  border: 1px solid rgba(240, 197, 106, 0.4);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 20;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hint {
  color: rgba(215, 192, 154, 0.7);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

@media (max-width: 980px) {
  .main {
    grid-template-columns: 1fr;
  }

  .viz-wrap {
    min-height: 380px;
  }

  .slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .console {
    padding: 42px 28px 28px;
  }

  .save-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  header.top {
    flex-wrap: wrap;
  }

  #stage {
    padding: 12px 12px 24px;
  }

  .viz-wrap {
    min-height: 320px;
  }
}
