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

:root {
  --bg: #0a0a0a;
  --surface: #1a1a1a;
  --surface-hover: #252525;
  --text: #f0f0f0;
  --text-muted: #888;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --danger: #ef4444;
  --success: #22c55e;
  --border: #333;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 400px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100%;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

h1 {
  font-size: 1.25rem;
  font-weight: 600;
}

h2 {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* Status indicator */
.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.status.connected .status-dot {
  background: var(--success);
}

/* Sections */
.section {
  margin-bottom: 2rem;
}

.section p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

/* QR Code */
#qr-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#qr-code {
  background: white;
  padding: 1rem;
  border-radius: 8px;
}

#qr-code img {
  display: block;
  max-width: 200px;
}

/* Device info */
.device-info {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.device-battery {
  color: var(--text-muted);
}

/* Control groups */
.control-group {
  margin-bottom: 1.5rem;
}

.control-group label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Slider */
.slider-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

input[type="range"] {
  flex: 1;
  height: 8px;
  -webkit-appearance: none;
  background: var(--surface);
  border-radius: 4px;
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
}

.slider-value {
  min-width: 2rem;
  text-align: center;
  font-weight: 600;
  font-size: 1.25rem;
}

/* Buttons */
.btn {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  background: var(--surface);
  color: var(--text);
}

.btn:hover {
  background: var(--surface-hover);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: white;
  width: 100%;
  padding: 1rem;
  font-size: 1rem;
  margin-top: 1rem;
}

.btn-danger:hover {
  background: #dc2626;
}

/* Button groups */
.preset-buttons,
.pattern-buttons,
.duration-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preset-buttons .btn,
.duration-buttons .btn {
  flex: 1;
  min-width: 60px;
}

.pattern-buttons .btn {
  flex: 1 1 calc(50% - 0.25rem);
}

.btn.active {
  background: var(--accent);
  color: white;
}

/* Loading state */
.btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Share link */
.share-link-container {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.share-link-container input {
  flex: 1;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.75rem;
}

.hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Touch Control Area */
.touch-area {
  position: relative;
  height: 200px;
  background: linear-gradient(to top, var(--surface) 0%, var(--accent) 100%);
  border-radius: 12px;
  touch-action: none;
  user-select: none;
  overflow: hidden;
  cursor: pointer;
}

.touch-indicator {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: var(--accent);
  opacity: 0.6;
  transition: height 0.05s ease-out;
  pointer-events: none;
}

.touch-intensity {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 4rem;
  font-weight: 700;
  color: white;
  opacity: 0.9;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.touch-hint {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.touch-area.active {
  background: linear-gradient(to top, var(--surface) 0%, var(--accent-hover) 100%);
}

.touch-area.active .touch-hint {
  opacity: 0;
}

/* Control Tabs */
.control-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tab {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
}

.tab.active {
  background: var(--accent);
  color: white;
}

/* Motion Control Area */
.motion-area {
  position: relative;
  height: 200px;
  background: linear-gradient(to top, var(--surface) 0%, #10b981 100%);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.motion-indicator {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: #10b981;
  opacity: 0.6;
  transition: height 0.1s ease-out;
  pointer-events: none;
}

.motion-intensity {
  position: absolute;
  font-size: 4rem;
  font-weight: 700;
  color: white;
  opacity: 0.9;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
  z-index: 1;
}

.motion-hint {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.motion-enable-btn {
  width: 100%;
  margin-top: 0.75rem;
}

.motion-enable-btn.hidden {
  display: none;
}

.shake-feedback {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.9);
  color: #0a0a0a;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.875rem;
  z-index: 2;
  animation: shake-pop 0.3s ease-out;
}

@keyframes shake-pop {
  0% { transform: translateX(-50%) scale(0.8); opacity: 0; }
  50% { transform: translateX(-50%) scale(1.1); }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Responsive */
@media (max-width: 360px) {
  .container {
    padding: 1rem;
  }

  .preset-buttons .btn {
    min-width: 50px;
    padding: 0.5rem;
  }
}
