/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.container {
  width: 100%;
  max-width: 420px;
  padding: 24px 20px;
}

/* Title bar */
.title-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
}

.title {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 600;
  color: #e0e0e0;
}

.btn-power {
  position: absolute;
  right: 0;
  background: #16213e;
  border: 2px solid #2a3a5c;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-power:active {
  background: #1e2d4a;
  transform: scale(0.93);
}

.btn-power.off {
  color: #ef4444;
  border-color: #ef444466;
}

.btn-power.on {
  color: #4ade80;
  border-color: #4ade8066;
}

.btn-power.waking {
  color: #facc15;
  border-color: #facc15;
  animation: pulse-power 1.5s ease-in-out infinite;
}

@keyframes pulse-power {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Poll activity light */
.poll-light {
  position: absolute;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #334155;
  transition: background 0.6s ease-out, box-shadow 0.6s ease-out;
}

.poll-light.active {
  background: #4ade80;
  box-shadow: 0 0 6px #4ade8066;
}

.poll-light.error {
  background: #ef4444;
  box-shadow: 0 0 6px #ef444466;
}

/* Server settings */
.settings {
  margin-bottom: 16px;
}

.settings label {
  display: block;
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.server-input {
  display: flex;
  gap: 8px;
}

.server-input input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #333;
  border-radius: 8px;
  background: #16213e;
  color: #eee;
  font-size: 0.95rem;
  outline: none;
}

.server-input input:focus {
  border-color: #4a90d9;
}

.btn-connect {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #4a90d9;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-connect:active {
  background: #3a7bc8;
}

/* Status bar */
.status {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  background: #16213e;
  margin-bottom: 24px;
  font-size: 0.9rem;
  color: #999;
  transition: all 0.3s;
}

.status.connected {
  color: #4ecdc4;
  border: 1px solid #4ecdc42a;
}

.status.error {
  color: #ff6b6b;
  border: 1px solid #ff6b6b2a;
}

/* Device status indicators */
.device-status {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.device-indicator {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #16213e;
  border-radius: 8px;
}

.device-btn {
  border: 1px solid #2a3a5c;
  cursor: pointer;
  transition: background 0.15s;
}

.device-btn:active {
  background: #1e2d4a;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-on { background: #4ade80; box-shadow: 0 0 6px #4ade8066; }
.dot-off { background: #ef4444; box-shadow: 0 0 6px #ef444466; }
.dot-booting { background: #facc15; box-shadow: 0 0 6px #facc1566; }
.dot-unknown { background: #555; }

.device-label {
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.device-state {
  margin-left: auto;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ccc;
}

/* Audio mode buttons */
.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

/* Shared button styles */
.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-user-select: none;
  user-select: none;
}

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

.btn-icon {
  font-size: 1.5rem;
  margin-bottom: 2px;
}

.btn-label {
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-desc {
  font-size: 0.73rem;
  margin-top: 1px;
  opacity: 0.7;
}

/* Gaming mode button */
.btn-gaming {
  background: linear-gradient(135deg, #2d1b69 0%, #1a1145 100%);
  color: #c4b5fd;
  border-color: #4c3a8f;
}

.btn-gaming:active {
  background: linear-gradient(135deg, #3d2b79 0%, #2a2155 100%);
}

.btn-gaming.active {
  border-color: #c4b5fd;
  border-width: 2px;
  background: linear-gradient(135deg, #7c3aed 0%, #4c1d95 100%);
  color: #ffffff;
  box-shadow: 0 0 20px #7c3aedaa, 0 2px 8px #0008;
}

/* Normal mode button */
.btn-normal {
  background: linear-gradient(135deg, #1b4332 0%, #0d2818 100%);
  color: #86efac;
  border-color: #2d6a4f;
}

.btn-normal:active {
  background: linear-gradient(135deg, #2b5342 0%, #1d3828 100%);
}

.btn-normal.active {
  border-color: #4ade80;
  background: linear-gradient(135deg, #2d6a4f 0%, #1b4332 100%);
  box-shadow: 0 0 30px #4ade8066;
}

/* Headphone mode button */
.btn-headphone {
  background: linear-gradient(135deg, #1b3a4b 0%, #0d1f2d 100%);
  color: #7dd3fc;
  border-color: #2a5a6f;
}

.btn-headphone:active {
  background: linear-gradient(135deg, #2b4a5b 0%, #1d2f3d 100%);
}

.btn-headphone.active {
  border-color: #38bdf8;
  background: linear-gradient(135deg, #2a5a6f 0%, #1b3a4b 100%);
  box-shadow: 0 0 30px #38bdf866;
}

/* Volume ruler bar */
.ruler-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #16213e;
  border-radius: 12px;
  padding: 7px 12px;
  margin-bottom: 12px;
}

.ruler-canvas {
  flex: 1;
  min-width: 0;
  display: block;
  cursor: ew-resize;
}

.volume-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  flex-shrink: 0;
}

.brand-icon {
  width: 18px;
  height: 18px;
  fill: #64748b;
}


.btn-mute-icon {
  background: none;
  border: 2px solid #2a3a5c;
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
  position: relative;
}

.btn-mute-icon:active {
  background: #1e2d4a;
}

.btn-mute-icon.muted::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  border: 3px solid #ef4444;
  border-radius: 50%;
  background: linear-gradient(
    to top right,
    transparent 42%,
    #ef4444 42%,
    #ef4444 58%,
    transparent 58%
  );
}


/* Rotary knob volume control */
.volume-knob-bar {
  align-items: center;
}

.tv-knob {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  margin-left: auto;
  display: block;
  cursor: grab;
}

.tv-knob:active {
  cursor: grabbing;
}

/* Output radio buttons */
.output-radios {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.output-option {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: #94a3b8;
  cursor: pointer;
}

.output-option input[type="radio"] {
  accent-color: #4a90d9;
  margin: 0;
}

.output-option span {
  user-select: none;
}

/* Feedback animation for button presses */
.btn.sending {
  opacity: 0.5;
  pointer-events: none;
  animation: pulse-sending 1s ease-in-out infinite;
}

@keyframes pulse-sending {
  0%, 100% { opacity: 0.5; }
  50%       { opacity: 1; }
}
