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

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface-light: #1f3056;
  --text: #e0e0e0;
  --text-dim: #8892a4;
  --accent: #4fc3f7;
  --open-color: #4caf50;
  --close-color: #f44336;
  --stop-color: #ff9800;
  --radius: 12px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

/* ---- Gate Control Screen ---- */
.gate-container {
  width: 100%;
  max-width: 400px;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 32px;
  padding-top: env(safe-area-inset-top, 16px);
}

.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

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

.dot-connected {
  background: var(--open-color);
  box-shadow: 0 0 6px var(--open-color);
}

.dot-disconnected {
  background: var(--close-color);
  box-shadow: 0 0 6px var(--close-color);
}

#connection-text {
  font-size: 13px;
  color: var(--text-dim);
  flex: 1;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.icon-btn:active {
  background: var(--surface-light);
}

/* ---- Gate Visual ---- */
.gate-status {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.gate-icon {
  width: 160px;
  height: 130px;
  transition: color 0.3s;
}

.gate-idle { color: var(--accent); }
.gate-unknown { color: var(--text-dim); opacity: 0.5; }

.gate-state-text {
  font-size: 18px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* ---- Control Buttons ---- */
.controls {
  display: flex;
  gap: 12px;
}

.control-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  color: #fff;
}

.control-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-open {
  background: var(--open-color);
}

.btn-stop {
  background: var(--stop-color);
}

.btn-close {
  background: var(--close-color);
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-light);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 100;
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast.toast-error {
  border-left: 3px solid var(--close-color);
}

.toast.toast-success {
  border-left: 3px solid var(--open-color);
}
