:root {
  --green: #3bf14d;
  --panel-bg: rgba(6, 14, 8, 0.92);
  --border: rgba(59, 241, 77, 0.35);
  --fg: #cfefd3;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
#matrix-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0;
}

/* マ button — top-left */
#ma-btn {
  position: fixed; top: 14px; left: 14px; z-index: 20;
  width: 44px; height: 44px; border-radius: 10px;
  background: rgba(6, 14, 8, 0.7); color: var(--green);
  border: 1px solid var(--border);
  font: 700 22px/1 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'MS Gothic', sans-serif;
  cursor: pointer; backdrop-filter: blur(6px);
  transition: box-shadow .15s, transform .1s, background .15s;
}
#ma-btn:hover { box-shadow: 0 0 14px rgba(59, 241, 77, 0.5); }
#ma-btn:active { transform: scale(0.94); }
#ma-btn.active { background: rgba(59, 241, 77, 0.18); box-shadow: 0 0 16px rgba(59, 241, 77, 0.6); }

/* Settings panel — hidden until the マ button opens it */
#panel {
  position: fixed; top: 68px; left: 14px; z-index: 15;
  width: min(420px, calc(100vw - 28px));
  max-height: calc(100vh - 84px); overflow-y: auto;
  background: var(--panel-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px; backdrop-filter: blur(10px);
  font-family: 'Fira Code', ui-monospace, 'Courier New', monospace;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity .16s, transform .16s;
}
#panel.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
#panel h1 { margin: 0 0 12px; font-size: 15px; color: var(--green); letter-spacing: 1px; }

.row { display: flex; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.grp { display: flex; flex-direction: column; gap: 4px; }
.grp.grow { flex: 1 1 0; min-width: 90px; }
label { font-size: 12px; opacity: 0.85; display: flex; justify-content: space-between; gap: 6px; align-items: baseline; }
.val { opacity: 0.9; font-weight: 600; font-variant-numeric: tabular-nums; }

input[type="range"] {
  width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none; accent-color: var(--green);
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--border); border-radius: 2px; }
input[type="range"]::-moz-range-track { height: 4px; background: var(--border); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--green); margin-top: -5px; border: none; }
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--green); border: none; }
input[type="color"] { width: 44px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: transparent; cursor: pointer; }
textarea {
  width: 100%; resize: vertical; min-height: 44px; padding: 6px 8px;
  background: rgba(0, 0, 0, 0.35); color: var(--fg); border: 1px solid var(--border);
  border-radius: 6px; font-family: inherit; font-size: 12px; line-height: 1.4;
}
textarea:focus, input:focus { outline: none; border-color: var(--green); }

.adv { margin-top: 4px; border-top: 1px solid var(--border); padding-top: 8px; }
.adv summary { cursor: pointer; font-size: 12px; font-weight: 700; color: var(--green); opacity: 0.85; margin-bottom: 8px; list-style: none; user-select: none; }
.adv summary::-webkit-details-marker { display: none; }
.adv summary::before { content: '▸ '; }
.adv[open] summary::before { content: '▾ '; }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 20px; margin-top: 2px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: rgba(255,255,255,0.15); border-radius: 20px; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::before { transform: translateX(18px); }
