:root {
  --ink: #e8e2ff;
  --dim: #6d6690;
  --hot: #ff4fd8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #05030c;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, "Courier New", monospace;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  cursor: crosshair;
  /* タップで文字が選択されると入店・打鍵の邪魔になる（モバイルで実際に発生） */
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ---- HUD ---- */

.hud {
  position: fixed;
  z-index: 10;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
  /* 床がキックで明るく光る瞬間に文字が埋もれるため、暗い影で縁取って可読性を保つ */
  text-shadow:
    0 0 8px rgba(255, 79, 216, .35),
    0 1px 2px rgba(0, 0, 0, .95),
    0 0 5px rgba(0, 0, 0, .85);
  user-select: none;
  pointer-events: none;
  transition: opacity .6s;
}

.hud-tl { top: max(14px, env(safe-area-inset-top)); left: 14px; }
.hud-tr { top: max(14px, env(safe-area-inset-top)); right: 14px; }
.hud-bl { bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; }
.hud-br {
  bottom: max(14px, env(safe-area-inset-bottom));
  right: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

#sign { color: var(--ink); font-size: 12px; }

#debug {
  top: max(40px, calc(env(safe-area-inset-top) + 26px));
  left: 14px;
  right: 14px;
  bottom: auto;
  margin: 0;
  padding: 10px 12px;
  background: rgba(5, 3, 12, .78);
  border: 1px solid rgba(255, 79, 216, .4);
  border-radius: 3px;
  color: #b8ffcf;
  font-size: 10px;
  line-height: 1.6;
  white-space: pre;
  max-width: 420px;
  pointer-events: none;
}

#booth-main {
  color: var(--ink);
  animation: booth-pulse 3.2s ease-in-out infinite;
}

#booth-sub {
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: .1em;
  color: var(--hot);
  opacity: .8;
}

@keyframes booth-pulse {
  0%, 100% { opacity: .45; }
  50%      { opacity: .95; }
}

#mixer button {
  background: none;
  border: 1px solid currentColor;
  color: var(--dim);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

#mixer button[aria-pressed="true"] { opacity: .35; }

#vol {
  width: 72px;
  accent-color: var(--hot);
  cursor: pointer;
}

/* ---- フロア上の操作。全面を覆う入店画面は設けない ---- */
#brand { top: 54px; left: 50%; transform: translateX(-50%); text-align: center; }
#brand h1 { margin: 0; font-size: clamp(19px, 4vw, 28px); letter-spacing: .25em; color: var(--ink); }
#brand span { display: block; margin-top: 5px; font-size: 9px; color: var(--hot); letter-spacing: .4em; }
#controls { position: fixed; z-index: 20; left: 50%; bottom: max(58px, calc(env(safe-area-inset-bottom) + 48px)); transform: translateX(-50%); text-align: center; width: min(94vw, 460px); }
.control-buttons { display: flex; justify-content: center; gap: 10px; }
#controls button, .loop-tools button, #note, #steps button {
  font: inherit; color: var(--ink); border: 1px solid #69517f; border-radius: 3px;
  background: rgba(10, 5, 20, .9); cursor: pointer;
}
#controls button { padding: 10px 18px; font-size: 12px; min-height: 42px; }
#controls button[aria-pressed="true"] { border-color: var(--hot); }
button:focus-visible, summary:focus-visible, select:focus-visible { outline: 2px solid var(--hot); outline-offset: 3px; }
button:disabled { opacity: .5; cursor: wait; }
#admission, #room-status { margin: 7px 0 0; font-size: 10px; line-height: 1.5; color: var(--ink); text-shadow: 0 1px 5px #000; }
#room-status { color: #c7a4cb; min-height: 15px; }
#loop-panel { position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: max(190px, calc(env(safe-area-inset-bottom) + 180px)); width: min(94vw, 460px); padding: 12px; background: rgba(5, 3, 12, .92); border: 1px solid #503456; border-radius: 4px; }
#loop-panel[hidden] { display: none; }
#loop-panel summary { cursor: pointer; font-size: 12px; padding: 2px; }
.loop-tools { display: flex; align-items: center; gap: 8px; margin: 14px 0 10px; }
.loop-tools button, #note { min-height: 32px; padding: 4px 8px; font-size: 10px; }
.loop-tools button[aria-pressed="true"] { border-color: var(--hot); color: var(--hot); }
#note-label { margin-left: auto; font-size: 10px; }
#steps { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; }
#steps button { padding: 0; min-width: 0; height: 34px; font-size: 9px; }
#steps button[aria-pressed="true"] { background: #66365f; border-color: var(--hot); }
#steps button.playing { outline: 2px solid #e8e2ff; outline-offset: -2px; }
#loop-status { margin: 10px 0 0; font-size: 10px; line-height: 1.5; color: #c7a4cb; }
@media (max-width: 600px) {
  .hud-tr { top: 34px; font-size: 9px; }
  #sign { font-size: 10px; }
  #brand { top: 62px; }
  #steps { grid-template-columns: repeat(8, 1fr); }
  #steps button { height: 36px; }
  #booth-main { font-size: 9px; }
  #booth-sub { font-size: 8px; }
  .loop-tools { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) { #booth-main { animation: none; } }

#history-panel { position:fixed; z-index:12; top:80px; left:20px; width:min(90vw,380px); color:#d0bedb; font:11px/1.6 monospace; background:rgba(12,5,22,.92); border:1px solid #684477; padding:10px 12px; max-height:40vh; overflow:auto; }
#history-panel summary { cursor:pointer; letter-spacing:.12em; }
#history-panel p { margin:8px 0; }
#history-panel ol { list-style:none; padding:0; margin:10px 0; }
#history-panel li { display:flex; align-items:center; justify-content:space-between; gap:8px; border-top:1px solid #35203f; padding:7px 0; }
#history-panel button { color:#f3d3ff; background:#271331; border:1px solid #80518d; padding:5px 8px; cursor:pointer; font:inherit; white-space:nowrap; }
.history-note { color:#a090ac; font-size:10px; }
@media(max-width:600px) { #history-panel { top:110px; left:12px; padding:7px 10px; max-height:32vh; } }
