html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100%;
  height: var(--app-height, 100vh);
  overflow: hidden;
}

body {
  background-color: #111;
  color: white;
  font-family: sans-serif;
  user-select: none;
}

canvas {
  display: block;
  background-color: #1a1a1a;
  cursor: crosshair;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#ui-layer {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  background: rgba(20, 20, 20, 0.92);
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
  border: 1px solid #333;
  width: 320px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transition: max-height 0.3s ease-in-out;
  box-sizing: border-box;
}

#ui-layer.collapsed {
  max-height: 44px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #222;
  cursor: pointer;
  border-bottom: 1px solid #333;
  position: sticky;
  top: 0;
  z-index: 11;
}

.panel-header:hover {
  background: #2b2b2b;
}

.panel-header h2 {
  margin: 0;
  font-size: 14px;
  color: #fff;
  letter-spacing: 0.5px;
}

.toggle-icon {
  color: #00e5ff;
  font-size: 12px;
  transition: transform 0.3s ease;
}

#ui-layer.collapsed .toggle-icon {
  transform: rotate(180deg);
}

.tab-header {
  display: flex;
  border-bottom: 1px solid #333;
  background: #181818;
}

.tab-btn {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
  font-size: 10px;
  font-weight: bold;
  color: #888;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn:hover {
  color: #fff;
  background: #222;
}

.tab-btn.active {
  color: #00e5ff;
  border-bottom: 2px solid #00e5ff;
  background: #1a1a1a;
}

.panel-body {
  padding: 15px;
}

p {
  margin-top: 0;
  font-size: 12px;
  color: #aaa;
  margin-bottom: 15px;
  line-height: 1.4;
}

.control-group {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #333;
}

.control-group label {
  display: block;
  font-size: 11px;
  color: #00e5ff;
  font-weight: bold;
  margin-bottom: 5px;
}

.ratio-display {
  font-family: monospace;
  font-size: 13px;
  color: #fff;
  background: #2a2a2a;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 8px;
}

.slider-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.slider-container {
  position: relative;
  flex-grow: 1;
  display: flex;
  align-items: center;
  height: 24px;
}

input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: #00e5ff;
  cursor: pointer;
  position: relative;
  z-index: 2;
  min-height: 28px;
}

.mode-btn {
  width: 100%;
  padding: 9px;
  background-color: #00e5ff;
  color: #000;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.mode-btn:hover {
  opacity: 0.9;
}

#actionBtn {
  background-color: #00ff7f;
  color: #000;
  font-size: 13px;
  letter-spacing: 0.5px;
  margin-bottom: 15px;
}

#actionBtn.running {
  background-color: #ff3366;
  color: #fff;
}

#curveBtn {
  background-color: #222;
  color: #ff3366;
  border: 1px solid #ff3366;
  margin-bottom: 15px;
}

#curveBtn.active {
  background-color: #ff3366;
  color: #000;
  box-shadow: 0 0 10px rgba(255, 51, 102, 0.4);
}

.guide-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 4px 0;
  font-size: 11px;
  color: #bbb;
  line-height: 1.4;
}

.guide-key {
  flex-shrink: 0;
  min-width: 64px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid #444;
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 10px;
  color: #00e5ff;
  text-align: center;
}