*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0c0c1e;
  color: #e8e8f0;
  font-family: 'Courier New', Courier, monospace;
  touch-action: manipulation;
}

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

#gameCanvas {
  position: absolute;
  inset: 0;
  display: block;
}

/* ── Top Bar ── */
#topBar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 16px;
  background: linear-gradient(to bottom, rgba(12,12,30,0.96) 70%, transparent);
  z-index: 10;
  pointer-events: none;
}

#topBar > * { pointer-events: all; }

.counter {
  margin-right: auto;
  font-size: 22px;
  font-weight: bold;
  color: rgba(255,220,50,0.7);
  letter-spacing: 0.05em;
  pointer-events: none;
}

.status-msg {
  font-size: 13px;
  color: #aaa;
  margin-right: auto;
}

/* ── Buttons ── */
.btn {
  border: none;
  border-radius: 10px;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.1s;
  touch-action: manipulation;
  outline: none;
  -webkit-appearance: none;
}

.btn:active { transform: scale(0.94); opacity: 0.8; }

.btn.primary {
  background: rgba(255,220,50,0.92);
  color: #0c0c1e;
  padding: 10px 22px;
  font-size: 16px;
  min-height: 44px;
  min-width: 90px;
}

.btn.icon {
  background: rgba(255,255,255,0.08);
  color: #ccc;
  width: 44px;
  height: 44px;
  font-size: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,0.12);
}

.btn.icon.small {
  width: 36px;
  height: 36px;
  font-size: 15px;
}

.btn.large {
  padding: 16px 44px;
  font-size: 20px;
  border-radius: 14px;
  min-height: 56px;
}

.hidden { display: none !important; }

/* ── Welcome Overlay ── */
#welcome {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12,12,30,0.93);
  z-index: 50;
}

.welcome-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
  padding: 40px 32px;
  max-width: 400px;
}

.logo { font-size: 64px; line-height: 1; }

.welcome-box h1 {
  font-size: 2.2rem;
  color: #FFD700;
  letter-spacing: 0.08em;
}

.welcome-box p {
  font-size: 1rem;
  color: #999;
  line-height: 1.8;
}

/* ── Settings Panel ── */
.panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(360px, calc(100vw - 24px));
  background: rgba(14,14,32,0.97);
  border: 1px solid rgba(255,220,50,0.22);
  border-radius: 18px;
  z-index: 20;
  overflow: hidden;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 40px rgba(0,0,0,0.55);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-size: 15px;
  font-weight: bold;
  color: #FFD700;
}

.panel-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sgroup {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sgroup > label {
  font-size: 11px;
  color: #777;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* String toggles */
.str-row { display: flex; gap: 7px; }

.str-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 6px;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  touch-action: manipulation;
}

.str-btn b {
  font-size: 17px;
  font-family: 'Courier New', monospace;
}

.str-btn small { font-size: 10px; }

.str-btn.active {
  background: color-mix(in srgb, var(--c) 18%, transparent);
  border-color: var(--c);
  color: var(--c);
}

/* Fret range */
.fret-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fval-box {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.fval-box > span { font-size: 11px; color: #777; }

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

.adj-btn {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
  color: #ddd;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  line-height: 1;
}

.adj-btn:active { background: rgba(255,255,255,0.18); }

#fretMinVal, #fretMaxVal {
  font-size: 26px;
  font-weight: bold;
  color: #FFD700;
  min-width: 32px;
  text-align: center;
}

.fval-sep { color: #444; font-size: 18px; padding-top: 14px; }

/* Sliders */
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #666;
  font-size: 12px;
}

.slider-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: rgba(255,255,255,0.14);
  border-radius: 2px;
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  background: #FFD700;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(255,220,50,0.45);
}

.slider-row input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  background: #FFD700;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}
